From patchwork Thu Aug 24 03:42:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13363502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB45AC71145 for ; Thu, 24 Aug 2023 03:49:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8204D2800AD; Wed, 23 Aug 2023 23:49:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A9E48E0011; Wed, 23 Aug 2023 23:49:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64A052800AD; Wed, 23 Aug 2023 23:49:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 505F28E0011 for ; Wed, 23 Aug 2023 23:49:38 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 23103401B7 for ; Thu, 24 Aug 2023 03:49:38 +0000 (UTC) X-FDA: 81157618836.05.5B51873 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf03.hostedemail.com (Postfix) with ESMTP id 5B78D2000C for ; Thu, 24 Aug 2023 03:49:36 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=TRSLMXdP; spf=pass (imf03.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1692848976; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qmgoIAslokneklTFoEzEoFMrIw6hl8ApjrQYf+i1Q4o=; b=ZZjhLCnhIUe8mx0gizydpnZ13FwRhAUwqkC5DffOe/4KEwdoKHUHcurhbTdI1U8XhJd0vI 47UiPs1HDBUQcmY+VJGTTel3tOgm336Lr14g03xFYvMuNmQwaMaYy2cOnGyBeKGjeo0Cus YwU3kbmsV88LVKlKN2QmDM+iO8S0AoE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692848976; a=rsa-sha256; cv=none; b=iVWguqcQElTtQBP0gMYR/yyOdDtNmw94iGZsFqvogxXW65RJyEGRACr5neT8YhddVfpd6b UXT5ZVb9U7k8lJel2iaNwQ0Zgpdn0NJI+xj61Ubk8QiAOFWBEbFiymxeBNT+dqGoW4wDyj TiCOj2CCP/5vMHwxSt/c9oZJfHg/Q9I= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=TRSLMXdP; spf=pass (imf03.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.210.182 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-68a32506e90so1062960b3a.1 for ; Wed, 23 Aug 2023 20:49:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1692848975; x=1693453775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qmgoIAslokneklTFoEzEoFMrIw6hl8ApjrQYf+i1Q4o=; b=TRSLMXdPlmwf9YEXYGnxt1Er7+vIMxGkXRFP+npDhhzxHYEZrz2fsp/CNMu5ekgS8P ZVQdZoWjCeWSWoSX0FD+SMWAvhqxdbo/SUI6G5epNK71KMQN/I0UgyD/TP8vnBiqWa2F dpLUodo7woLZUS/OgUd4n8LBwIEnnIfgsZoYtadSO95/PxsyM3N0R5s3QP+YCpStQDf+ rB0+AD5yGw6voV92ne0m7t1cRTXRUFv4aTU6ocrlUAzZSMJTUFcezv4BNlikDZYgFqz5 CSIkdNIkvPbpmdBFPSagV0mGjdvOlzGd8rMQx+ZM7/8xXDCC3lla5V3wstPB0iOQMZLM pBgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692848975; x=1693453775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qmgoIAslokneklTFoEzEoFMrIw6hl8ApjrQYf+i1Q4o=; b=HP7gQ14q84a34LwwAlg6mdRkuFxLte7Y1iBVEI7fY7CamFS/o/8ROxKnKwypJvWJZ+ AnZuh0kMqCVm3GaQajyQnYaRcByXHURLEORN3tg1fTOB217eggsYU5hW7coBUJEwd4lE Uj3dWuilbTEJDhoZbLpSM/rWoS/5wiWT3r9iDxyitYXvAcLHrCKSWXNb6fs7n495cdeR ExQ9jcW2o1dGXJnebHPQ4FABUugJW/Y7dTumrS4tw+B7FZQmk8H8GvuI8er8Kexwk7bW yr6I+EU3LfX9Cw1t2yGpJB7wHfCNj6w6cJ3hPnMN/JSxDk+u6D5gNOBPSdvZyiXh4P61 Z2lQ== X-Gm-Message-State: AOJu0YxCgodz9jt20cdm/gH6w6hixjtInoqqRACJIzyziZztHtUoL/9u 3NXfShnMQIUfvR4JF3UIgZiYug== X-Google-Smtp-Source: AGHT+IEnL/536NpETn587uFUKIsPyUoKrOXgr9b77JCUCWQkpC9m8Or3mJZEtRjjogndteOSgzRUYw== X-Received: by 2002:a05:6a00:3107:b0:68a:4bf9:3b21 with SMTP id bi7-20020a056a00310700b0068a4bf93b21mr11175503pfb.0.1692848975313; Wed, 23 Aug 2023 20:49:35 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id t6-20020a63b246000000b005579f12a238sm10533157pgo.86.2023.08.23.20.49.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Aug 2023 20:49:34 -0700 (PDT) From: Qi Zheng To: akpm@linux-foundation.org, david@fromorbit.com, tkhai@ya.ru, vbabka@suse.cz, roman.gushchin@linux.dev, djwong@kernel.org, brauner@kernel.org, paulmck@kernel.org, tytso@mit.edu, steven.price@arm.com, cel@kernel.org, senozhatsky@chromium.org, yujie.liu@intel.com, gregkh@linuxfoundation.org, muchun.song@linux.dev Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Qi Zheng , Muchun Song Subject: [PATCH v5 39/45] mm: shrinker: remove old APIs Date: Thu, 24 Aug 2023 11:42:58 +0800 Message-Id: <20230824034304.37411-40-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230824034304.37411-1-zhengqi.arch@bytedance.com> References: <20230824034304.37411-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5B78D2000C X-Rspam-User: X-Stat-Signature: 7mumbzkzbj4cu568qqpyej1j4uyq5iq3 X-Rspamd-Server: rspam03 X-HE-Tag: 1692848976-620092 X-HE-Meta: U2FsdGVkX1/5fHodna1g/EMXkHRf/uhvCLQBSu8j2psDjrfDIR8pn0zGy6MgMvP9w7g/Q7XYHrYyHGOntqPTaawR91f10QEzpGaiDnXUEHPxdATLB02S5xpiBrbEYPB5H0IaY3c7bHl3Uzw2PHLRoGsdbCB/iK1dctno+xAxvabm8ZxJaACMJCK3tURhGE0TeOHtQAixrPIRpgbPC+dxYsiRtk0hvnI7JiK+edkEtbtNCN+GckjThikR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NTTXiH/yPbBPvFOudo28f+50BRt69p9VllZKpIhroRZ55JcgpeOaUuw5JbFeY7Lxz2WL1ENw+jNs9 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Now no users are using the old APIs, just remove them. Signed-off-by: Qi Zheng Reviewed-by: Muchun Song --- include/linux/shrinker.h | 8 --- mm/shrinker.c | 143 --------------------------------------- 2 files changed, 151 deletions(-) diff --git a/include/linux/shrinker.h b/include/linux/shrinker.h index 3f3fd9974ce5..025c8070dd86 100644 --- a/include/linux/shrinker.h +++ b/include/linux/shrinker.h @@ -103,14 +103,6 @@ struct shrinker *shrinker_alloc(unsigned int flags, const char *fmt, ...); void shrinker_register(struct shrinker *shrinker); void shrinker_free(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 __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); - #ifdef CONFIG_SHRINKER_DEBUG extern int __printf(2, 3) shrinker_debugfs_rename(struct shrinker *shrinker, const char *fmt, ...); diff --git a/mm/shrinker.c b/mm/shrinker.c index 36711c5c01f9..a27779ed3798 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -650,146 +650,3 @@ void shrinker_free(struct shrinker *shrinker) kfree(shrinker); } EXPORT_SYMBOL_GPL(shrinker_free); - -/* - * Add a shrinker callback to be called from the vm. - */ -static int __prealloc_shrinker(struct shrinker *shrinker) -{ - unsigned int size; - int err; - - if (shrinker->flags & SHRINKER_MEMCG_AWARE) { - err = prealloc_memcg_shrinker(shrinker); - if (err != -ENOSYS) - return err; - - shrinker->flags &= ~SHRINKER_MEMCG_AWARE; - } - - size = sizeof(*shrinker->nr_deferred); - if (shrinker->flags & SHRINKER_NUMA_AWARE) - size *= nr_node_ids; - - shrinker->nr_deferred = kzalloc(size, GFP_KERNEL); - if (!shrinker->nr_deferred) - return -ENOMEM; - - 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); - shrinker->name = NULL; - } - - 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); - shrinker->name = NULL; -#endif - if (shrinker->flags & SHRINKER_MEMCG_AWARE) { - down_write(&shrinker_rwsem); - unregister_memcg_shrinker(shrinker); - up_write(&shrinker_rwsem); - return; - } - - kfree(shrinker->nr_deferred); - shrinker->nr_deferred = NULL; -} - -void register_shrinker_prepared(struct shrinker *shrinker) -{ - down_write(&shrinker_rwsem); - list_add_tail(&shrinker->list, &shrinker_list); - shrinker->flags |= SHRINKER_REGISTERED; - shrinker_debugfs_add(shrinker); - up_write(&shrinker_rwsem); -} - -static int __register_shrinker(struct 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); - shrinker->name = NULL; - } - return err; -} -#else -int register_shrinker(struct shrinker *shrinker, const char *fmt, ...) -{ - return __register_shrinker(shrinker); -} -#endif -EXPORT_SYMBOL(register_shrinker); - -/* - * Remove one - */ -void unregister_shrinker(struct shrinker *shrinker) -{ - struct dentry *debugfs_entry; - int debugfs_id; - - if (!(shrinker->flags & SHRINKER_REGISTERED)) - return; - - down_write(&shrinker_rwsem); - list_del(&shrinker->list); - shrinker->flags &= ~SHRINKER_REGISTERED; - if (shrinker->flags & SHRINKER_MEMCG_AWARE) - unregister_memcg_shrinker(shrinker); - debugfs_entry = shrinker_debugfs_detach(shrinker, &debugfs_id); - up_write(&shrinker_rwsem); - - shrinker_debugfs_remove(debugfs_entry, debugfs_id); - - kfree(shrinker->nr_deferred); - shrinker->nr_deferred = NULL; -} -EXPORT_SYMBOL(unregister_shrinker);