lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <ef7059c8442b7e1ee5f406523b79d24d19b050b6.1676342827.git.baolin.wang@linux.alibaba.com>
Date:   Tue, 14 Feb 2023 11:18:06 +0800
From:   Baolin Wang <baolin.wang@...ux.alibaba.com>
To:     akpm@...ux-foundation.org
Cc:     torvalds@...ux-foundation.org, sj@...nel.org, hannes@...xchg.org,
        mhocko@...nel.org, roman.gushchin@...ux.dev, shakeelb@...gle.com,
        muchun.song@...ux.dev, baolin.wang@...ux.alibaba.com,
        damon@...ts.linux.dev, cgroups@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] mm: check negative error of folio_isolate_lru() when failed to isolate a folio

The folio_isolate_lru() will return a negative error if failed to isolate
a folio from its LRU list, thus better to check the negative error to
make the code more clear per Linus's suggestion[1].

No functional changes.

[1] https://lore.kernel.org/all/CAHk-=wiBrY+O-4=2mrbVyxR+hOqfdJ=Do6xoucfJ9_5az01L4Q@mail.gmail.com/

Signed-off-by: Baolin Wang <baolin.wang@...ux.alibaba.com>
---
 mm/damon/paddr.c | 2 +-
 mm/gup.c         | 2 +-
 mm/khugepaged.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index b4df9b9bcc0a..ebf3dd084af2 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -246,7 +246,7 @@ static unsigned long damon_pa_pageout(struct damon_region *r, struct damos *s)
 
 		folio_clear_referenced(folio);
 		folio_test_clear_young(folio);
-		if (folio_isolate_lru(folio)) {
+		if (folio_isolate_lru(folio) < 0) {
 			folio_put(folio);
 			continue;
 		}
diff --git a/mm/gup.c b/mm/gup.c
index b0885f70579c..7fdddd43663c 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1939,7 +1939,7 @@ static unsigned long collect_longterm_unpinnable_pages(
 			drain_allow = false;
 		}
 
-		if (folio_isolate_lru(folio))
+		if (folio_isolate_lru(folio) < 0)
 			continue;
 
 		list_add_tail(&folio->lru, movable_page_list);
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index a5d32231bfad..463dfca4b841 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -2047,7 +2047,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
 			goto out_unlock;
 		}
 
-		if (folio_isolate_lru(folio)) {
+		if (folio_isolate_lru(folio) < 0) {
 			result = SCAN_DEL_PAGE_LRU;
 			goto out_unlock;
 		}
-- 
2.27.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ