From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93097CD128A for ; Wed, 3 Apr 2024 17:03:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BF8C16B0082; Wed, 3 Apr 2024 13:03:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA9136B0083; Wed, 3 Apr 2024 13:03:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A70FD6B0085; Wed, 3 Apr 2024 13:03:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8986D6B0082 for ; Wed, 3 Apr 2024 13:03:02 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 41956A0CE5 for ; Wed, 3 Apr 2024 17:03:02 +0000 (UTC) X-FDA: 81968840604.23.2BC143E Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) by imf22.hostedemail.com (Postfix) with ESMTP id E0BB6C002C for ; Wed, 3 Apr 2024 17:02:59 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hZoh+pO+; spf=pass (imf22.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.171 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712163780; a=rsa-sha256; cv=none; b=A67vAroYM0u3s8uRr8sjL28q+r+WN5OUilLfPp3wzsp62+krvWDbexBCfka0srZT257O// Q+iF21swDrpNw5MqUf3Dw10pp2CyrXTl/QKy1CdGuVLaXvBGSot2a5/Gt7DAoT2d6ui6oC PtKbwJm0pX3d00PZQtzGdWRnQqQKjw0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hZoh+pO+; spf=pass (imf22.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.171 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712163780; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l2xgd3X9t4EgBaNAFDJVjvxOH1jxFC0KojtDFbkugeQ=; b=sRo1J+efPElINLo0P3oib7Q7e2ZX2WevQgxdNb20n1/RaVymtwTBMBTM9mRR9ZI+pdtgpY rX8rkOEiooychdqZn1VO0tarHfQxmink4o5eiI9AdbmKTQT1i2J6kiSOklPhy7jwWyvw6Q Fc3jMi4KY3FuUW5yW2uO8UhKGwMGfsQ= Date: Wed, 3 Apr 2024 10:02:40 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1712163777; 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=l2xgd3X9t4EgBaNAFDJVjvxOH1jxFC0KojtDFbkugeQ=; b=hZoh+pO+l0APIgPQISDmnLTHEmqpxabM1zSle/bXSt0Rv0Hu5Vb48tN7QWGsBv2nWTDfZB PfmejjrzTBt5G7M7FpBZ7m1h684jEvO4ylLhoT46tLRwJrbcun1U5Bi2j0KgR41qRLra/o k172DDMShT0o2CtvIZmeFyo3MVW6cyk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Roman Gushchin To: Vlastimil Babka Cc: Aishwarya TCV , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-fsdevel@vger.kernel.org, Chengming Zhou , Linus Torvalds , Josh Poimboeuf , Jeff Layton , Chuck Lever , Kees Cook , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Hyeonggon Yoo <42.hyeyoo@gmail.com>, Johannes Weiner , Michal Hocko , Muchun Song , Alexander Viro , Christian Brauner , Jan Kara , Shakeel Butt , Mark Brown Subject: Re: [PATCH v2 1/2] mm, slab: move memcg charging to post-alloc hook Message-ID: References: <20240325-slab-memcg-v2-0-900a458233a6@suse.cz> <20240325-slab-memcg-v2-1-900a458233a6@suse.cz> <30df7730-1b37-420d-b661-e5316679246f@arm.com> <4af50be2-4109-45e5-8a36-2136252a635e@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4af50be2-4109-45e5-8a36-2136252a635e@suse.cz> X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E0BB6C002C X-Stat-Signature: rip7cp1k5sydagtzj5e7gitiphjqqyr4 X-Rspam-User: X-HE-Tag: 1712163779-903721 X-HE-Meta: U2FsdGVkX19EhFvRrhNw4+yuaPwphVj5CdweVRXYoE7oniUrDjKCcCYOYn7an4el3FeoKxpghDEPUHvRK2zkkZ2CvSDGY5TLRIo9TjZUkZt5My7QpnSFDi0OlydONWmAtVlm+HpqsiM9LxEE9UjwDYVhuvf01etTVEQi5SE9+tp+ZCauQkHu2A1cEUmStKx8vPRZjaOClMzO6KvJohmt5JPV7H+YhuBEYP/4N5TiEukosa5i6H4qKHHx3nSV7r2v828Nky7ZMKSsWi9Dmk2E8hnFJFsJdmI9Sng9hFz4SaxulECTH8z7tlMX/uWqHI2uQTugk8B2Sj5adFowWJee6KmdvJ0Ma1diC5ICHg6svguxMHfKHjvzqq+xM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sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Apr 03, 2024 at 05:48:24PM +0200, Vlastimil Babka wrote: > On 4/3/24 1:39 PM, Aishwarya TCV wrote: > > > > > > On 25/03/2024 08:20, Vlastimil Babka wrote: > >> The MEMCG_KMEM integration with slab currently relies on two hooks > >> during allocation. memcg_slab_pre_alloc_hook() determines the objcg and > >> charges it, and memcg_slab_post_alloc_hook() assigns the objcg pointer > >> to the allocated object(s). > >> > >> As Linus pointed out, this is unnecessarily complex. Failing to charge > >> due to memcg limits should be rare, so we can optimistically allocate > >> the object(s) and do the charging together with assigning the objcg > >> pointer in a single post_alloc hook. In the rare case the charging > >> fails, we can free the object(s) back. > >> > >> This simplifies the code (no need to pass around the objcg pointer) and > >> potentially allows to separate charging from allocation in cases where > >> it's common that the allocation would be immediately freed, and the > >> memcg handling overhead could be saved. > >> > >> Suggested-by: Linus Torvalds > >> Link: https://lore.kernel.org/all/CAHk-=whYOOdM7jWy5jdrAm8LxcgCMFyk2bt8fYYvZzM4U-zAQA@mail.gmail.com/ > >> Reviewed-by: Roman Gushchin > >> Reviewed-by: Chengming Zhou > >> Signed-off-by: Vlastimil Babka > >> --- > >> mm/slub.c | 180 +++++++++++++++++++++++++++----------------------------------- > >> 1 file changed, 77 insertions(+), 103 deletions(-) > > > > Hi Vlastimil, > > > > When running the LTP test "memcg_limit_in_bytes" against next-master > > (next-20240402) kernel with Arm64 on JUNO, oops is observed in our CI. I > > can send the full logs if required. It is observed to work fine on > > softiron-overdrive-3000. > > > > A bisect identified 11bb2d9d91627935c63ea3e6a031fd238c846e1 as the first > > bad commit. Bisected it on the tag "next-20240402" at repo > > "https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git". > > > > This works fine on Linux version v6.9-rc2 > > Oops, sorry, can you verify that this fixes it? > Thanks. > > ----8<---- > From b0597c220624fef4f10e26079a3ff1c86f02a12b Mon Sep 17 00:00:00 2001 > From: Vlastimil Babka > Date: Wed, 3 Apr 2024 17:45:15 +0200 > Subject: [PATCH] fixup! mm, slab: move memcg charging to post-alloc hook > > The call to memcg_alloc_abort_single() is wrong, it expects a pointer to > single object, not an array. > > Reported-by: Aishwarya TCV > Signed-off-by: Vlastimil Babka Oh, indeed. Reviewed-by: Roman Gushchin Vlastimil, here is another small comments fixup for the same original patch: diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0745a28782de..9bd0ffd4c547 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -353,7 +353,7 @@ static void memcg_reparent_objcgs(struct mem_cgroup *memcg, /* * A lot of the calls to the cache allocation functions are expected to be - * inlined by the compiler. Since the calls to memcg_slab_pre_alloc_hook() are + * inlined by the compiler. Since the calls to memcg_slab_post_alloc_hook() are * conditional to this static branch, we'll have to allow modules that does * kmem_cache_alloc and the such to see this symbol as well */ Thanks!