The patch titled Subject: mm: remove an avoidable load of page refcount in page_ref_add_unless has been added to the -mm mm-unstable branch. Its filename is mm-remove-an-avoidable-load-of-page-refcount-in-page_ref_add_unless.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-remove-an-avoidable-load-of-page-refcount-in-page_ref_add_unless.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Mateusz Guzik <mjguzik@xxxxxxxxx> Subject: mm: remove an avoidable load of page refcount in page_ref_add_unless Date: Sat, 7 Dec 2024 09:29:31 +0100 Explicitly pre-checking the count adds nothing as atomic_add_unless starts with doing the same thing. iow no functional changes. disasm of stock filemap_get_read_batch from perf top while running readseek2_processes -t 24: 0.04 â?? cb: mov 0x34(%rbx),%eax # first load 73.11 â?? test %eax,%eax â?? â?? je 1bd 0.09 â?? mov 0x34(%rbx),%eax # second load 1.01 â?? d9: test %eax,%eax â?? â?? je 1bd 0.06 â?? lea 0x1(%rax),%edx 0.00 â?? lea 0x34(%rbx),%r14 0.00 â?? lock cmpxchg %edx,0x34(%rbx) 14.06 â?? â?? jne d9 Link: https://lkml.kernel.org/r/20241207082931.1707465-1-mjguzik@xxxxxxxxx Signed-off-by: Mateusz Guzik <mjguzik@xxxxxxxxx> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx> Cc: Yu Zhao <yuzhao@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/page_ref.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/linux/page_ref.h~mm-remove-an-avoidable-load-of-page-refcount-in-page_ref_add_unless +++ a/include/linux/page_ref.h @@ -234,7 +234,7 @@ static inline bool page_ref_add_unless(s rcu_read_lock(); /* avoid writing to the vmemmap area being remapped */ - if (!page_is_fake_head(page) && page_ref_count(page) != u) + if (!page_is_fake_head(page)) ret = atomic_add_unless(&page->_refcount, nr, u); rcu_read_unlock(); _ Patches currently in -mm which might be from mjguzik@xxxxxxxxx are mm-remove-an-avoidable-load-of-page-refcount-in-page_ref_add_unless.patch get_task_exe_file-check-pf_kthread-locklessly.patch