On Thu, Apr 04, 2019 at 11:30:17AM +0800, Zhaoyang Huang wrote:
> +++ b/mm/workingset.c
> @@ -159,7 +159,7 @@
>                        NODES_SHIFT +  \
>                        MEM_CGROUP_ID_SHIFT)
>  #define EVICTION_MASK        (~0UL >> EVICTION_SHIFT)
> -
> +#define EVICTION_JIFFIES (BITS_PER_LONG >> 3)
>  /*
>   * Eviction timestamps need to be able to cover the full range of
>   * actionable refaults. However, bits are tight in the radix tree
> @@ -175,18 +175,22 @@ static void *pack_shadow(int memcgid, pg_data_t *pgdat, 
> unsigned long eviction)
>       eviction >>= bucket_order;
>       eviction = (eviction << MEM_CGROUP_ID_SHIFT) | memcgid;
>       eviction = (eviction << NODES_SHIFT) | pgdat->node_id;
> +     eviction = (eviction << EVICTION_JIFFIES) | (jiffies >> 
> EVICTION_JIFFIES);
>       eviction = (eviction << RADIX_TREE_EXCEPTIONAL_SHIFT);

... this isn't against current, or even 5.0.

>       entry >>= RADIX_TREE_EXCEPTIONAL_SHIFT;
> +     entry >>= EVICTION_JIFFIES;
> +     prev_jiff = (entry & ((1UL << EVICTION_JIFFIES) - 1)) << 
> EVICTION_JIFFIES;

These two lines are in the wrong order.  So you're getting (effectively) a
random answer in your 'prev_jiff', which means your testing isn't thorough
enough.  I suspect you're only testing cases you're expecting to improve,
and you aren't testing to make sure that other cases don't regress.

Reply via email to