Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Joshua Hahn <joshua.hahnjy@gmail.com>
To: Joshua Hahn <joshua.hahnjy@gmail.com>
Cc: hannes@cmpxchg.org, shakeel.butt@linux.dev, mhocko@kernel.org,
	roman.gushchin@linux.dev, muchun.song@linux.dev,
	akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org,
	liam@infradead.org, vbabka@kernel.org, rppt@kernel.org,
	surenb@google.com, dev@lankhorst.se, mripard@kernel.org,
	nat@pixelcluster.dev, tj@kernel.org, mkoutny@suse.com,
	osalvador@suse.de, cgroups@vger.kernel.org, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	kernel-team@meta.com
Subject: Re: [PATCH v5 0/7] move stock from mem_cgroup to page_counter
Date: Fri,  4 Sep 2026 09:53:49 -0700	[thread overview]
Message-ID: <20260904165349.4100321-1-joshua.hahnjy@gmail.com> (raw)
In-Reply-To: <20260831163752.2193337-1-joshua.hahnjy@gmail.com>

> v4 --> v5
> =========
> - The stock is now a raw_spinlock_t and an unsigned long to more closely
>   match the original semantics of the stock code.
> - Draining is asynchronous again, we add a work_struct per-page_counter
>   (not percpu) that walks every cpu. This eliminates the concerns
>   of doing a synchronous drain.
> - page_counter_try_charge transparently handles stock.
> - Addressed the netperf regression by reworking the refill path to match
>   the vanilla uncharge path more closely.
> - Correctness fixes for the percpu pointer access usage
> - More testing to demonstrate that this series achieves its goal.
> - Included Shakeel's stock watermarks from [1].
> - Wordsmithing
> 
> INTRO
> =====
> Memcg currently keeps a "stock" of 64 pages per-cpu to cache pre-charged
> allocations, allowing small and frequent allocations to avoid walking
> the expensive mem_cgroup hierarchy traversal each time. This fastpath
> offers real improvements, 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 have stock present on a single CPU, a random
>    victim is evicted and its associated stock is drained.
> 2. When one cgroup runs out of memory and needs to drain stock across
>    all CPUs it has stock cached in, those CPUs will drain all other
>    memcgs' stock present in that CPU. This leads to inefficient stock
>    caching and cross-memcg interference under memory pressure.
> 3. 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.
> 
> This series moves the per-cpu stock down into page_counter, so that
> page_counter_try_charge() transparently serves a charge from the stock
> and refills it, and each counter owns and drains its own cache. This
> eliminates the 7 memcg-per-cpu slot limit, the random cross-memcg stock
> drains, and the slot traversal.
> 
> In turn, we can add independent stock management for additional
> page_counters in each memcg, which is used in my tiered memory limits
> series to add a new page_counter to track toptier usage [2]. Patch 7
> uses it to give memsw its own stock.
> 
> Because the stock is now a property of the counter rather than of the
> cpu, it is also reachable remotely, so draining no longer has to run on
> the cpu that owns the cache.
> 
> This series preserves as much of the old semantics as possible,
> including non-spinning safety by using trylocks for stock access.
> The old !allow_spinning semantics in try_charge_memcg are slightly
> different now though; outside NMI, page_counter_try_charge may perform
> a speculative batch charge and a refill.

Hello reviewers,

I just wanted to note that Sashiko seems to have raised no concerns [1]
with this series : -)

Thank you for your feedback and input!!
Joshua

[1] https://sashiko.dev/#/patchset/20260831163752.2193337-1-joshua.hahnjy%40gmail.com


      parent reply	other threads:[~2026-09-04 16:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 16:37 [PATCH v5 0/7] move stock from mem_cgroup to page_counter Joshua Hahn
2026-08-31 16:37 ` [PATCH v5 1/7] mm/memcontrol: flatten try_charge_memcg control flow Joshua Hahn
2026-09-04 23:06   ` Shakeel Butt
2026-08-31 16:37 ` [PATCH v5 2/7] mm/page_counter: report the number of pages charged Joshua Hahn
2026-09-05  1:47   ` Shakeel Butt
2026-08-31 16:37 ` [PATCH v5 3/7] mm/page_counter: introduce per-page_counter stock Joshua Hahn
2026-09-04 22:47   ` Shakeel Butt
2026-08-31 16:37 ` [PATCH v5 4/7] mm/page_counter: use stock in page_counter_try_charge Joshua Hahn
2026-08-31 16:37 ` [PATCH v5 5/7] mm/page_counter: introduce an asynchronous drainer Joshua Hahn
2026-08-31 16:37 ` [PATCH v5 6/7] mm/memcontrol: convert memcg to use page_counter_stock Joshua Hahn
2026-08-31 16:37 ` [PATCH v5 7/7] mm/memcontrol: add stock to the memsw page_counter Joshua Hahn
2026-09-01  9:40   ` Michal Koutný
2026-09-01 14:11     ` Joshua Hahn
2026-09-04 16:53 ` Joshua Hahn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260904165349.4100321-1-joshua.hahnjy@gmail.com \
    --to=joshua.hahnjy@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cgroups@vger.kernel.org \
    --cc=david@kernel.org \
    --cc=dev@lankhorst.se \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hannes@cmpxchg.org \
    --cc=kernel-team@meta.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=mripard@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=nat@pixelcluster.dev \
    --cc=osalvador@suse.de \
    --cc=roman.gushchin@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=tj@kernel.org \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox