]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mm: shrinkers: provide shrinkers with names
authorRoman Gushchin <roman.gushchin@linux.dev>
Wed, 1 Jun 2022 03:22:24 +0000 (20:22 -0700)
committerakpm <akpm@linux-foundation.org>
Mon, 4 Jul 2022 01:08:40 +0000 (18:08 -0700)
Currently shrinkers are anonymous objects.  For debugging purposes they
can be identified by count/scan function names, but it's not always
useful: e.g.  for superblock's shrinkers it's nice to have at least an
idea of to which superblock the shrinker belongs.

This commit adds names to shrinkers.  register_shrinker() and
prealloc_shrinker() functions are extended to take a format and arguments
to master a name.

In some cases it's not possible to determine a good name at the time when
a shrinker is allocated.  For such cases shrinker_debugfs_rename() is
provided.

The expected format is:
    <subsystem>-<shrinker_type>[:<instance>]-<id>
For some shrinkers an instance can be encoded as (MAJOR:MINOR) pair.

After this change the shrinker debugfs directory looks like:
  $ cd /sys/kernel/debug/shrinker/
  $ ls
    dquota-cache-16     sb-devpts-28     sb-proc-47       sb-tmpfs-42
    mm-shadow-18        sb-devtmpfs-5    sb-proc-48       sb-tmpfs-43
    mm-zspool:zram0-34  sb-hugetlbfs-17  sb-pstore-31     sb-tmpfs-44
    rcu-kfree-0         sb-hugetlbfs-33  sb-rootfs-2      sb-tmpfs-49
    sb-aio-20           sb-iomem-12      sb-securityfs-6  sb-tracefs-13
    sb-anon_inodefs-15  sb-mqueue-21     sb-selinuxfs-22  sb-xfs:vda1-36
    sb-bdev-3           sb-nsfs-4        sb-sockfs-8      sb-zsmalloc-19
    sb-bpf-32           sb-pipefs-14     sb-sysfs-26      thp-deferred_split-10
    sb-btrfs:vda2-24    sb-proc-25       sb-tmpfs-1       thp-zero-9
    sb-cgroup2-30       sb-proc-39       sb-tmpfs-27      xfs-buf:vda1-37
    sb-configfs-23      sb-proc-41       sb-tmpfs-29      xfs-inodegc:vda1-38
    sb-dax-11           sb-proc-45       sb-tmpfs-35
    sb-debugfs-7        sb-proc-46       sb-tmpfs-40

[roman.gushchin@linux.dev: fix build warnings]
Link: https://lkml.kernel.org/r/Yr+ZTnLb9lJk6fJO@castle
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lkml.kernel.org/r/20220601032227.4076670-4-roman.gushchin@linux.dev
Signed-off-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: Hillf Danton <hdanton@sina.com>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
39 files changed:
arch/x86/kvm/mmu/mmu.c
drivers/android/binder_alloc.c
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
drivers/gpu/drm/msm/msm_gem_shrinker.c
drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c
drivers/gpu/drm/ttm/ttm_pool.c
drivers/md/bcache/btree.c
drivers/md/dm-bufio.c
drivers/md/dm-zoned-metadata.c
drivers/md/raid5.c
drivers/misc/vmw_balloon.c
drivers/virtio/virtio_balloon.c
drivers/xen/xenbus/xenbus_probe_backend.c
fs/btrfs/super.c
fs/erofs/utils.c
fs/ext4/extents_status.c
fs/f2fs/super.c
fs/gfs2/glock.c
fs/gfs2/main.c
fs/jbd2/journal.c
fs/mbcache.c
fs/nfs/nfs42xattr.c
fs/nfs/super.c
fs/nfsd/filecache.c
fs/nfsd/nfscache.c
fs/quota/dquot.c
fs/super.c
fs/ubifs/super.c
fs/xfs/xfs_buf.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_qm.c
include/linux/shrinker.h
kernel/rcu/tree.c
mm/huge_memory.c
mm/shrinker_debug.c
mm/vmscan.c
mm/workingset.c
mm/zsmalloc.c
net/sunrpc/auth.c

index 17252f39bd7c2ef466b1519e6c97de025f0f6562..797d3286ecc1461c4d4c753ac75f20cf56a88022 100644 (file)
@@ -6317,7 +6317,7 @@ int kvm_mmu_vendor_module_init(void)
        if (percpu_counter_init(&kvm_total_used_mmu_pages, 0, GFP_KERNEL))
                goto out;
 
-       ret = register_shrinker(&mmu_shrinker);
+       ret = register_shrinker(&mmu_shrinker, "x86-mmu");
        if (ret)
                goto out;
 
index 5649a0371a1f2c8b553957f613b4d271d21919ee..51b502217d000cfe6d56f5fcbc57a15fe3ad7650 100644 (file)
@@ -1084,7 +1084,7 @@ int binder_alloc_shrinker_init(void)
        int ret = list_lru_init(&binder_alloc_lru);
 
        if (ret == 0) {
-               ret = register_shrinker(&binder_shrinker);
+               ret = register_shrinker(&binder_shrinker, "android-binder");
                if (ret)
                        list_lru_destroy(&binder_alloc_lru);
        }
index 6a6ff98a87462b388f8af950fcc1b0282e656ade..e43577e03067d9d0c666f2ad48415e215312e4f1 100644 (file)
@@ -426,7 +426,8 @@ void i915_gem_driver_register__shrinker(struct drm_i915_private *i915)
        i915->mm.shrinker.count_objects = i915_gem_shrinker_count;
        i915->mm.shrinker.seeks = DEFAULT_SEEKS;
        i915->mm.shrinker.batch = 4096;
-       drm_WARN_ON(&i915->drm, register_shrinker(&i915->mm.shrinker));
+       drm_WARN_ON(&i915->drm, register_shrinker(&i915->mm.shrinker,
+                                                 "drm-i915_gem"));
 
        i915->mm.oom_notifier.notifier_call = i915_gem_shrinker_oom;
        drm_WARN_ON(&i915->drm, register_oom_notifier(&i915->mm.oom_notifier));
index 086dacf2f26a74120f015a4d5f1ed93b9e0fdc1b..26e84d2ea6aea89087be44cc651d5794840de60a 100644 (file)
@@ -221,7 +221,7 @@ void msm_gem_shrinker_init(struct drm_device *dev)
        priv->shrinker.count_objects = msm_gem_shrinker_count;
        priv->shrinker.scan_objects = msm_gem_shrinker_scan;
        priv->shrinker.seeks = DEFAULT_SEEKS;
-       WARN_ON(register_shrinker(&priv->shrinker));
+       WARN_ON(register_shrinker(&priv->shrinker, "drm-msm_gem"));
 
        priv->vmap_notifier.notifier_call = msm_gem_shrinker_vmap;
        WARN_ON(register_vmap_purge_notifier(&priv->vmap_notifier));
index 77e7cb6d1ae3b8f4fae97007ffc4cf5756d82bc8..bf0170782f2585e9dc90bc2943191ec64dcb6aa5 100644 (file)
@@ -103,7 +103,7 @@ void panfrost_gem_shrinker_init(struct drm_device *dev)
        pfdev->shrinker.count_objects = panfrost_gem_shrinker_count;
        pfdev->shrinker.scan_objects = panfrost_gem_shrinker_scan;
        pfdev->shrinker.seeks = DEFAULT_SEEKS;
-       WARN_ON(register_shrinker(&pfdev->shrinker));
+       WARN_ON(register_shrinker(&pfdev->shrinker, "drm-panfrost"));
 }
 
 /**
index 1bba0a0ed3f996fbef159085dffd6b6c8f60355b..21b61631f73a1be9c586b7af50a7f193b7d2f153 100644 (file)
@@ -722,7 +722,7 @@ int ttm_pool_mgr_init(unsigned long num_pages)
        mm_shrinker.count_objects = ttm_pool_shrinker_count;
        mm_shrinker.scan_objects = ttm_pool_shrinker_scan;
        mm_shrinker.seeks = 1;
-       return register_shrinker(&mm_shrinker);
+       return register_shrinker(&mm_shrinker, "drm-ttm_pool");
 }
 
 /**
index e136d6edc1ed63b07e91f103356e302658eb0bc5..147c493a989a5e1fcc03039188c302c4321a2d33 100644 (file)
@@ -812,7 +812,7 @@ int bch_btree_cache_alloc(struct cache_set *c)
        c->shrink.seeks = 4;
        c->shrink.batch = c->btree_pages * 2;
 
-       if (register_shrinker(&c->shrink))
+       if (register_shrinker(&c->shrink, "md-bcache:%pU", c->set_uuid))
                pr_warn("bcache: %s: could not register shrinker\n",
                                __func__);
 
index 5ffa1dcf84cfc8f441398eacaaac1b16425ef544..3ff571b20f14948f88415bb2956a286642e505d2 100644 (file)
@@ -1806,7 +1806,8 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign
        c->shrinker.scan_objects = dm_bufio_shrink_scan;
        c->shrinker.seeks = 1;
        c->shrinker.batch = 0;
-       r = register_shrinker(&c->shrinker);
+       r = register_shrinker(&c->shrinker, "md-%s:(%u:%u)", slab_name,
+                             MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev));
        if (r)
                goto bad;
 
index d1ea66114d1424681405d42305bc03c739e2a8ae..46648f6100fbee7263a555292fac22ae54fc83ac 100644 (file)
@@ -2944,7 +2944,9 @@ int dmz_ctr_metadata(struct dmz_dev *dev, int num_dev,
        zmd->mblk_shrinker.seeks = DEFAULT_SEEKS;
 
        /* Metadata cache shrinker */
-       ret = register_shrinker(&zmd->mblk_shrinker);
+       ret = register_shrinker(&zmd->mblk_shrinker, "md-meta:(%u:%u)",
+                               MAJOR(dev->bdev->bd_dev),
+                               MINOR(dev->bdev->bd_dev));
        if (ret) {
                dmz_zmd_err(zmd, "Register metadata cache shrinker failed");
                goto err;
index 5d09256d7f81857d4a6861ef192a6f0d385118a8..780ae66840b761d426de2b1545b89f83095a389c 100644 (file)
@@ -7414,7 +7414,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
        conf->shrinker.count_objects = raid5_cache_count;
        conf->shrinker.batch = 128;
        conf->shrinker.flags = 0;
-       ret = register_shrinker(&conf->shrinker);
+       ret = register_shrinker(&conf->shrinker, "md-raid5:%s", mdname(mddev));
        if (ret) {
                pr_warn("md/raid:%s: couldn't register shrinker.\n",
                        mdname(mddev));
index 086ce77d9074e5aa4f7421ae738c3c69530ecb22..c2d2fa114e65c58e13aa02a65b598bbe2d6184b2 100644 (file)
@@ -1587,7 +1587,7 @@ static int vmballoon_register_shrinker(struct vmballoon *b)
        b->shrinker.count_objects = vmballoon_shrinker_count;
        b->shrinker.seeks = DEFAULT_SEEKS;
 
-       r = register_shrinker(&b->shrinker);
+       r = register_shrinker(&b->shrinker, "vmw-balloon");
 
        if (r == 0)
                b->shrinker_registered = true;
index b9737da6c4ddbc06732767232c82a510e9f7de16..cba57b1f382fb2975dbe9590d492ed48e799be29 100644 (file)
@@ -875,7 +875,7 @@ static int virtio_balloon_register_shrinker(struct virtio_balloon *vb)
        vb->shrinker.count_objects = virtio_balloon_shrinker_count;
        vb->shrinker.seeks = DEFAULT_SEEKS;
 
-       return register_shrinker(&vb->shrinker);
+       return register_shrinker(&vb->shrinker, "virtio-balloon");
 }
 
 static int virtballoon_probe(struct virtio_device *vdev)
index 5abded97e1a7e513990bc38d230c4f929b091c23..9c09f89d8278b3aa2978f21c14f0eb6b357eca3d 100644 (file)
@@ -305,7 +305,7 @@ static int __init xenbus_probe_backend_init(void)
 
        register_xenstore_notifier(&xenstore_notifier);
 
-       if (register_shrinker(&backend_memory_shrinker))
+       if (register_shrinker(&backend_memory_shrinker, "xen-backend"))
                pr_warn("shrinker registration failed\n");
 
        return 0;
index 6627dd7875ee0ede0b478e5f4e975ef6737875e5..eee3e96d877f0e0b1e7f1c0cc9d3f40709285ce7 100644 (file)
@@ -1815,6 +1815,8 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type,
                        error = -EBUSY;
        } else {
                snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
+               shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name,
+                                       s->s_id);
                btrfs_sb(s)->bdev_holder = fs_type;
                if (!strstr(crc32c_impl(), "generic"))
                        set_bit(BTRFS_FS_CSUM_IMPL_FAST, &fs_info->flags);
index ec9a1d780dc143c0bd8ab3d6b42b8532f022fe48..46627cb69abe9adbed15c02e6eca41a21338532e 100644 (file)
@@ -282,7 +282,7 @@ static struct shrinker erofs_shrinker_info = {
 
 int __init erofs_init_shrinker(void)
 {
-       return register_shrinker(&erofs_shrinker_info);
+       return register_shrinker(&erofs_shrinker_info, "erofs-shrinker");
 }
 
 void erofs_exit_shrinker(void)
index 9a3a8996aacf7356131e3ea6a12e096f3a711695..23167efda95ee14659f70ec91a429ebd0a32a984 100644 (file)
@@ -1654,7 +1654,8 @@ int ext4_es_register_shrinker(struct ext4_sb_info *sbi)
        sbi->s_es_shrinker.scan_objects = ext4_es_scan;
        sbi->s_es_shrinker.count_objects = ext4_es_count;
        sbi->s_es_shrinker.seeks = DEFAULT_SEEKS;
-       err = register_shrinker(&sbi->s_es_shrinker);
+       err = register_shrinker(&sbi->s_es_shrinker, "ext4-es:%s",
+                               sbi->s_sb->s_id);
        if (err)
                goto err4;
 
index 37221e94e5eff55b82b3b8940b9ef025f36f348f..bce02306f7a0cd14e09dd0e371ea8b2d5fcbcd9d 100644 (file)
@@ -4579,7 +4579,7 @@ static int __init init_f2fs_fs(void)
        err = f2fs_init_sysfs();
        if (err)
                goto free_garbage_collection_cache;
-       err = register_shrinker(&f2fs_shrinker_info);
+       err = register_shrinker(&f2fs_shrinker_info, "f2fs-shrinker");
        if (err)
                goto free_sysfs;
        err = register_filesystem(&f2fs_fs_type);
index c992d53013d31dc7a8d679d266338b58bc3bf2dc..dca842379caba00380fa947e5fe3440d768430d4 100644 (file)
@@ -2533,7 +2533,7 @@ int __init gfs2_glock_init(void)
                return -ENOMEM;
        }
 
-       ret = register_shrinker(&glock_shrinker);
+       ret = register_shrinker(&glock_shrinker, "gfs2-glock");
        if (ret) {
                destroy_workqueue(gfs2_delete_workqueue);
                destroy_workqueue(glock_workqueue);
index 244187e3e70f7eeb1a91588b1b3f1f86a07b8b66..b66a3e1ec15286655e0e3fa576c22aeaed5222c8 100644 (file)
@@ -148,7 +148,7 @@ static int __init init_gfs2_fs(void)
        if (!gfs2_trans_cachep)
                goto fail_cachep8;
 
-       error = register_shrinker(&gfs2_qd_shrinker);
+       error = register_shrinker(&gfs2_qd_shrinker, "gfs2-qd");
        if (error)
                goto fail_shrinker;
 
index c0cbeeaec2d1aa33d0ff97217ae02e2205c248ba..45e4655c8033ecaf9be860d98e382c7fa09af0fb 100644 (file)
@@ -1418,7 +1418,8 @@ static journal_t *journal_init_common(struct block_device *bdev,
        if (percpu_counter_init(&journal->j_checkpoint_jh_count, 0, GFP_KERNEL))
                goto err_cleanup;
 
-       if (register_shrinker(&journal->j_shrinker)) {
+       if (register_shrinker(&journal->j_shrinker, "jbd2-journal:(%u:%u)",
+                             MAJOR(bdev->bd_dev), MINOR(bdev->bd_dev))) {
                percpu_counter_destroy(&journal->j_checkpoint_jh_count);
                goto err_cleanup;
        }
index 97c54d3a2227693df2050109fc10a9fa7f5921ac..0b833da0a9a5fad56d313b0064cf9772f33e7053 100644 (file)
@@ -367,7 +367,7 @@ struct mb_cache *mb_cache_create(int bucket_bits)
        cache->c_shrink.count_objects = mb_cache_count;
        cache->c_shrink.scan_objects = mb_cache_scan;
        cache->c_shrink.seeks = DEFAULT_SEEKS;
-       if (register_shrinker(&cache->c_shrink)) {
+       if (register_shrinker(&cache->c_shrink, "mbcache-shrinker")) {
                kfree(cache->c_hash);
                kfree(cache);
                goto err_out;
index e7b34f7e0614b6ff47836777c98fd21a07ba054d..a9bf09fdf2c3203df1716799502d624cb2ccce58 100644 (file)
@@ -1017,15 +1017,16 @@ int __init nfs4_xattr_cache_init(void)
        if (ret)
                goto out2;
 
-       ret = register_shrinker(&nfs4_xattr_cache_shrinker);
+       ret = register_shrinker(&nfs4_xattr_cache_shrinker, "nfs-xattr_cache");
        if (ret)
                goto out1;
 
-       ret = register_shrinker(&nfs4_xattr_entry_shrinker);
+       ret = register_shrinker(&nfs4_xattr_entry_shrinker, "nfs-xattr_entry");
        if (ret)
                goto out;
 
-       ret = register_shrinker(&nfs4_xattr_large_entry_shrinker);
+       ret = register_shrinker(&nfs4_xattr_large_entry_shrinker,
+                               "nfs-xattr_large_entry");
        if (!ret)
                return 0;
 
index 6ab5eeb000dc020bdd9ec2b092d47877a2720935..82944e14fcea19533f9bb2ea9e1819ea0da784ec 100644 (file)
@@ -149,7 +149,7 @@ int __init register_nfs_fs(void)
        ret = nfs_register_sysctl();
        if (ret < 0)
                goto error_2;
-       ret = register_shrinker(&acl_shrinker);
+       ret = register_shrinker(&acl_shrinker, "nfs-acl");
        if (ret < 0)
                goto error_3;
 #ifdef CONFIG_NFS_V4_2
index 9cb2d590c0361b80fb4531e0b634d78ac6fd7600..a605c0e39b09ff502d27e2370eb94b3a47771c5e 100644 (file)
@@ -670,7 +670,7 @@ nfsd_file_cache_init(void)
                goto out_err;
        }
 
-       ret = register_shrinker(&nfsd_file_shrinker);
+       ret = register_shrinker(&nfsd_file_shrinker, "nfsd-filecache");
        if (ret) {
                pr_err("nfsd: failed to register nfsd_file_shrinker: %d\n", ret);
                goto out_lru;
index 7da88bdc0d6c36bdd5da24f69a3870718dd4ee44..9b31e1103e7b1d2ae4ded2587b3cff73e79d5fac 100644 (file)
@@ -176,7 +176,8 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
        nn->nfsd_reply_cache_shrinker.scan_objects = nfsd_reply_cache_scan;
        nn->nfsd_reply_cache_shrinker.count_objects = nfsd_reply_cache_count;
        nn->nfsd_reply_cache_shrinker.seeks = 1;
-       status = register_shrinker(&nn->nfsd_reply_cache_shrinker);
+       status = register_shrinker(&nn->nfsd_reply_cache_shrinker,
+                                  "nfsd-reply:%s", nn->nfsd_name);
        if (status)
                goto out_stats_destroy;
 
index 09d1307959d085720769839b95f5c99f0478de78..e0b659900e70e3478bc918ff8a99259bed8dbeab 100644 (file)
@@ -2995,7 +2995,7 @@ static int __init dquot_init(void)
        pr_info("VFS: Dquot-cache hash table entries: %ld (order %ld,"
                " %ld bytes)\n", nr_hash, order, (PAGE_SIZE << order));
 
-       if (register_shrinker(&dqcache_shrinker))
+       if (register_shrinker(&dqcache_shrinker, "dquota-cache"))
                panic("Cannot register dquot shrinker");
 
        return 0;
index 60f57c7bc0a69a0cb931a957c354ed740aaba9f0..4fca6657f442bc8b44500eef95782825697c6ff4 100644 (file)
@@ -265,7 +265,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags,
        s->s_shrink.count_objects = super_cache_count;
        s->s_shrink.batch = 1024;
        s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE;
-       if (prealloc_shrinker(&s->s_shrink))
+       if (prealloc_shrinker(&s->s_shrink, "sb-%s", type->name))
                goto fail;
        if (list_lru_init_memcg(&s->s_dentry_lru, &s->s_shrink))
                goto fail;
@@ -1288,6 +1288,8 @@ int get_tree_bdev(struct fs_context *fc,
        } else {
                s->s_mode = mode;
                snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
+               shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s",
+                                       fc->fs_type->name, s->s_id);
                sb_set_blocksize(s, block_size(bdev));
                error = fill_super(s, fc);
                if (error) {
@@ -1363,6 +1365,8 @@ struct dentry *mount_bdev(struct file_system_type *fs_type,
        } else {
                s->s_mode = mode;
                snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev);
+               shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s",
+                                       fs_type->name, s->s_id);
                sb_set_blocksize(s, block_size(bdev));
                error = fill_super(s, data, flags & SB_SILENT ? 1 : 0);
                if (error) {
index 0978d01b0ea4fa09479b2ed35c5a5cc7a723a2a9..d0c9a09988bc7ba59d78391fe10cc9e15dbdaa28 100644 (file)
@@ -2430,7 +2430,7 @@ static int __init ubifs_init(void)
        if (!ubifs_inode_slab)
                return -ENOMEM;
 
-       err = register_shrinker(&ubifs_shrinker_info);
+       err = register_shrinker(&ubifs_shrinker_info, "ubifs-slab");
        if (err)
                goto out_slab;
 
index bf4e60871068205eb30a4909654717782d6bbe84..4aa9c9cf5b6e7683c67efbaa2c920311f6053cb1 100644 (file)
@@ -1986,7 +1986,8 @@ xfs_alloc_buftarg(
        btp->bt_shrinker.scan_objects = xfs_buftarg_shrink_scan;
        btp->bt_shrinker.seeks = DEFAULT_SEEKS;
        btp->bt_shrinker.flags = SHRINKER_NUMA_AWARE;
-       if (register_shrinker(&btp->bt_shrinker))
+       if (register_shrinker(&btp->bt_shrinker, "xfs-buf:%s",
+                             mp->m_super->s_id))
                goto error_pcpu;
        return btp;
 
index 5269354b1b69d432aa1f7cfb7852da3055dbc3b8..a1941c8b863057ada3996279012d7442e497d912 100644 (file)
@@ -2201,5 +2201,5 @@ xfs_inodegc_register_shrinker(
        shrink->flags = SHRINKER_NONSLAB;
        shrink->batch = XFS_INODEGC_SHRINKER_BATCH;
 
-       return register_shrinker(shrink);
+       return register_shrinker(shrink, "xfs-inodegc:%s", mp->m_super->s_id);
 }
index abf08bbf34a90f2aace2d9a43c3750bba91ee795..c31d57453cebab5263db5768557bb5e7442d9b3c 100644 (file)
@@ -677,7 +677,8 @@ xfs_qm_init_quotainfo(
        qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
        qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
 
-       error = register_shrinker(&qinf->qi_shrinker);
+       error = register_shrinker(&qinf->qi_shrinker, "xfs-qm:%s",
+                                 mp->m_super->s_id);
        if (error)
                goto out_free_inos;
 
index 2ced8149c51371027fe7fe37480608aa9b26710e..08e6054e061f3bd03ef3020d9d211ae820748d97 100644 (file)
@@ -75,6 +75,7 @@ struct shrinker {
 #endif
 #ifdef CONFIG_SHRINKER_DEBUG
        int debugfs_id;
+       const char *name;
        struct dentry *debugfs_entry;
 #endif
        /* objs pending delete, per node */
@@ -92,9 +93,11 @@ struct shrinker {
  */
 #define SHRINKER_NONSLAB       (1 << 3)
 
-extern int prealloc_shrinker(struct shrinker *shrinker);
+extern int __printf(2, 3) prealloc_shrinker(struct shrinker *shrinker,
+                                           const char *fmt, ...);
 extern void register_shrinker_prepared(struct shrinker *shrinker);
-extern int register_shrinker(struct shrinker *shrinker);
+extern int __printf(2, 3) register_shrinker(struct shrinker *shrinker,
+                                           const char *fmt, ...);
 extern void unregister_shrinker(struct shrinker *shrinker);
 extern void free_prealloced_shrinker(struct shrinker *shrinker);
 extern void synchronize_shrinkers(void);
@@ -102,6 +105,8 @@ extern void synchronize_shrinkers(void);
 #ifdef CONFIG_SHRINKER_DEBUG
 extern int shrinker_debugfs_add(struct shrinker *shrinker);
 extern void shrinker_debugfs_remove(struct shrinker *shrinker);
+extern int __printf(2, 3) shrinker_debugfs_rename(struct shrinker *shrinker,
+                                                 const char *fmt, ...);
 #else /* CONFIG_SHRINKER_DEBUG */
 static inline int shrinker_debugfs_add(struct shrinker *shrinker)
 {
@@ -110,5 +115,10 @@ static inline int shrinker_debugfs_add(struct shrinker *shrinker)
 static inline void shrinker_debugfs_remove(struct shrinker *shrinker)
 {
 }
+static inline __printf(2, 3)
+int shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...)
+{
+       return 0;
+}
 #endif /* CONFIG_SHRINKER_DEBUG */
 #endif /* _LINUX_SHRINKER_H */
index c25ba442044a6e9452a43f617a93abd4a8b6ab08..4b3bf6ebb1ebefa50dacfe1023116542d47081c1 100644 (file)
@@ -4884,7 +4884,7 @@ static void __init kfree_rcu_batch_init(void)
                INIT_DELAYED_WORK(&krcp->page_cache_work, fill_page_cache_func);
                krcp->initialized = true;
        }
-       if (register_shrinker(&kfree_rcu_shrinker))
+       if (register_shrinker(&kfree_rcu_shrinker, "rcu-kfree"))
                pr_err("Failed to register kfree_rcu() shrinker!\n");
 }
 
index f9b90a8d7dfa4ce0f6c9f23a1b26b6ad2664f50f..60d742c33de34d72511008bd71ad6ee910b58ab5 100644 (file)
@@ -423,10 +423,10 @@ static int __init hugepage_init(void)
        if (err)
                goto err_slab;
 
-       err = register_shrinker(&huge_zero_page_shrinker);
+       err = register_shrinker(&huge_zero_page_shrinker, "thp-zero");
        if (err)
                goto err_hzp_shrinker;
-       err = register_shrinker(&deferred_split_shrinker);
+       err = register_shrinker(&deferred_split_shrinker, "thp-deferred_split");
        if (err)
                goto err_split_shrinker;
 
index 1a70556bd46cf46b6c3f0368af519249232165f2..781ecbd3d6080c33d02c07049f47b35a7f1e9851 100644 (file)
@@ -102,7 +102,7 @@ DEFINE_SHOW_ATTRIBUTE(shrinker_debugfs_count);
 int shrinker_debugfs_add(struct shrinker *shrinker)
 {
        struct dentry *entry;
-       char buf[16];
+       char buf[128];
        int id;
 
        lockdep_assert_held(&shrinker_rwsem);
@@ -116,7 +116,7 @@ int shrinker_debugfs_add(struct shrinker *shrinker)
                return id;
        shrinker->debugfs_id = id;
 
-       snprintf(buf, sizeof(buf), "%d", id);
+       snprintf(buf, sizeof(buf), "%s-%d", shrinker->name, id);
 
        /* create debugfs entry */
        entry = debugfs_create_dir(buf, shrinker_debugfs_root);
@@ -131,10 +131,53 @@ int shrinker_debugfs_add(struct shrinker *shrinker)
        return 0;
 }
 
+int shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...)
+{
+       struct dentry *entry;
+       char buf[128];
+       const char *new, *old;
+       va_list ap;
+       int ret = 0;
+
+       va_start(ap, fmt);
+       new = kvasprintf_const(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+
+       if (!new)
+               return -ENOMEM;
+
+       down_write(&shrinker_rwsem);
+
+       old = shrinker->name;
+       shrinker->name = new;
+
+       if (shrinker->debugfs_entry) {
+               snprintf(buf, sizeof(buf), "%s-%d", shrinker->name,
+                        shrinker->debugfs_id);
+
+               entry = debugfs_rename(shrinker_debugfs_root,
+                                      shrinker->debugfs_entry,
+                                      shrinker_debugfs_root, buf);
+               if (IS_ERR(entry))
+                       ret = PTR_ERR(entry);
+               else
+                       shrinker->debugfs_entry = entry;
+       }
+
+       up_write(&shrinker_rwsem);
+
+       kfree_const(old);
+
+       return ret;
+}
+EXPORT_SYMBOL(shrinker_debugfs_rename);
+
 void shrinker_debugfs_remove(struct shrinker *shrinker)
 {
        lockdep_assert_held(&shrinker_rwsem);
 
+       kfree_const(shrinker->name);
+
        if (!shrinker->debugfs_entry)
                return;
 
index 35dedff79eb4cf6b2443da9f7a1008312f773535..97ac6c6c026dcd9d28650dcad424719cd83a2f5d 100644 (file)
@@ -608,7 +608,7 @@ static unsigned long lruvec_lru_size(struct lruvec *lruvec, enum lru_list lru,
 /*
  * Add a shrinker callback to be called from the vm.
  */
-int prealloc_shrinker(struct shrinker *shrinker)
+static int __prealloc_shrinker(struct shrinker *shrinker)
 {
        unsigned int size;
        int err;
@@ -632,8 +632,36 @@ int prealloc_shrinker(struct shrinker *shrinker)
        return 0;
 }
 
+#ifdef CONFIG_SHRINKER_DEBUG
+int prealloc_shrinker(struct shrinker *shrinker, const char *fmt, ...)
+{
+       va_list ap;
+       int err;
+
+       va_start(ap, fmt);
+       shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+       if (!shrinker->name)
+               return -ENOMEM;
+
+       err = __prealloc_shrinker(shrinker);
+       if (err)
+               kfree_const(shrinker->name);
+
+       return err;
+}
+#else
+int prealloc_shrinker(struct shrinker *shrinker, const char *fmt, ...)
+{
+       return __prealloc_shrinker(shrinker);
+}
+#endif
+
 void free_prealloced_shrinker(struct shrinker *shrinker)
 {
+#ifdef CONFIG_SHRINKER_DEBUG
+       kfree_const(shrinker->name);
+#endif
        if (shrinker->flags & SHRINKER_MEMCG_AWARE) {
                down_write(&shrinker_rwsem);
                unregister_memcg_shrinker(shrinker);
@@ -654,15 +682,39 @@ void register_shrinker_prepared(struct shrinker *shrinker)
        up_write(&shrinker_rwsem);
 }
 
-int register_shrinker(struct shrinker *shrinker)
+static int __register_shrinker(struct shrinker *shrinker)
 {
-       int err = prealloc_shrinker(shrinker);
+       int err = __prealloc_shrinker(shrinker);
 
        if (err)
                return err;
        register_shrinker_prepared(shrinker);
        return 0;
 }
+
+#ifdef CONFIG_SHRINKER_DEBUG
+int register_shrinker(struct shrinker *shrinker, const char *fmt, ...)
+{
+       va_list ap;
+       int err;
+
+       va_start(ap, fmt);
+       shrinker->name = kvasprintf_const(GFP_KERNEL, fmt, ap);
+       va_end(ap);
+       if (!shrinker->name)
+               return -ENOMEM;
+
+       err = __register_shrinker(shrinker);
+       if (err)
+               kfree_const(shrinker->name);
+       return err;
+}
+#else
+int register_shrinker(struct shrinker *shrinker, const char *fmt, ...)
+{
+       return __register_shrinker(shrinker);
+}
+#endif
 EXPORT_SYMBOL(register_shrinker);
 
 /*
index 592569a8974c4d41bda81095b1e51c32f6bc7444..a5e84862fc86881e09ad611ebbca6e3c156ea234 100644 (file)
@@ -625,7 +625,7 @@ 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);
+       ret = prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow");
        if (ret)
                goto err;
        ret = __list_lru_init(&shadow_nodes, true, &shadow_nodes_key,
index 5d5fc04385b8d78ab70ae3c8d7d276e876030352..f24b71568e830272940eb1f5bb36abc9d0d13d1e 100644 (file)
@@ -2217,7 +2217,8 @@ static int zs_register_shrinker(struct zs_pool *pool)
        pool->shrinker.batch = 0;
        pool->shrinker.seeks = DEFAULT_SEEKS;
 
-       return register_shrinker(&pool->shrinker);
+       return register_shrinker(&pool->shrinker, "mm-zspool:%s",
+                                pool->name);
 }
 
 /**
index 682fcd24bf439ca23aeffb3efd202b03f956187f..04e7b55fe0d96bf78ccab3714597a9b82e50782a 100644 (file)
@@ -874,7 +874,7 @@ int __init rpcauth_init_module(void)
        err = rpc_init_authunix();
        if (err < 0)
                goto out1;
-       err = register_shrinker(&rpc_cred_shrinker);
+       err = register_shrinker(&rpc_cred_shrinker, "sunrpc_cred");
        if (err < 0)
                goto out2;
        return 0;