From patchwork Mon Sep 11 09:44:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qi Zheng X-Patchwork-Id: 13379115 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 A316BEE57DF for ; Mon, 11 Sep 2023 09:51:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 459046B0261; Mon, 11 Sep 2023 05:51:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40A2B6B0266; Mon, 11 Sep 2023 05:51:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D18A6B0269; Mon, 11 Sep 2023 05:51:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 1ED0C6B0261 for ; Mon, 11 Sep 2023 05:51:10 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id ECE95C02D9 for ; Mon, 11 Sep 2023 09:51:09 +0000 (UTC) X-FDA: 81223848258.06.CFC971C Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf17.hostedemail.com (Postfix) with ESMTP id 2A1814001C for ; Mon, 11 Sep 2023 09:51:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=kNh1kkMy; spf=pass (imf17.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 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=1694425868; 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=Fa9xv5O6zRN9YujHabqvlTbDnEkmHba3eF7bPn48dFs=; b=NiIYl8AikasUNSRTHyVjVKDUwr1SnV9qocBfeZD60QlNe69oCE1n3x/l+FDQlEeT+qnXQg 6EcNbj1WzW9RdkTMWO8Z4SuJv6qa59lacELWIH8Qu9jwNJXMCWRGurf5RlNYEFT0DY9V/q u/BOZoOJnqiaArXcTC+AxP5QQXC/YWU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694425868; a=rsa-sha256; cv=none; b=wlsw9mcJ1jynSKQavXHMHYbZBLx5d1cdtL3OShSt2s6wTH1Sh1N8bmw5iTqFBZT3kNrlgc QNoGEWJ2uwPFvm9x2Z6pzlF4K6nWJ0Buk+A84vZN/tPdS4QMUejgJQWSee/w+D9Dts/E2Q pTJEtT4UQCLBivuCz1KPq3Q3pKWsTMc= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=kNh1kkMy; spf=pass (imf17.hostedemail.com: domain of zhengqi.arch@bytedance.com designates 209.85.214.181 as permitted sender) smtp.mailfrom=zhengqi.arch@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1bf7b5e1f06so7714275ad.0 for ; Mon, 11 Sep 2023 02:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1694425867; x=1695030667; darn=kvack.org; 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=Fa9xv5O6zRN9YujHabqvlTbDnEkmHba3eF7bPn48dFs=; b=kNh1kkMyxaWdSUYzEfHAd31ima8lwkvgP05vO/qmt0RPDwl6rhbrXznc6ddWt2BVlW YItXPBjUHAq9eqJAF3/t6Wteo4Mv5TD+naZ4pha5pPU4FkSv+kJbuqvjtoO7wHy/wych +9bXUfXoU8Cuz68FYOQz8Wsoq2pJ2SyOyLP7CIKM2modIUwwZsvr13Qxsbtk5xB6+Z8o 3i0FHVRYF7pNE46S5GhSncFkITcEGEO/irZcmxBK40XSlBatqZgQqVXXMQxZoCSOsUaF 9bKMVYdR1QxkJqB+yPbH2TkrPG5piNs2V1Dm1xhk/Gd8xICxR/1STlxPgYnOMM0+NFnx H8wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694425867; x=1695030667; 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=Fa9xv5O6zRN9YujHabqvlTbDnEkmHba3eF7bPn48dFs=; b=w+DnpO+dgjcby7kkFlBJ3kzqVS0hK/HGyYWI4HU6sAzxgZ6x1+brbj+nIVUO2JV7c1 otpuzzE/AB6y+wanb/j/gcwosIXAad5LYpoXNagIZL87ZUkPwq3rfLIJ9F+wo+Tw3+LP YoaS2/YIexg0E8rJOzWTtdPAZgz+u5/nkia9s9QfgHErZzUR1EudwbCtyzHEHgVCFm7O p4PTXDlSTCMUIKrF9UT5TARRe+LfCsGkDfEaK2pUVZHrxGhGzPofmbj77yqpld7qgfZF VZBVkZnHSG4uZMctSc5hF7pOAU0EUprrk4wVaUFoC9atCiu8PeXZHzfP0S7po12xgUkg 9ZLQ== X-Gm-Message-State: AOJu0YyZbvrNv5uVOzDZejebuY1I3VPR0Gr1cIxbjL9jFPKVGHbstFlK ZZhh0qMce9kkrlP/eEls6WjOOA== X-Google-Smtp-Source: AGHT+IHGQbme9+SUFaGqtXxW3dpwxnbADbFKKzuXkjeBXh8SM/R1CUkQJ1X6e1o6BdROvLlqkFtmJw== X-Received: by 2002:a17:902:e5c1:b0:1b3:d8ac:8db3 with SMTP id u1-20020a170902e5c100b001b3d8ac8db3mr11070242plf.6.1694425867096; Mon, 11 Sep 2023 02:51:07 -0700 (PDT) Received: from C02DW0BEMD6R.bytedance.net ([203.208.167.146]) by smtp.gmail.com with ESMTPSA id az7-20020a170902a58700b001bdc2fdcf7esm5988188plb.129.2023.09.11.02.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 02:51:06 -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 v6 39/45] mm: shrinker: remove old APIs Date: Mon, 11 Sep 2023 17:44:38 +0800 Message-Id: <20230911094444.68966-40-zhengqi.arch@bytedance.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20230911094444.68966-1-zhengqi.arch@bytedance.com> References: <20230911094444.68966-1-zhengqi.arch@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2A1814001C X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: h66uutomg59ijmmcycbc3efwyp43yb1c X-HE-Tag: 1694425867-527177 X-HE-Meta: U2FsdGVkX180it09w7xQZpOEkDTyc/ZXcGtyjLJb30ZiuihnXgSlNr2cClKJvtb905gHmWzTZlXfd6l9sGaeByGAmkeYEElW4h/3s32eRQ8sON1DB7f5cfPPN1DCrtweNVIHAuER0ms9J4KgsRrdR2Dp+mVPhZK9OBe9suug2NHLFfvmgwr4Z7fWcvIFvGv2BmrG3KHhkyAjUYN5d7ac3uB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9ADeUHLCDHHM3LmVeFOYRhHvxOfH+CoqtkHttvB7urpyO8X+Oahw0be/ODjLqgGKj0vM15FanADVOi4uuBDx50YmooG8rlkDhyJMYYSIFxOzxQ9PG3LlsXjjZuw 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 201211a67827..d75be41b8a5f 100644 --- a/mm/shrinker.c +++ b/mm/shrinker.c @@ -651,146 +651,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);