Skip to contentSkip to conversation

mm:remove useless code

PATCH In review hui yang 3 participants 3 messages Dec 23, 2020

Subsystems (3)
lore
Share & tools
lore

hui yang

author
#0 lore raw

PATCH 1/1 mm:remove useless code

From: YangHui <[email protected]>

remove useless code

---
 mm/vmscan.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/vmscan.c +2 -3
index 257cba7..af1d176 100644
@@ -1234,8 +1234,8 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 		 * Try to allocate it some swap space here.
 		 * Lazyfree page could be freed directly
 		 */
-		if (PageAnon(page) && PageSwapBacked(page)) {
-			if (!PageSwapCache(page)) {
+		if (PageAnon(page) && PageSwapBacked(page) &&
+			!PageSwapCache(page)) {
 				if (!(sc->gfp_mask & __GFP_IO))
 					goto keep_locked;
 				if (PageTransHuge(page)) {
@@ -1270,7 +1270,6 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 
 				/* Adding to swap updated mapping */
 				mapping = page_mapping(page);
-			}
 		} else if (unlikely(PageTransHuge(page))) {
 			/* Split file THP */
 			if (split_huge_page_to_list(page, page_list))
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · hui yang

From: YangHui <[email protected]>

remove useless code

---
 mm/vmscan.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/vmscan.c +0 -0
index 257cba7..af1d176 100644

mm/vmscan.c static unsigned int shrink_page_list(struct list_head *page_list, · line 1238

Quoted 7 lines
mm/vmscan.c +2 -2
@@ -1234,8 +1234,8 @@ static unsigned int shrink_page_list(struct list_head *page_list,
                 * Try to allocate it some swap space here.
                 * Lazyfree page could be freed directly
                 */
-               if (PageAnon(page) && PageSwapBacked(page)) {
-                       if (!PageSwapCache(page)) {
+               if (PageAnon(page) && PageSwapBacked(page) &&
+                       !PageSwapCache(page)) {

I think this is incorrect.

Consider this scenario:

PageAnon(page) && PageSwapBacked(page) is true
!PageSwapCache(page) is false

In original logic, this snippet will run into the first if branch which does nothing actually. However, in your logic, this snippet will run into else if branch.

Regards,
Hao Lee

Quoted 15 lines
mm/vmscan.c +0 -2
                                if (!(sc->gfp_mask & __GFP_IO))
                                        goto keep_locked;
                                if (PageTransHuge(page)) {
@@ -1270,7 +1270,6 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 
                                /* Adding to swap updated mapping */
                                mapping = page_mapping(page);
-                       }
                } else if (unlikely(PageTransHuge(page))) {
                        /* Split file THP */
                        if (split_huge_page_to_list(page, page_list))
--

2.7.4

#2 lore raw
In reply to hui yang
Quoted 4 lines · hui yang

From: YangHui <[email protected]>

remove useless code

Change logs need to be more descriptive.

Quoted 11 lines
---
 mm/vmscan.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
mm/vmscan.c +0 -0
index 257cba7..af1d176 100644

mm/vmscan.c static unsigned int shrink_page_list(struct list_head *page_list, · line 1238

Quoted 7 lines
mm/vmscan.c +2 -2
@@ -1234,8 +1234,8 @@ static unsigned int shrink_page_list(struct list_head *page_list,
                 * Try to allocate it some swap space here.
                 * Lazyfree page could be freed directly
                 */
-               if (PageAnon(page) && PageSwapBacked(page)) {
-                       if (!PageSwapCache(page)) {
+               if (PageAnon(page) && PageSwapBacked(page) &&
+                       !PageSwapCache(page)) {

This will change the original behaviour of the code.

Quoted 15 lines
mm/vmscan.c +0 -2
                                if (!(sc->gfp_mask & __GFP_IO))
                                        goto keep_locked;
                                if (PageTransHuge(page)) {
@@ -1270,7 +1270,6 @@ static unsigned int shrink_page_list(struct list_head *page_list,
 
                                /* Adding to swap updated mapping */
                                mapping = page_mapping(page);
-                       }
                } else if (unlikely(PageTransHuge(page))) {
                        /* Split file THP */
                        if (split_huge_page_to_list(page, page_list))
--

2.7.4