Message ID | 20230724094354.90817-22-zhengqi.arch@bytedance.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | Mike Snitzer |
Headers | show |
Series | use refcount+RCU method to implement lockless slab shrink | expand |
> On Jul 24, 2023, at 17:43, Qi Zheng <zhengqi.arch@bytedance.com> wrote: > > Use new APIs to dynamically allocate the mm-shadow shrinker. > > Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> > --- > mm/workingset.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/mm/workingset.c b/mm/workingset.c > index 4686ae363000..4bc85f739b13 100644 > --- a/mm/workingset.c > +++ b/mm/workingset.c > @@ -762,12 +762,7 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker, > NULL); > } > > -static struct shrinker workingset_shadow_shrinker = { > - .count_objects = count_shadow_nodes, > - .scan_objects = scan_shadow_nodes, > - .seeks = 0, /* ->count reports only fully expendable nodes */ > - .flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, > -}; > +static struct shrinker *workingset_shadow_shrinker; Same as patch #17. -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
On 2023/7/26 15:13, Muchun Song wrote: > > >> On Jul 24, 2023, at 17:43, Qi Zheng <zhengqi.arch@bytedance.com> wrote: >> >> Use new APIs to dynamically allocate the mm-shadow shrinker. >> >> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> >> --- >> mm/workingset.c | 26 ++++++++++++++------------ >> 1 file changed, 14 insertions(+), 12 deletions(-) >> >> diff --git a/mm/workingset.c b/mm/workingset.c >> index 4686ae363000..4bc85f739b13 100644 >> --- a/mm/workingset.c >> +++ b/mm/workingset.c >> @@ -762,12 +762,7 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker, >> NULL); >> } >> >> -static struct shrinker workingset_shadow_shrinker = { >> - .count_objects = count_shadow_nodes, >> - .scan_objects = scan_shadow_nodes, >> - .seeks = 0, /* ->count reports only fully expendable nodes */ >> - .flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, >> -}; >> +static struct shrinker *workingset_shadow_shrinker; > > > Same as patch #17. OK, will do. -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel
diff --git a/mm/workingset.c b/mm/workingset.c index 4686ae363000..4bc85f739b13 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -762,12 +762,7 @@ static unsigned long scan_shadow_nodes(struct shrinker *shrinker, NULL); } -static struct shrinker workingset_shadow_shrinker = { - .count_objects = count_shadow_nodes, - .scan_objects = scan_shadow_nodes, - .seeks = 0, /* ->count reports only fully expendable nodes */ - .flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE, -}; +static struct shrinker *workingset_shadow_shrinker; /* * Our list_lru->lock is IRQ-safe as it nests inside the IRQ-safe @@ -779,7 +774,7 @@ static int __init workingset_init(void) { unsigned int timestamp_bits; unsigned int max_order; - int ret; + int ret = -ENOMEM; BUILD_BUG_ON(BITS_PER_LONG < EVICTION_SHIFT); /* @@ -796,17 +791,24 @@ static int __init workingset_init(void) pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", timestamp_bits, max_order, bucket_order); - ret = prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow"); - if (ret) + workingset_shadow_shrinker = shrinker_alloc(SHRINKER_NUMA_AWARE | + SHRINKER_MEMCG_AWARE, + "mm-shadow"); + if (!workingset_shadow_shrinker) goto err; + ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key, - &workingset_shadow_shrinker); + workingset_shadow_shrinker); if (ret) goto err_list_lru; - register_shrinker_prepared(&workingset_shadow_shrinker); + + workingset_shadow_shrinker->count_objects = count_shadow_nodes; + workingset_shadow_shrinker->scan_objects = scan_shadow_nodes; + + shrinker_register(workingset_shadow_shrinker); return 0; err_list_lru: - free_prealloced_shrinker(&workingset_shadow_shrinker); + shrinker_free_non_registered(workingset_shadow_shrinker); err: return ret; }
Use new APIs to dynamically allocate the mm-shadow shrinker. Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> --- mm/workingset.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)