From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4203B2836E for ; Fri, 22 May 2026 15:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465211; cv=none; b=lml9g/ZsmfKMaeZ9cMR+daR9LDLrq50zP987I7Z+Pm4PGFHEpgqKHF3DO3orTY2MCpdqB9/7Ek3OmI/CUMjCmgksxn8j2Xr1g58Fi46YIbM8mkYK8WO2XvhrR4AdAiwCH1fmD8DxrMKUlHeWunFuwT0kxfWRJHANPuw/DRvzmZE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779465211; c=relaxed/simple; bh=kUDdYKQJRuSyELyHCrcRcrVqLZiSl+J2yY4EH3oO/j8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ktATDGExqUtvQxotpVEly+UEW3/riD5GUmfAPl2iwlkDhGuGp7EptY5cqlsV+wmBL2cVrR2hCDx/oRS2u+gVgFnF+LyvZXo9iElLVSzfQnVe1ceTJcRazecs1Q3jAURoRtmh/gvd0W9xBaxVwptThrAgUFtWDNlHZWOdQakB+vg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=MuXsjjQg; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="MuXsjjQg" Date: Fri, 22 May 2026 08:53:10 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779465198; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=AwTt7VfN0tnXd1ZqN8u19c+a+Qxdue+k49zPjLSV3ZY=; b=MuXsjjQgauUbq6p7cS5X7gF5Z6HEZ2T6QHo3Z+tfEZAPeGfOfiun15kqxaardGLnl0Zz4b mTHGPWLoISi8nc4sgxwqejS7QzEnX572JGU6D0A9CSPWg7wtkhV/8dnteZkKgY77lgztYK TMV+2hhiahKs40JSX0J9m6xncftzo8k= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Eric Chanudet Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Andrew Morton , Maarten Lankhorst , Maxime Ripard , Natalie Vock , Tejun Heo , Michal =?utf-8?Q?Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "T.J. Mercier" , Christian =?utf-8?B?S8O2bmln?= , Maxime Ripard , Albert Esteve , Dave Airlie , linux-doc@vger.kernel.org Subject: Re: [PATCH v2 1/2] mm/memcontrol: add dmem charge/uncharge functions Message-ID: References: <20260519-cgroup-dmem-memcg-double-charge-v2-0-db4d1407062b@redhat.com> <20260519-cgroup-dmem-memcg-double-charge-v2-1-db4d1407062b@redhat.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260519-cgroup-dmem-memcg-double-charge-v2-1-db4d1407062b@redhat.com> X-Migadu-Flow: FLOW_OUT On Tue, May 19, 2026 at 11:59:01AM -0400, Eric Chanudet wrote: > Add mem_cgroup_dmem_charge() and mem_cgroup_dmem_uncharge() to allow > dmem pool allocations to optionally be double-charged against the memory > controller. Take the struct cgroup from the dmem pool's css as there is > no convenient object exported to represent these allocations. These will > resolve the effective memory css from that cgroup and perform the > charge. > > Introduce a MEMCG_DMEM stat counter to memory.stat to make the cgroup's > dmem charge visible. > > Signed-off-by: Eric Chanudet > --- > include/linux/memcontrol.h | 16 ++++++++++++ > mm/memcontrol.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 81 insertions(+) > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > index dc3fa687759b45748b2acee6d7f43da325eb50c1..8e1d49b87fb64e6114f3eb920293e14920290fe7 100644 > --- a/include/linux/memcontrol.h > +++ b/include/linux/memcontrol.h > @@ -39,6 +39,7 @@ enum memcg_stat_item { > MEMCG_ZSWAP_B, > MEMCG_ZSWAPPED, > MEMCG_ZSWAP_INCOMP, > + MEMCG_DMEM, > MEMCG_NR_STAT, > }; > > @@ -1872,6 +1873,21 @@ static inline bool mem_cgroup_zswap_writeback_enabled(struct mem_cgroup *memcg) > } > #endif > > +#if defined(CONFIG_MEMCG) && defined(CONFIG_CGROUP_DMEM) > +bool mem_cgroup_dmem_charge(struct cgroup *cgrp, unsigned int nr_pages, > + gfp_t gfp_mask); > +void mem_cgroup_dmem_uncharge(struct cgroup *cgrp, unsigned int nr_pages); > +#else > +static inline bool mem_cgroup_dmem_charge(struct cgroup *cgrp, > + unsigned int nr_pages, gfp_t gfp_mask) Please follow Johannes's request to pass the actually memory object instead of naked numbers.