From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 270203DFC7B for ; Mon, 30 Mar 2026 18:59:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774897191; cv=none; b=JhLHRASg426GXC0+vbjQF5l1PL+HcDAmmDTUiHW0tv5F/Anfoj8/Ir4NFeOusTMxbPygJd3+B7mt2KoZSuL6ZY32FJqA5vFpDeZCBslp3ysGOElQIg7B1t1Jg5VoXwvSfYGFPZ/7OmiJ7HfBUUyGGBufFIo5WNZGaaA3zBsdxrw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774897191; c=relaxed/simple; bh=5BjoNsXzpMy+cVOBp+gg/3lFykrDC40QD5dKZmKMGTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TEHbXlR1Qg4x1iAPm2Wliyf1Q7sUosji1fo43rMSDPiREUY816SRxwFGbLsPhmaLlVDPPrWJR5J92HfwwiR3SNEvtLFhSvpUel8jwca6K0X5vTgXZRlmnIrQ1Yff0d+ZHwp3kLN459RrV9IxE7sY/KuTQG31NKXmM9EMv7BrB8M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FIdg/ZZW; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FIdg/ZZW" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-464ba2bb3aeso2850895b6e.1 for ; Mon, 30 Mar 2026 11:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774897189; x=1775501989; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cFGS6w31Laz9Ddur1i7GLVmK/pVD2soBNffdP6C8TRo=; b=FIdg/ZZWuZtvCfbGY9TJBP0JcUsXK3cpvfzRxiBDU0sM8R67jZawLj6XnSOvkIM7MV ZWb+li5/FUErpMW0x+fRpj4SQiOEJiRuRlqFflxjJ0qa5FiTaMvsFMBFdXet69Oxrlxx dO3CmU7odExNg3/lcQKpyDNLIxGHXjTVoEnMN2fbkP2prpuGtESaslSMDl+ZGNUyUcHM KrGMRN7/1zaLweNAX7Ch4yyEmt0WznoTuOpMwehahDxGxp5vrxYowQfF/41+nHeQdIl1 g1eW/ZODO2WX5TQZxCswcwXHpvxeFWWPywpnUjX0LG5o2smc4Cu+dWJSxTgF84CtND89 mg0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774897189; x=1775501989; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cFGS6w31Laz9Ddur1i7GLVmK/pVD2soBNffdP6C8TRo=; b=r9Av3a/ic5RBAj0yCQIJRNBLEA8wN7vHbORx0dTDkziIwr5zi2TSVdPfi9fEfCyP0+ koUp0yv5a+SyYOw+I8OODhixfm50w6uqerueTMvd8EmKjh1F6kMBptjrL7xuOCvl8SXf isugnQ/H8ua2W2zN4mQnbQW8HBrzBqKQd9/moqvj+jl9Zb1iKbXFr2xivSop6aoS9fHp IvqDP3CWfnIVzGCMGSWICSe5uyUuYYCXVc+c7VGu4J/Nk7wlDNZC8xZiuZoYQefaZU7X +r1783hbf8kj35U7rEaV/xQyZalnXmoiu+KyCfXq50kXXD6nGzR//b4R1bKXWY7qjbCU GGlw== X-Forwarded-Encrypted: i=1; AJvYcCULfier5tHbNh4wMeLaBTkIP1D6bW+jHkh/QrAv0YBpm971OomBkx3+VK+KsRcPZ6jwD7ajCnq35xHIsnE=@vger.kernel.org X-Gm-Message-State: AOJu0YyeJtoR+PorWH5GnnfUWQlEOtJliIkg+jOCi5p5NC9Mat7Ab7Ys bai6OxI9tOXuXd643WUDsgzEtunQKGdXknVSquuFbUNnM5/o0GoaJU49 X-Gm-Gg: ATEYQzypOkeN5qz7zMxiRYUl3uyE67myjAa5ozEkre/HzhnaByrZzgqEH4w9nJqoM0P 36NwQ0SPYj2Y99bHG+bL5w63k4MD/qMhgXdip2UJs4/4HY7Jg7cbUmStHNfpgyK+qnGYhgUS/wy Fn2cr5OEiwyQxl05VfrLE0qTHx23Mbi4EmU+6cZEbpOkbflHDBXNYAX+mUqVvR/WnOj2WqchcsA gqoDY62oyidbMwu3UQar6Cvjyc97xasjjChQqghzqFMEbqPwUsAlnlaWkL7f2F17OcY+WT+vZyX bSXqxvuR+h/rW+GNR7f32NrA3H8FIHi+xYKrEsFQaNT/gXVItX/a1d0b/hylkZKlXkrU/98N9BR gUYREWMly69hh6mBKu1seE3O3CnXN7SFKLXha0wQ2Yn/6PlILavPuSdwf2R35A2ylj8tsWDU2Mw N7creFc9VSqOAytCqM60p7hA== X-Received: by 2002:a05:6808:2f09:b0:467:f1e5:a294 with SMTP id 5614622812f47-46acdb4b61cmr444228b6e.4.1774897188917; Mon, 30 Mar 2026 11:59:48 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:73::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-46aa03656e2sm5180605b6e.11.2026.03.30.11.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 11:59:48 -0700 (PDT) From: Joshua Hahn To: Yosry Ahmed Cc: Michal Hocko , Johannes Weiner , Andrew Morton , Roman Gushchin , Shakeel Butt , Muchun Song , David Hildenbrand , Lorenzo Stoakes , Vlastimil Babka , Dennis Zhou , Tejun Heo , Christoph Lameter , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH] mm/percpu, memcontrol: Per-memcg-lruvec percpu accounting Date: Mon, 30 Mar 2026 11:59:45 -0700 Message-ID: <20260330185947.2427740-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mon, 30 Mar 2026 11:35:38 -0700 Yosry Ahmed wrote: > On Mon, Mar 30, 2026 at 7:21 AM Michal Hocko wrote: > > > > On Mon 30-03-26 07:10:10, Joshua Hahn wrote: > > > On Mon, 30 Mar 2026 14:03:29 +0200 Michal Hocko wrote: > > > > > > > On Fri 27-03-26 12:19:35, Joshua Hahn wrote: > > > > > Convert MEMCG_PERCPU_B from a memcg_stat_item to a memcg_node_stat_item > > > > > to give visibility into per-node breakdowns for percpu allocations and > > > > > turn it into NR_PERCPU_B. > > > > > > > > Why do we need/want this? > > > > > > Hello Michal, > > > > > > Thank you for reviewing my patch! I hope you are doing well. > > > > > > You're right, I could have done a better job of motivating the patch. > > > My intent with this patch is to give some more visibility into where > > > memory is physically, once you know which memcg it is in. > > > > Please keep in mind that WHY is very often much more important than HOW > > in the patch so you should always start with the intention and > > justification. > > > > > Percpu memory could probably be seen as "trivial" when it comes to figuring > > > out what node it is on, but I'm hoping to make similar transitions to the > > > rest of enum memcg_stat_item as well (you can see my work for the zswap > > > stats in [1]). > > > > > > When all of the memory is moved from being tracked per-memcg to per-lruvec, > > > then the final vision would be able to attribute node placement within > > > each memcg, which can help with diagnosing things like asymmetric node > > > pressure within a memcg, which is currently only partially accurate. > > > > > > Getting per-node breakdowns of percpu memory orthogonal to memcgs also > > > seems like a win to me. While unlikely, I think that we can benefit from > > > some amount of visibility into whether percpu allocations are happening > > > equally across all CPUs. > > > > > > What do you think? Thank you again, I hope you have a great day! > > > > I think that you should have started with this intended outcome first > > rather than slicing it in pieces. Why do we want to shift to per-node > > stats for other/all counters? What is the cost associated comparing to the > > existing accounting (if any)? Please go into details on how do you plan > > to use the data before we commit into a lot of code churn. > > > > TBH I do not see any fundamental reasons why this would be impossible > > but I am not really sure this is worth the work and I also do not see > > potential subtle issues that we might stumble over when getting there. > > So I would appreciate if you could have a look into that deeper and > > provide us with evaluation on how do you want to achieve your end goal > > and what can we expect on the way. It is, of course, impossible to see > > all potential problems without starting implementing the thing but a > > high level evaluation would be really helpful. > > You should probably also speak to extra memory overhead to move all > these stats from per-memcg to per-lruvec. Hello Yosry, Thank you for your feedback! Here are the things that I cna see from my end: - NR_PERCPU_B adds a byte per-node, per-cpu. I think this is manageable. - lruvec_stats_percpu grows by 1 long in 2 arrays (state, state_prev) since NR_MEMCG_NODE_STAT_ITEMS grows by 1 from ~30. This is +16 bytes per cgroup x node x CPU. Even still, I'm not sure this is too concerning, on a host with 300 CPUs across 2 nodes with 100 cgroups (theoretical) we would see a 16 * 300 * 2 * 100 = 937 kB change, less than a mB (and I think this would be considered a big machine). What do you think? Do these numbers look acceptable? Thanks again for your insights, I hope you have a great day : -) Joshua