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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE91FCD4F3C for ; Tue, 19 May 2026 14:03:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C6196B008C; Tue, 19 May 2026 10:03:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5766C6B0092; Tue, 19 May 2026 10:03:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48C096B0093; Tue, 19 May 2026 10:03:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3653C6B008C for ; Tue, 19 May 2026 10:03:17 -0400 (EDT) Received: from smtpin09.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CEDC7A03D5 for ; Tue, 19 May 2026 14:03:16 +0000 (UTC) X-FDA: 84784336392.09.116ED23 Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by imf06.hostedemail.com (Postfix) with ESMTP id BA80B180022 for ; Tue, 19 May 2026 14:03:14 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="k/Sf/ctN"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1779199395; 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=RLkJJxHnitGVDPhMID677Jv5DkOQCt8pQUC50Rx5KFQ=; b=RkePZ73EsLWkwBKSf7D6HKWpK8NqH3z+MgQOjGcZQg2LDxTKTbGL21r6TBk0QQLBvWrQ69 xdsPSRkcyurgv296LtAzbNX13mUGrkkVbtLgaKIS70vy+uQgLG3C4vpdH3HvAAxE6Ubp6X ogkGhor8moC3QAhMKAJuRwuBG3xYDUs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1779199395; a=rsa-sha256; cv=none; b=Z8j9cujDWscFGOGE3aZbSAouAyN1AE6hvmB5CkoAVLO8+ERMcimfecUpkIPoGAc8Gp9I0m aiRwClPUByEh0b679h5nMrZvCsjDMEQiV5tr/MJZ8qZQK3VyovtwN3DScg9jUR4Koc67MU OhFHcQ0BBx5IbJ/IxSNO5qfR9N0tR1E= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="k/Sf/ctN"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.189 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev Date: Tue, 19 May 2026 07:02:47 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779199391; 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=RLkJJxHnitGVDPhMID677Jv5DkOQCt8pQUC50Rx5KFQ=; b=k/Sf/ctN+0g0y8K/IpdbvTp1cYEfoUAApm7k/DJj6iPyQHQkBLM9gQ6ylpR0M2yakt6epr jI0VSIqp37yHfaJPa46xMDp3LZg9yTfFjrirJEbUePonoLShekskAYNYqheBsfSPWAFsG9 Ukp0H+D0/xyn1dk/GrfPw8zgWZRKFFs= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Harry Yoo Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Roman Gushchin , Muchun Song , Qi Zheng , Alexandre Ghiti , Joshua Hahn , Meta kernel team , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: Re: [PATCH v3] memcg: cache obj_stock by memcg, not by objcg pointer Message-ID: References: <20260518222827.110696-1-shakeel.butt@linux.dev> <4e296262-fbbf-4ac7-aecc-3ef831583704@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e296262-fbbf-4ac7-aecc-3ef831583704@kernel.org> X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: BA80B180022 X-Stat-Signature: r3cdewjeya7s4ssp7q1axmrgwowgkqfe X-Rspam-User: X-HE-Tag: 1779199394-921942 X-HE-Meta: U2FsdGVkX1/QG8uyS8ZwBBqbp8EGHnvhSkP4jJfoV/i1rEBTPg5oYKm00Ilf3Ep3fu3Jr0vf5m4JBU6BXKHWeXYLHhRD4MLtwSTX2AgoNlhQfWRv3vOY9aED+4iZ2g3hHDAsdZxQRr156wKv5VyEsQZck5V5ag21S5UW5n4lgkREbWHBeL3QM7k4lKehhET9qJ227DqdCzSOvMas6qQywX7pF/Np9W9gTnDj6laxO8u4H8sH9ETqunv08KF/ETmWa6AsTPrtFQjEfaIhOjFMFklrAV+EHbmDFaRi9jfIF3EvZQSNINcS0PO/tAoYf11Q4DQQyAMRKwQ+Tgh/niKXukOfGrFbRLUuxO4F0OJoWDtr1N6eN0ylkmfbOiW532Ge3XUnMuhZ8URjGZLbIZjM8mixIM23spPHgFCAXwwKkoi8ncThzZn4T37PxdRssqYYQvi54RQOcOD0L9oKK4aaxu1pDUmICZSpeYaypmfeakrj1I9rrMy6R7+fvQJ4EwC83rHnXXp5x7eYAcN/1KnjjmLcnuiBfkld6apoSKXO67bjuXgfcwh5+xiPm+MbLO4NqlENMbA8iTkcr35x3Erfm4q12fJEwiGYbDgqHlgDFg6TiXi5NDo/8RuEatmRVBcWYN4Njsa5sy4e7xba59v+Zoejr6Kyp+ZmsS3tf1OzzDw1PijiDPVLXyyIUa5IwH6k+VWoKKKNao53HhC0tgX/+aVKj7zPZU1oKJtiSeksQePl9Qo7r5SzgNPM9R9hVClwIpbZ4wt1v7e3WERNZUlXpHRQsp2eTgtnl+ywLmJ4vYtCW3u8ev4kT8QKUDTmjtPhztZ+WpXrQdhDsGYNRikOVQqwJHpAs1dV8AbfzIs9Au9nfHDNBunX/oitmy57lf9l+MHxGijMNNwkgpuz1P+T/o3rQP3rHu7SH9c2z1efxUg57IspIJj+MG7qM6irDmMvIsn9YWcLvT8CkyZn92v 2IR3EhcV Pu3cisZHe3ikTkPk++NhnZfW8lp/vyqQNeN72gv/mFLRnAT6Um9yMZh91vFpA5P1hYq1A1F6mt2TnJOhjUdFKfRp27+YWalR/1gokSYCfeP0am2wrfDOyUG5Lp0hiD10VfmZsPEQdxbjHLzqDG0ava2oaLmHd87tCRsetJpv4wIEaGttNqU/ROe/gDNiykimO83OSgNuQL8t8vejiNAvL/E85grIJYcndMWvXTePsxLPV2Ef1JteWVJLPgTLx1gDTauQIQ7scxhOkLQe0xbdMqLQ1vm1q4lan36S3LKqrfo0k1euFkRp9BYmiKwn9O//DpI8QsaecysdxsXqQCf0+1OOyzPu3k3Tf6n5a Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, May 19, 2026 at 03:46:51PM +0900, Harry Yoo wrote: > > > On 5/19/26 8:41 AM, Shakeel Butt wrote: > > On Mon, May 18, 2026 at 03:28:27PM -0700, Shakeel Butt wrote: > > > Commit 01b9da291c49 ("mm: memcontrol: convert objcg to be per-memcg > > > per-node type") split a memcg's single obj_cgroup into one per NUMA > > > node, but the per-CPU obj_stock_pcp still keys cached_objcg by > > > pointer. Cross-NUMA workloads now see a drain on every refill and a > > > miss on every consume that targets a sibling per-node objcg of the > > > same memcg, producing the 67.7% stress-ng switch-mq regression > > > reported by LKP. > > > > > > stock->nr_bytes are fungible across per-node objcgs of one memcg. > > > Treat the cache as keyed by memcg in __consume_obj_stock() and > > > __refill_obj_stock() so siblings share the reserve. Compare via > > > READ_ONCE(objcg->memcg) directly: pointer-compare only, no deref, so > > > the rcu_read_lock contract on obj_cgroup_memcg() does not apply. > > > > > > Sharing the reserve without re-caching means bytes funded by one > > > per-node objcg's slow path can be consumed/freed under a different > > > sibling, leaving sub-page residue on whichever sibling was cached at > > > drain time. The pre-existing obj_cgroup_release() path would WARN and > > > silently drop that residue, leaking up to nr_node_ids * (PAGE_SIZE - 1) > > > bytes per memcg lifecycle from the page_counter. Forward the residue > > > into a per-node objcg of the same (post-reparent) memcg at release time > > > instead, so it can be reconciled later via a refill atomic_xchg or > > > another release; the chain terminates at root_mem_cgroup, whose > > > page_counter has no enforced limit. > > > > > > Please note that this is temporary fix and will be reverted when > > > per-node kmem accounting is introduced. > > ... because once per-node kmem accounting is introduced, > "stock->nr_bytes are fungible across per-node objcgs of one memcg" > no longer holds? Yes > > And the follow-up plain is to revert this and address it with a multi-objcg > percpu stock [1], similar to a multi-memcg percpu charge cache we have now, > right? (regardless of per-node kmem accounting's progress) > Yes > If this temporary fix imposes other potential correctness issues, would it > make sense to land [1] in mainline before the next LTS release and skip this > temporary fix? > > [1] https://lore.kernel.org/oe-lkp/agtPMpQK2jXdQAY4@linux.dev > The full clean solution might take one more cycle and I think we can not just ignore 67% regression on 7.1.