Skip to contentSkip to conversation

mm-vmscan-remove-unnecessary-lruvec-adding.patch removed from -mm tree

merged [email protected] 1 participant 1 message Dec 16, 2020

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: mm/vmscan: remove unnecessary lruvec adding
has been removed from the -mm tree. Its filename was
mm-vmscan-remove-unnecessary-lruvec-adding.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Alex Shi <[email protected]>
Subject: mm/vmscan: remove unnecessary lruvec adding

We don't have to add a freeable page into lru and then remove from it. This change saves a couple of actions and makes the moving more clear.

The SetPageLRU needs to be kept before put_page_testzero for list integrity, otherwise:

#0 move_pages_to_lru #1 release_pages
if !put_page_testzero

     			           if (put_page_testzero())
     			              !PageLRU //skip lru_lock
     SetPageLRU()
     list_add(&page->lru,)
                                         list_add(&page->lru,)
[[email protected]: coding style fixes]
Cc Tejun Heo <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Alexander Duyck <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Andrey Ryabinin <[email protected]>
Cc "Chen, Rong A" <[email protected]>
Cc Daniel Jordan <[email protected]>
Cc "Huang, Ying" <[email protected]>
Cc Jann Horn <[email protected]>
Cc Joonsoo Kim <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Konstantin Khlebnikov <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Mika Penttilä <[email protected]>
Cc Minchan Kim <[email protected]>
Cc Shakeel Butt <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vladimir Davydov <[email protected]>
Cc Wei Yang <[email protected]>
Cc Yang Shi <[email protected]>

---

 mm/vmscan.c |   38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)
mm/vmscan.c renamed from mm/vmscan.c~mm-vmscan-remove-unnecessary-lruvec-adding +25 -13
@@ -1851,26 +1851,30 @@ static unsigned noinline_for_stack move_
 	while (!list_empty(list)) {
 		page = lru_to_page(list);
 		VM_BUG_ON_PAGE(PageLRU(page), page);
+		list_del(&page->lru);
 		if (unlikely(!page_evictable(page))) {
-			list_del(&page->lru);
 			spin_unlock_irq(&pgdat->lru_lock);
 			putback_lru_page(page);
 			spin_lock_irq(&pgdat->lru_lock);
 			continue;
 		}
-		lruvec = mem_cgroup_page_lruvec(page, pgdat);
 
+		/*
+		 * The SetPageLRU needs to be kept here for list integrity.
+		 * Otherwise:
+		 *   #0 move_pages_to_lru             #1 release_pages
+		 *   if !put_page_testzero
+		 *				      if (put_page_testzero())
+		 *				        !PageLRU //skip lru_lock
+		 *     SetPageLRU()
+		 *     list_add(&page->lru,)
+		 *                                        list_add(&page->lru,)
+		 */
 		SetPageLRU(page);
-		lru = page_lru(page);
 
-		nr_pages = thp_nr_pages(page);
-		update_lru_size(lruvec, lru, page_zonenum(page), nr_pages);
-		list_move(&page->lru, &lruvec->lists[lru]);
-
-		if (put_page_testzero(page)) {
+		if (unlikely(put_page_testzero(page))) {
 			__ClearPageLRU(page);
 			__ClearPageActive(page);
-			del_page_from_lru_list(page, lruvec, lru);
 
 			if (unlikely(PageCompound(page))) {
 				spin_unlock_irq(&pgdat->lru_lock);
@@ -1878,11 +1882,19 @@ static unsigned noinline_for_stack move_
 				spin_lock_irq(&pgdat->lru_lock);
 			} else
 				list_add(&page->lru, &pages_to_free);
-		} else {
-			nr_moved += nr_pages;
-			if (PageActive(page))
-				workingset_age_nonresident(lruvec, nr_pages);
+
+			continue;
 		}
+
+		lruvec = mem_cgroup_page_lruvec(page, pgdat);
+		lru = page_lru(page);
+		nr_pages = thp_nr_pages(page);
+
+		update_lru_size(lruvec, lru, page_zonenum(page), nr_pages);
+		list_add(&page->lru, &lruvec->lists[lru]);
+		nr_moved += nr_pages;
+		if (PageActive(page))
+			workingset_age_nonresident(lruvec, nr_pages);
 	}
 
 	/*

_

Patches currently in -mm which might be from [email protected] are

mm-vmscan-__isolate_lru_page_prepare-clean-up.patch fs-nilfs2-remove-some-unused-macros-to-tame-gcc.patch gcov-fix-kernel-doc-markup-issue.patch mm-memcg-bail-early-from-swap-accounting-if-memcg-disabled.patch mm-memcg-warning-on-memcg-after-readahead-page-charged.patch mm-memcontrol-rewrite-mem_cgroup_page_lruvec-fix.patch