mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karim Manaouil <kmanaouil.dev@gmail.com>
To: Bo Zhang <zhangbo0325@gmail.com>
Cc: akpm@linux-foundation.org, vbabka@kernel.org, david@kernel.org,
	surenb@google.com, mhocko@suse.com, brendan.jackman@linux.dev,
	hannes@cmpxchg.org, ziy@nvidia.com, ljs@kernel.org,
	liam@infradead.org, rppt@kernel.org, qi.zheng@linux.dev,
	shakeel.butt@linux.dev, kasong@tencent.com, baohua@kernel.org,
	axelrasmussen@google.com, yuanchu@google.com, weixugc@google.com,
	zhaonanzhe@xiaomi.com, lipengfei28@xiaomi.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 4/4] mm: adjust free_pages to make __zone_watermark_ok() mTHP-aware
Date: Fri, 18 Sep 2026 12:58:03 +0100	[thread overview]
Message-ID: <20260918115803.55bfl7whbvc5q25u@wrangler> (raw)
In-Reply-To: <20260918024238.31128-1-zhangbo56@xiaomi.com>

On Fri, Sep 18, 2026 at 10:42:38AM +0800, Bo Zhang wrote:
> On Thu, Sep 17, 2026 at 06:16:42PM +0100, Karim Manaouil wrote:
> > > +	if (READ_ONCE(huge_anon_orders_always) && order == compact_hpage_order()) {
> > > +		unsigned long free_pages = 0;
> > > +
> > > +		for (int o = order; o < NR_PAGE_ORDERS; o++)
> > > +			free_pages += zone->free_area[o].nr_free << o;
> >
> > I understand that you don't need a precise value here, but in every
> > instance in the kernel source tree where nr_free is accessed, it's
> > accessed under the zone lock. Do we need to use READ_ONCE()?
> 
> Good point, thanks. The nr_free read here is an intentional lockless
> estimate. I'll annotate it with data_race(), matching how
> fill_contig_page_info() in mm/vmstat.c reads the same
> zone->free_area[].nr_free field without the zone lock:
> 
> 	free_pages += data_race(zone->free_area[o].nr_free) << o;
> 
> data_race() documents the intended racy read and keeps KCSAN quiet.
> Happy to use READ_ONCE() instead if you'd prefer.

Yeah, data_race() is probably a good starting point. Thanks!

> Bo

-- 
~karim

  reply	other threads:[~2026-09-18 11:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  4:38 [RFC PATCH 0/4] mm: compaction: mTHP-friendly memory compaction Bo Zhang
2026-08-25  4:38 ` [RFC PATCH 1/4] mm: compaction: make proactive compaction mTHP-aware Bo Zhang
2026-09-03 14:11   ` Bo Zhang
2026-08-25  4:38 ` [RFC PATCH 2/4] mm: compaction: skip isolating large folios that satisfy the mTHP order Bo Zhang
2026-09-03 14:29   ` Bo Zhang
2026-08-25  4:38 ` [RFC PATCH 3/4] mm: compaction: don't skip proactive compaction for non-costly mTHP Bo Zhang
2026-09-03 14:32   ` Bo Zhang
2026-08-25  4:38 ` [RFC PATCH 4/4] mm: adjust free_pages to make __zone_watermark_ok() mTHP-aware Bo Zhang
2026-09-03  2:46   ` Xueyuan Chen
2026-09-03 13:56     ` Bo Zhang
2026-09-03 15:09   ` Bo Zhang
2026-09-17 17:16   ` Karim Manaouil
2026-09-18  2:42     ` Bo Zhang
2026-09-18 11:58       ` Karim Manaouil [this message]
2026-09-07  2:51 ` [RFC PATCH 0/4] mm: compaction: mTHP-friendly memory compaction Zi Yan
2026-09-07  8:45   ` Bo Zhang
2026-09-18 15:06 ` Lorenzo Stoakes (ARM)
2026-09-22  4:15   ` Bo Zhang
2026-09-22 21:07     ` Barry Song

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=20260918115803.55bfl7whbvc5q25u@wrangler \
    --to=kmanaouil.dev@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=brendan.jackman@linux.dev \
    --cc=david@kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=kasong@tencent.com \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lipengfei28@xiaomi.com \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=qi.zheng@linux.dev \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=yuanchu@google.com \
    --cc=zhangbo0325@gmail.com \
    --cc=zhaonanzhe@xiaomi.com \
    --cc=ziy@nvidia.com \
    /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

all inboxes | Powered by JetHome®