From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 A535E3BBFC8 for ; Fri, 5 Jun 2026 15:41:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780674101; cv=none; b=ohWvHL6uwhoj0jL536q0qqUR+HtW8mI8oNH+NBaFSI+CdE8gqb1/eWSM659XW0Pi4YhrXx9N8wD2ev/UWZRP3VuQmpv6tDdPUiqefjW0e2vlwg3SFAxzwf+tPb4FEBTLP+E5ICrrSpyZP6syZ3H4ltYm6FdJ2hRURSJNNwtNUUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780674101; c=relaxed/simple; bh=3lG1VFTIzPuOpKHLtUvNxm1Y7EPAysGI8/9QXN/VQjk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z9k22XXxy7LHIkz0/5xGrcJEbe5nwoPqQ7XhpgTKT4g6/9IAbBCV8luwulZDfEoevpL0yRx41JjaUebuzVozhcOc8AzcPPLUoCOOPiE4NDZ+0LTVmS1LK6dC0r2xMep5LqipOOTxLk+M7LDGYzKHr4wG/yRfkr2cmiOJ5657LK4= 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=W+cIeEh+; arc=none smtp.client-ip=209.85.210.42 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="W+cIeEh+" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-7e6f586a0d5so925312a34.0 for ; Fri, 05 Jun 2026 08:41:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780674100; x=1781278900; 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=KFfuDG07qzWYz9cM/uqAnn123BbnDuZibDKFIXN94Bs=; b=W+cIeEh+AD5sYEPfx8rpopl7tfNEl5qmqYdcW7cAyg7PJYfavUhMBeHu+iVQURAB25 fLYmdDzyn0NmXwPMvfRkQnJASpK+zqJtmr5nZL4eBJV1MntK6BYoVcG7GHj2ofv2ztlp QA8zw6zASRYEKVLbTXleb+d93oVTlLGSBX24dijO7CGkQThNNXSDy+m5yMI+HSNQAhu8 oTjBwdgMEWlT9NqL/V+miVp+r6onlwXaJh2NMaWNqbetJS48BnTVIyJgjM2MWLecirja yqSq+LkLSe3LR3F1gBoSQYU9fxkFAcJpsgl5nAV7OFQKpCSwkEdLacWGcW+PITZ9aKvv dNYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780674100; x=1781278900; 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=KFfuDG07qzWYz9cM/uqAnn123BbnDuZibDKFIXN94Bs=; b=K01u9Oel0bSiJDuSDLUwU1GvQ1A7V0MOW9nFrdoEuRiBjoTuvASPO21mZ8JJJEI5SF 46Ku5UFrVthOyV3+FXd0v+zpCx2MkFVvYxgNsrB9xCrttTrycXmfoQ0eZUkI3XsEC1n0 Z7ymmw9qUn0CvS9oq10uQu440l/EaA4t6jw/M4xO6FU+AsYP4K10uXf0B4BtHHRFcwV5 8hSW9Pmf1vHQg9Wk+UzipK+9AK6DyCeuIihRUo5HUsXQaK2Mj4SaAm6A4FnJZ5tlllf9 Fg1mzELK5+BWlkJmBdvv5hPO1LT+eTQ/Ek3ydZvkl3kNbDCtjdFn/A7+CqI0KRTTi86W 7eJg== X-Forwarded-Encrypted: i=1; AFNElJ9/w3rc4+ZbAKfeNMnM/FI9hWKs6//jcQuPr3uN0pUnSQRkrKrp5wmuv+6ZbLQhyRKUeoOY0qq3/Vk8/RU=@vger.kernel.org X-Gm-Message-State: AOJu0Yzc2ZS7GrVKns04yanwM0kAYqJlK0YeslaS9+GAYyNKjvGbVVxd HSC9h9k28EPKL4uIzlSyGhoOwuAP4DmIofTdxsQRqMvBoWG4O0LJIFNz X-Gm-Gg: Acq92OGsG8wUWMsWWYfbIYns2XNAj5a1OnpEL1S0pnTHzgLN2s+L04lEIIjkGTgnbzB q+xyKBJI/TkqXgRF5xKeVspbuzRjkmYDOPu9krDfJhvQRWzZ1/qIy2T8m7pK7/cno6mJ8FJ+B4d /1nRyMQzodu8gj8ngZI1t9rfGElJz03FlKsQ1O7k6I0S1uuodvi/8i1FeHTaFDN9QrSfkCpd+2G rSc4qSc1Gn9ujrg2xOwShnt9jbYzgQzF+nPXlWT7kn3i/F2O/xEKxYNOvEtHI2s83oik9yeEUVN AG1EoOX5NwEIGQRGTVa7HQRAxsx+eWSnzS22N8k+e3qSV7qQ1g405Mjt0kuIDRJSp7TOV47C6wy 9T+IXMKfTadXQo+X706xxqlTMCwInO8b4HpcBc5ZbX77GOMugmiHPwPQt5Y33b03VjuL1D+g7vg zYcmGZ+k2vx3kKRSttlzhDhC3IiuCJV6n8u/2DIYdCucy49iFuf9/ZsthQGTnzYhVN X-Received: by 2002:a05:6820:82b:b0:69b:196a:de67 with SMTP id 006d021491bc7-69e685faf92mr2261978eaf.0.1780674099658; Fri, 05 Jun 2026 08:41:39 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:5c::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-69e464743f8sm5649858eaf.15.2026.06.05.08.41.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 08:41:39 -0700 (PDT) From: Joshua Hahn To: Joshua Hahn Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH 0/6 v3] mm/memcontrol, page_counter: move stock from mem_cgroup to page_counter Date: Fri, 5 Jun 2026 08:41:36 -0700 Message-ID: <20260605154137.300900-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260605153603.234296-1-joshua.hahnjy@gmail.com> 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 On Fri, 5 Jun 2026 08:35:56 -0700 Joshua Hahn wrote: > Memcg currently keeps a "stock" of 64 pages per-cpu to cache pre-charged > allocations, allowing small allocations to avoid walking the expensive > mem_cgroup hierarchy traversal and atomic operations on each charge. > This design introduces a fastpath, but there is room for improvement: > > 1. Currently, each CPU tracks up to 7 (NR_MEMCG_STOCK) mem_cgroups. When > more than 7 mem_cgroups are actively charging on a single CPU, a > random victim is evicted and its associated stock is drained. > > 2. Stock management is tightly coupled to struct mem_cgroup, which makes > it difficult to add a new page_counter to mem_cgroup and have > multiple sources of stock management, which is required when trying > to introduce fastpaths to multiple hard limit checks. > > This series moves the per-cpu stock down into the page_counter which > consolidates stock limit checking and page_counter limit checking into > page_counter_try_charge. This eliminates the 7-memcg-per-cpu slot limit, > the random evictions (drain & refill), and slot traversal. Sorry, two things that I forgot to add as reviewers' notes: - There was a previous v3, but that was just a rebase, so I wasn't sure how to name that / this. I decided to name this one v3, since the last one didn't have any changes at all. I apologize in case there are any confusions. - I think it is quite late in the merge cycle, this is intended for the next cycle, not this one. Thank you!