lkml.org 
[lkml]   [2023]   [Sep]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v6 05/45] xenbus/backend: dynamically allocate the xen-backend shrinker
    Date
    Use new APIs to dynamically allocate the xen-backend shrinker.

    Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
    Reviewed-by: Muchun Song <songmuchun@bytedance.com>
    Acked-by: Juergen Gross <jgross@suse.com>
    CC: Stefano Stabellini <sstabellini@kernel.org>
    CC: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    CC: xen-devel@lists.xenproject.org
    ---
    drivers/xen/xenbus/xenbus_probe_backend.c | 17 ++++++++++-------
    1 file changed, 10 insertions(+), 7 deletions(-)

    diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c
    index da96c260e26b..5ebb7233076f 100644
    --- a/drivers/xen/xenbus/xenbus_probe_backend.c
    +++ b/drivers/xen/xenbus/xenbus_probe_backend.c
    @@ -284,13 +284,9 @@ static unsigned long backend_shrink_memory_count(struct shrinker *shrinker,
    return 0;
    }

    -static struct shrinker backend_memory_shrinker = {
    - .count_objects = backend_shrink_memory_count,
    - .seeks = DEFAULT_SEEKS,
    -};
    -
    static int __init xenbus_probe_backend_init(void)
    {
    + struct shrinker *backend_memory_shrinker;
    static struct notifier_block xenstore_notifier = {
    .notifier_call = backend_probe_and_watch
    };
    @@ -305,8 +301,15 @@ static int __init xenbus_probe_backend_init(void)

    register_xenstore_notifier(&xenstore_notifier);

    - if (register_shrinker(&backend_memory_shrinker, "xen-backend"))
    - pr_warn("shrinker registration failed\n");
    + backend_memory_shrinker = shrinker_alloc(0, "xen-backend");
    + if (!backend_memory_shrinker) {
    + pr_warn("shrinker allocation failed\n");
    + return 0;
    + }
    +
    + backend_memory_shrinker->count_objects = backend_shrink_memory_count;
    +
    + shrinker_register(backend_memory_shrinker);

    return 0;
    }
    --
    2.30.2
    \
     
     \ /
      Last update: 2023-09-12 00:22    [W:8.272 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site