>         if (next_deferred >= scanned)
> @@ -468,18 +487,9 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
>         if (nr_scanned == 0)
>                 nr_scanned = SWAP_CLUSTER_MAX;
>
> -       if (!down_read_trylock(&shrinker_rwsem)) {
> -               /*
> -                * If we would return 0, our callers would understand that we
> -                * have nothing else to shrink and give up trying. By 
> returning
> -                * 1 we keep it going and assume we'll be able to shrink next
> -                * time.
> -                */
> -               freed = 1;
> -               goto out;
> -       }
> +       rcu_read_lock();

Sorry, the rcu_read_lock() will not work. I am currently testing with
srcu_read_lock() and see if it gives any error.

>
> -       list_for_each_entry(shrinker, &shrinker_list, list) {
> +       list_for_each_entry_rcu(shrinker, &shrinker_list, list) {
>                 struct shrink_control sc = {
>                         .gfp_mask = gfp_mask,
>                         .nid = nid,
> @@ -498,11 +508,13 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int 
> nid,
>                 if (!(shrinker->flags & SHRINKER_NUMA_AWARE))
>                         sc.nid = 0;
>
> +               get_shrinker(shrinker);
>                 freed += do_shrink_slab(&sc, shrinker, nr_scanned, 
> nr_eligible);
> +               put_shrinker(shrinker);
>         }
>
> -       up_read(&shrinker_rwsem);
> -out:
> +       rcu_read_unlock();
> +
>         cond_resched();
>         return freed;
>  }
> --
> 2.15.0.403.gc27cc4dac6-goog
>

Reply via email to