Thread (18 messages) 18 messages, 3 authors, 2021-11-29

Re: [PATCH] mm: reduce spinlock contention in release_pages()

From: Hao Lee <hidden>
Date: 2021-11-25 03:24:31
Also in: linux-mm, lkml

On Wed, Nov 24, 2021 at 11:58 PM Matthew Wilcox [off-list ref] wrote:
On Wed, Nov 24, 2021 at 03:19:15PM +0000, Hao Lee wrote:
quoted
When several tasks are terminated simultaneously, lots of pages will be
released, which can cause severe spinlock contention. Other tasks which
are running on the same core will be seriously affected. We can yield
cpu to fix this problem.
The realtime people will eat you alive for this suggestion.
Thanks for pointing out this.
quoted
+++ b/mm/swap.c
@@ -960,8 +960,14 @@ void release_pages(struct page **pages, int nr)
              if (PageLRU(page)) {
                      struct lruvec *prev_lruvec = lruvec;

-                     lruvec = folio_lruvec_relock_irqsave(folio, lruvec,
+retry:
+                     lruvec = folio_lruvec_tryrelock_irqsave(folio, lruvec,
                                                                      &flags);
+                     if (!lruvec) {
+                             cond_resched();
+                             goto retry;
+                     }
+
                      if (prev_lruvec != lruvec)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help