From mboxrd@z Thu Jan 1 00:00:00 1970 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 83530C433F5 for ; Sun, 20 Feb 2022 11:40:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A55556B0072; Sun, 20 Feb 2022 06:40:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A03866B0073; Sun, 20 Feb 2022 06:40:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F23E6B0074; Sun, 20 Feb 2022 06:40:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 802826B0072 for ; Sun, 20 Feb 2022 06:40:23 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2EDA2226DF for ; Sun, 20 Feb 2022 11:40:23 +0000 (UTC) X-FDA: 79162965126.03.D3223CC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 4DC4840002 for ; Sun, 20 Feb 2022 11:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=rVtuU6Hrq8wCtIw10ZxltjmyN+GjMD3/PKda00/vg6g=; b=QyunQTIbhs6QyM/MNE8tIOZ8NR 8J9x7GNbtnqtEjiwN8tVwwtFQuoCUzqM472l1PRDW2oAUV3vngMml03D9suwj/LOHiOH9x7puHW0x EJdvx2+H+CG6jDZkS9WYca4c6rqDypdYOzq9g5a1MYxB9N4dDROK5iaFBrJz3RzZve2U2x+KD9RzH ezIIkD+cpqa1dd+A1vpj6a4Bxd8+XkzbaPQh37kW0OliuSDj/2wJ4M0+zNm+ECzZaMX53qu8JPMh7 J1jP5PRzIxb9WgDWq1jybO4BqplW8EHCi53BvpNeTjvmE/HXr5HKMXyiT8GFppa4U1LvZ5lt1esGP chMITAWw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nLkZN-000oj8-5z; Sun, 20 Feb 2022 11:40:01 +0000 Date: Sun, 20 Feb 2022 11:40:01 +0000 From: Matthew Wilcox To: tangmeng Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, nizhen@uniontech.com, zhanglianjie@uniontech.com, nixiaoming@huawei.com Subject: Re: [PATCH 10/11] fs/drop_caches: move drop_caches sysctls to its own file Message-ID: References: <20220220060626.15885-1-tangmeng@uniontech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220220060626.15885-1-tangmeng@uniontech.com> X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QyunQTIb; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 4DC4840002 X-Stat-Signature: mn46df4qx9rxj35h9dafutibqmyhq4mk X-HE-Tag: 1645357222-117412 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: On Sun, Feb 20, 2022 at 02:06:26PM +0800, tangmeng wrote: > diff --git a/fs/drop_caches.c b/fs/drop_caches.c > @@ -75,3 +75,25 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, > } > return 0; > } > + > +#ifdef CONFIG_SYSCTL fs/Makefile has: obj-$(CONFIG_SYSCTL) += drop_caches.o so we don't need this ifdef. > +static struct ctl_table vm_drop_caches_table[] = { > + { > + .procname = "drop_caches", > + .data = &sysctl_drop_caches, > + .maxlen = sizeof(int), > + .mode = 0200, > + .proc_handler = drop_caches_sysctl_handler, > + .extra1 = SYSCTL_ONE, > + .extra2 = SYSCTL_FOUR, > + }, > + { } > +}; Something which slightly concerns me about this sysctl splitup (which is obviously the right thing to do) is that ctl_table is quite large (64 bytes per entry) and every array is terminated with an empty one. In this example, we've gone from 64 bytes to 128 bytes. Would we be better off having a register_sysctl_one() which registers exactly one ctl_table, rather than an array? And/or a register_sysctl_array() which takes an ARRAY_SIZE() of its argument instead of looking for the NULL terminator?