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-next>] [day] [month] [year] [list]
Message-ID: <20201027170420.GA61326@rlk>
Date:   Wed, 28 Oct 2020 01:04:20 +0800
From:   Hui Su <sh_def@....com>
To:     akpm@...ux-foundation.org, gustavo@...eddedor.com, sh_def@....com,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: [PATCH] mm/list_lru: optimize condition of exiting the loop

In list_lru_walk(), nr_to_walk type is 'unsigned long',
so nr_to_walk won't be '< 0'.

In list_lru_walk_node(), nr_to_walk type is 'unsigned long',
so *nr_to_walk won't be '< 0' too.

We can use '!nr_to_walk' instead of 'nr_to_walk <= 0', which
is more precise.

Signed-off-by: Hui Su <sh_def@....com>
---
 include/linux/list_lru.h | 2 +-
 mm/list_lru.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/list_lru.h b/include/linux/list_lru.h
index 9dcaa3e582c9..b7bc4a2636b9 100644
--- a/include/linux/list_lru.h
+++ b/include/linux/list_lru.h
@@ -214,7 +214,7 @@ list_lru_walk(struct list_lru *lru, list_lru_walk_cb isolate,
 	for_each_node_state(nid, N_NORMAL_MEMORY) {
 		isolated += list_lru_walk_node(lru, nid, isolate,
 					       cb_arg, &nr_to_walk);
-		if (nr_to_walk <= 0)
+		if (!nr_to_walk)
 			break;
 	}
 	return isolated;
diff --git a/mm/list_lru.c b/mm/list_lru.c
index 5aa6e44bc2ae..39b8d467159d 100644
--- a/mm/list_lru.c
+++ b/mm/list_lru.c
@@ -304,7 +304,7 @@ unsigned long list_lru_walk_node(struct list_lru *lru, int nid,
 							nr_to_walk);
 			spin_unlock(&nlru->lock);
 
-			if (*nr_to_walk <= 0)
+			if (!*nr_to_walk)
 				break;
 		}
 	}
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ