mm: workingset: #define radix entry eviction mask
authorJohannes Weiner <hannes@cmpxchg.org>
Tue, 15 Mar 2016 21:57:07 +0000 (14:57 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 15 Mar 2016 23:55:16 +0000 (16:55 -0700)
This is a compile-time constant, no need to calculate it on refault.

Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Vladimir Davydov <vdavydov@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/workingset.c

index 61ead9e5549df171f43fa53936a4b8cbd86a21a5..3ef92f6e41fe034b56f05d8b6372b9ea099eeccd 100644 (file)
  * refault distance will immediately activate the refaulting page.
  */
 
+#define EVICTION_SHIFT (RADIX_TREE_EXCEPTIONAL_ENTRY + \
+                        ZONES_SHIFT + NODES_SHIFT)
+#define EVICTION_MASK  (~0UL >> EVICTION_SHIFT)
+
 static void *pack_shadow(unsigned long eviction, struct zone *zone)
 {
        eviction = (eviction << NODES_SHIFT) | zone_to_nid(zone);
@@ -168,7 +172,6 @@ static void unpack_shadow(void *shadow,
        unsigned long entry = (unsigned long)shadow;
        unsigned long eviction;
        unsigned long refault;
-       unsigned long mask;
        int zid, nid;
 
        entry >>= RADIX_TREE_EXCEPTIONAL_SHIFT;
@@ -181,8 +184,7 @@ static void unpack_shadow(void *shadow,
        *zone = NODE_DATA(nid)->node_zones + zid;
 
        refault = atomic_long_read(&(*zone)->inactive_age);
-       mask = ~0UL >> (NODES_SHIFT + ZONES_SHIFT +
-                       RADIX_TREE_EXCEPTIONAL_SHIFT);
+
        /*
         * The unsigned subtraction here gives an accurate distance
         * across inactive_age overflows in most cases.
@@ -199,7 +201,7 @@ static void unpack_shadow(void *shadow,
         * inappropriate activation leading to pressure on the active
         * list is not a problem.
         */
-       *distance = (refault - eviction) & mask;
+       *distance = (refault - eviction) & EVICTION_MASK;
 }
 
 /**