* [PATCH] __isolate_lru_page: change code style
@ 2010-04-06 2:40 Bob Liu
0 siblings, 0 replies; only message in thread
From: Bob Liu @ 2010-04-06 2:40 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, kosaki.motohiro, Bob Liu
As Andrew said:
"
it wouldn't be a good and maintainable change -
one point in using enumerations such as ISOLATE_* is to hide their real
values. Adding code which implicitly "knows" that a particular
enumerated identifier has a particular underlying value is rather
grubby and fragile.
It's also a bit fragile to assume that a true/false-returning C
function (PageActive) will always return 0 or 1. It's a common C idiom
for such functions to return 0 or non-zero (not necessarily 1).
So a clean and maintainable implementation of
if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode))
return ret;
would be
if (mode != ISOLATE_BOTH &&
((PageActive(page) && mode == ISOLATE_ACTIVE) ||
(!PageActive(page) && mode ==
ISOLATE_INACTIVE)))
return ret;
"
I changed my "skip unneeded 'not' patch" following his idea.
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
mm/vmscan.c | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/mm/vmscan.c b/mm/vmscan.c
index e0e5f15..9d1e52a 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -862,12 +862,9 @@ int __isolate_lru_page(struct page *page, int mode, int file)
if (!PageLRU(page))
return ret;
- /*
- * When checking the active state, we need to be sure we are
- * dealing with comparible boolean values. Take the logical not
- * of each.
- */
- if (mode != ISOLATE_BOTH && (!PageActive(page) != !mode))
+ if (mode != ISOLATE_BOTH &&
+ ((PageActive(page) && mode == ISOLATE_ACTIVE) ||
+ (!PageActive(page) && mode == ISOLATE_INACTIVE)))
return ret;
if (mode != ISOLATE_BOTH && page_is_file_cache(page) != file)
--
1.5.6.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2010-04-06 2:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-06 2:40 [PATCH] __isolate_lru_page: change code style Bob Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).