Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1314143

[PATCH 3/3] thp: limit number of object to scan on deferred_split_scan()

From "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Newsgroups linux.kernel
Subject [PATCH 3/3] thp: limit number of object to scan on deferred_split_scan()
Date 2016-01-21 13:10 +0100
Message-ID <qTmdR-545-29@gated-at.bofh.it> (permalink)
References <qTceu-6lk-5@gated-at.bofh.it> <qTmdQ-545-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If we have a lot of pages in queue to be split, deferred_split_scan()
can spend unreasonable amount of time under spinlock with disabled
interrupts.

Let's cap number of pages to split on scan by sc->nr_to_scan.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Andrea Arcangeli <aarcange@redhat.com>
---
 mm/huge_memory.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 36f98459f854..298dbc001b07 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -3478,17 +3478,19 @@ static unsigned long deferred_split_scan(struct shrinker *shrink,
 	int split = 0;
 
 	spin_lock_irqsave(&pgdata->split_queue_lock, flags);
-	list_splice_init(&pgdata->split_queue, &list);
-
 	/* Take pin on all head pages to avoid freeing them under us */
 	list_for_each_safe(pos, next, &list) {
 		page = list_entry((void *)pos, struct page, mapping);
 		page = compound_head(page);
-		/* race with put_compound_page() */
-		if (!get_page_unless_zero(page)) {
+		if (get_page_unless_zero(page)) {
+			list_move(page_deferred_list(page), &list);
+		} else {
+			/* We lost race with put_compound_page() */
 			list_del_init(page_deferred_list(page));
 			pgdata->split_queue_len--;
 		}
+		if (!--sc->nr_to_scan)
+			break;
 	}
 	spin_unlock_irqrestore(&pgdata->split_queue_lock, flags);
 
-- 
2.7.0.rc3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCHv12 34/37] thp: introduce deferred_split_huge_page() Andrea Arcangeli <aarcange@redhat.com> - 2016-01-21 02:30 +0100
  [PATCH 1/3] thp: make split_queue per-node "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-01-21 13:10 +0100
  [PATCH 2/3] thp: change deferred_split_count() to return number of THP in queue "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-01-21 13:10 +0100
    Re: [PATCH 2/3] thp: change deferred_split_count() to return number  of THP in queue Andrea Arcangeli <aarcange@redhat.com> - 2016-01-22 15:40 +0100
      Re: [PATCH 2/3] thp: change deferred_split_count() to return number  of THP in queue "Kirill A. Shutemov" <kirill@shutemov.name> - 2016-01-22 16:30 +0100
  [PATCH 3/3] thp: limit number of object to scan on deferred_split_scan() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-01-21 13:10 +0100
  [PATCH 0/3] Couple of fixes for deferred_split_huge_page() "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2016-01-21 13:20 +0100
    Re: [PATCH 0/3] Couple of fixes for deferred_split_huge_page() Andrea Arcangeli <aarcange@redhat.com> - 2016-01-22 00:00 +0100

csiph-web