* + mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch added to -mm tree
@ 2021-09-24 2:30 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2021-09-24 2:30 UTC (permalink / raw)
To: edumazet, hughd, mm-commits
The patch titled
Subject: mm/page_alloc.c: do not acquire zone lock in is_free_buddy_page()
has been added to the -mm tree. Its filename is
mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch
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 and is updated
there every 3-4 working days
------------------------------------------------------
From: Eric Dumazet <edumazet@google.com>
Subject: mm/page_alloc.c: do not acquire zone lock in is_free_buddy_page()
Grabbing zone lock in is_free_buddy_page() gives a wrong sense of safety,
and has potential performance implications when zone is experiencing lock
contention.
In any case, if a caller needs a stable result, it should grab zone lock
before calling this function.
Link: https://lkml.kernel.org/r/20210922152833.4023972-1-eric.dumazet@gmail.com
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/page_alloc.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--- a/mm/page_alloc.c~mm-do-not-acquire-zone-lock-in-is_free_buddy_page
+++ a/mm/page_alloc.c
@@ -9350,21 +9350,21 @@ void __offline_isolated_pages(unsigned l
}
#endif
+/*
+ * This function returns a stable result only if called under zone lock.
+ */
bool is_free_buddy_page(struct page *page)
{
- struct zone *zone = page_zone(page);
unsigned long pfn = page_to_pfn(page);
- unsigned long flags;
unsigned int order;
- spin_lock_irqsave(&zone->lock, flags);
for (order = 0; order < MAX_ORDER; order++) {
struct page *page_head = page - (pfn & ((1 << order) - 1));
- if (PageBuddy(page_head) && buddy_order(page_head) >= order)
+ if (PageBuddy(page_head) &&
+ buddy_order_unsafe(page_head) >= order)
break;
}
- spin_unlock_irqrestore(&zone->lock, flags);
return order < MAX_ORDER;
}
_
Patches currently in -mm which might be from edumazet@google.com are
mm-large-system-hash-avoid-possible-null-deref-in-alloc_large_system_hash.patch
mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-09-24 2:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 2:30 + mm-do-not-acquire-zone-lock-in-is_free_buddy_page.patch added to -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.