From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 C6B162F1FDF for ; Mon, 29 Jun 2026 19:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782760231; cv=none; b=AbRQB16tG9/OmlZEZx8ps1JjB7u2m8aqJubwv/aY/31Oe9p6jQyK06wMElYg76OvjToozTrPX5fHFolfbhWyh/LM73l7OoickiuEDfO70nSv/m4wYk9tflxxqMYUjmH+GdrRdfN7zkmzST/mPeMEGHPp9jZnPzjKKFDjN4x3eGk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782760231; c=relaxed/simple; bh=5GCD0k2wHB4fN5o0m9P+G5gpRGGLNrHpg8q8caPBXYg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lY5zYeAXAt3d+9Rx7boLGkA1XNG0xkGz1/lsiNXir+n2CUFmeHofKN4VNEvpuM2pRoE2hWuA7u04rchZ+AMQ69f2/Bh8cuWxNgjIG9kfkdj7ptjtHElckPfZ2g130957xW4ZSm2gKPV141AGO1RSo8m2o6djgOKrafSabzmYUvQ= 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=CTsUoAeU; arc=none smtp.client-ip=209.85.167.175 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="CTsUoAeU" Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-4877a7b451dso2466798b6e.0 for ; Mon, 29 Jun 2026 12:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782760229; x=1783365029; 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=YqlqX82xmlKGNezyrTYUwMGt6l+Ufnqh/0K5ySWqGfo=; b=CTsUoAeUvw3T0Qrmk3eYWPUY2930H3IkRSmlnX9iyZBq9nL/kSd3LGmcBE+OLwRJc9 8pDBJCDvO5oHR52K2OFR77cottprYe1JvNa5NXDmhSmnF1IDIn67Wq6Uz3d9xGKBa8WA FrRc1SB9XccisuBn303BRw4md6PSdE8/24PHhoz9ycz67GoBwVxSQM+FfJ7J1FY7joE0 Nupl8L3ThyO6GvEHEWZTpPVXXc48zqEkbDODxj+IJHCND0tRUralH25t8CkMEhT+1ueo pZuk/DsPf9oIDTtnpYJmzpqJqGqjPuTcU9k3pDaIJN6UYi2kJS3q2K8PQ8QaeGKovVWJ A8Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782760229; x=1783365029; 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=YqlqX82xmlKGNezyrTYUwMGt6l+Ufnqh/0K5ySWqGfo=; b=MwBQJ49jpTsYvu/G6Vxtp9QYSdP8M0IKGt4DUsYxpUiFs9B+M6QeWUaa2GKN3otX4N wE5zkbMxJ0LTUAVTduF8hLgjT4scLeDl5KHsRxgI7KOawXGdyiOATUPh9vhMZNfWeqqc YJlSPb9+XL1SfqTvqkkuC5EreCn/ZJBwofiWU8ExR3R1g6SrC7JkI2Jbdfs1bvfgbmE2 tBTxk9PNhkkxDvvph32QpfEpwa10q/0YyDivZrmVreDnIhzOuaPM7DmOgZD1yBYVEb3Y X7dPKu/EOhyFK6lYVQLzmHwNzI0k3PDXflj1SCCqV5d4JX8i3ki7Z1W7R7jTW4O8uyRW VVRg== X-Forwarded-Encrypted: i=1; AFNElJ/yFxTYpIBIy1lB6ZJp/aMF5eNowQ7kMVPyXi9wwveBfAD/enuUzyI7sk3E16DJKp5vkrkkhlLJovNGRoM=@vger.kernel.org X-Gm-Message-State: AOJu0YxqwYpgBZrNbIheH4Qi0mCMxVNPMdIRC9Oelat07SHiaLEdsz7K r4pozKJP2cfcQY0H4pbMOsbFZ5ZJOVuzTd1xhl5fGwbra9SXlqSJIRPM X-Gm-Gg: AfdE7cnMT8iPABVr/KrnepMfeRYtknd6gYVLIZ0vvSD5acoy+BxVtz9qH8hyndvXvg/ 9ktjSWWCOVqATeq6+F04j13kyz0FgZyds2IOkZX1IPimE7QERAFOpN4VamoEDUbRMpk4oRfaPV9 n0ngBHP5X6yeQu9qxuSTFnc8NtWIeoem5/N/ubQVTgfpqlgIpN6cSYmzbuWdKL59I736WGiCqVq vK8hXDkzlYxxA8NBqRPcbbFjw8FSsX60pW3TRZQ8DojccfpxvMywXxd1pBykMN2NaZ+X1NbZPhl 3TaHfO0mXeBVP9m++HKjXol/75mXLS8vCO1g+/eyYI4iIE12A6Lm48x57dbql6aza9d/ZHTu5bZ rVKY5nRkhKw6n46q4WfAF+NrBGN4hzn45x1NzCAogwHVWiojU5Bnw58KtuXAwLqfTTm/TVSn90D QbbUBOdYPBn0Ik8tQv7nWdv+smuHi4lg6+apl/JNB8a3g= X-Received: by 2002:a05:6808:1821:b0:492:c931:4d67 with SMTP id 5614622812f47-495ead9873cmr594933b6e.1.1782760228797; Mon, 29 Jun 2026 12:10:28 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:46::]) by smtp.gmail.com with ESMTPSA id 5614622812f47-49352506000sm7433362b6e.3.2026.06.29.12.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jun 2026 12:10:28 -0700 (PDT) From: Joshua Hahn To: Alexandre Ghiti Cc: alexandre@ghiti.fr, Andrew Morton , Barry Song , Ben Segall , cgroups@vger.kernel.org, Chengming Zhou , Christoph Lameter , David Hildenbrand , Dennis Zhou , Dietmar Eggemann , Ingo Molnar , Johannes Weiner , Juri Lelli , Kairui Song , Kent Overstreet , K Prateek Nayak , "Liam R. Howlett" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Lorenzo Stoakes , Mel Gorman , Michal Hocko , Mike Rapoport , Minchan Kim , Muchun Song , Nhat Pham , Peter Zijlstra , Qi Zheng , Roman Gushchin , Sergey Senozhatsky , Shakeel Butt , Steven Rostedt , Suren Baghdasaryan , Tejun Heo , Valentin Schneider , Vincent Guittot , Vlastimil Babka , Wei Xu , Yosry Ahmed , Yuanchu Xie Subject: Re: [PATCH v2 4/9] mm: percpu: Split memcg charging and kmem accounting Date: Mon, 29 Jun 2026 12:10:26 -0700 Message-ID: <20260629191026.2124952-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260626102358.1603618-5-alex@ghiti.fr> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit > This is preparatory patch for upcoming per-memcg-per-node kmem > accounting. Hi Alex, I hope you are doing well. Thank you for the series! And sorry that I took so long to review. I'm slowly going through the series, so I expect to leave more comments in the future. > Percpu allocations charge memory before knowing which NUMA nodes the > pages will land on. So we need to decouple the memcg charging from the > kmem accounting: > > 1. In the pre-alloc hook, obj_cgroup_precharge() reserves pages for > memcg limit enforcement without updating kmem stats. > 2. In the post-alloc hook, obj_cgroup_account_kmem() accounts kmem > and places the sub-page remainder into the obj stock after the > allocation succeeds. > > Because of that decoupling, we must not rely on the stock in the > precharge function and always charge the necessary pages that will > be accounted after the allocations happened. I was thinking about this, I think the reality of the sitaution is actually a bit better than the description makes it seem. We're still using stock, just a different level so we're not losing any fastpath at all. Previously we would use the objcg stock to do the charge quickly, but if we're going straight to memcg charging, we'll be using the memcg stock instead. Maybe a clarification here that we're not relying on the obj_stock would help your case here : -) > That means we may > temporarily overcharge the memcg but the obj_stock draining will get > things back to normal. Nice, this is quite clean. We might hit memcg limits faster because we overcharge up to PAGE_SIZE bytes but... I'm not sure if this is even worth noting since the window is so small. I think in all the places where you use PAGE_ALIGN(x) >> PAGE_SHIFT we can instead use PFN_UP(x)? Or maybe DIV_ROUND_UP(x, PAGE_SIZE)? Just thought that this way we could avoid some of the two-line function calls ; -) > Signed-off-by: Alexandre Ghiti Anyways I think the split looks clean and makes sense to me. Sashiko raised no concerns either, just wanted to note some nits. I imagine there will be a v3 in the future? I think this patch looks good but I will wait until the next version to leave my signatures in case some of the context changes. Thanks again, Alex! I hope you have a great day, Joshua