lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ab41791a-2ffc-429b-ae5e-1853106224fa@suse.cz>
Date: Tue, 20 Jan 2026 11:16:14 +0100
From: Vlastimil Babka <vbabka@...e.cz>
To: Yajun Deng <yajun.deng@...ux.dev>, Johannes Weiner <hannes@...xchg.org>
Cc: akpm@...ux-foundation.org, surenb@...gle.com, mhocko@...e.com,
 jackmanb@...gle.com, ziy@...dia.com, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org, Joshua Hahn <joshua.hahnjy@...il.com>
Subject: Re: [PATCH v2] mm/page_alloc: Avoid duplicate NR_FREE_PAGES updates
 in move_to_free_list()

On 1/13/26 08:13, Yajun Deng wrote:
> January 12, 2026 at 10:50 PM, "Johannes Weiner" <hannes@...xchg.org mailto:hannes@...xchg.org?to=%22Johannes%20Weiner%22%20%3Channes%40cmpxchg.org%3E > wrote:
> 
> 
>> 
>> On Mon, Jan 12, 2026 at 08:16:14PM +0800, Yajun Deng wrote:
>> 
>> > 
>> > In move_to_free_list(), when a page block changes its migration type,
>> >  we need to update free page counts for both the old and new types.
>> >  Originally, this was done by two calls to account_freepages(), which
>> >  updates NR_FREE_PAGES and also type-specific counters. However, this
>> >  causes NR_FREE_PAGES to be updated twice, while the net change is zero
>> >  in most cases.
>> >  
>> >  This patch adds a condition that updates the NR_FREE_PAGES only if one of
>> >  the two types is the isolate type. This avoids NR_FREE_PAGES being
>> >  updates twice.
>> >  
>> >  The optimization avoid duplicate NR_FREE_PAGES updates in
>> >  move_to_free_list().
>> >  
>> >  Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
>> >  Suggested-by: Joshua Hahn <joshua.hahnjy@...il.com>
>> > 
>> I'm not a fan of this.
>> 
>> The code ends up more complicated, more lines, and fragile because the
>> accounting decisions are now spread out over multiple places (again).

Agreed.

>> 
> How about V1? It will introduce account_freepages_both().
> https://lore.kernel.org/all/20260109105121.328780-1-yajun.deng@linux.dev/

Also not a fan myself.

Thanks,
Vlastimil

>> Is it worth it? move_to_free_list() is used in page isolation, which
>> has to do the accounting anyway; and migratetype fallbacks, which we
>> are trying to avoid as much as possible. So this path shouldn't be all
>> that hot to begin with.
>> 
> Not all cases are of the isolation type. There are indeed duplicate caculations.
> move_freepages_block() will be called in __isolate_free_page().
> Both old_mt and new_mt are mergeable type in this case.
> 
>> Simplicity & maintainability trumps here, IMO, unless you have hard
>> data showing this is worth the pain.
>>
> I'm tring to do it, but I haven't yet.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ