From patchwork Wed Oct 11 18:24:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 151522 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp732935vqb; Wed, 11 Oct 2023 11:24:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzm12mOMtfFvaYPOr68sONJ8TA3HJnAbqVzZsdmEQyjnzUbtuHQnhnloLwiZ9VuJFLa9z5 X-Received: by 2002:a05:6602:2e84:b0:79f:8cd3:fd0e with SMTP id m4-20020a0566022e8400b0079f8cd3fd0emr27873664iow.1.1697048687276; Wed, 11 Oct 2023 11:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697048687; cv=none; d=google.com; s=arc-20160816; b=sBcHD24HHxFhvpczPNggBdiwLB3rE7+5/Es9Vxe+36sv5GcsIi3PeWyPq4capFTdiW Pg2o6NmdpbigRhV1GfncLAPl2WkhUOFYUUWS13rWBDO1zPW1Z4HZ1pW6wQjTZxJfguD2 PGqeymCIDx3uh6Uf1g4zDV9Mm3KChnEGexg5bD7/KnpbTuBKlj1xWhM7rA4fdGo4i/yP nn7gW60K7fkoh3Vs4LDDqKIbbgX8dVMrqlCUBTWbGt0qXL6cVn3DQEhFDEBeJRPor3BO Oo1VyvvQedgpgdUZjYe0IjQvQ/1rL/9od81JX+zcvV9U4UNSPX527yg8mEDpcYmG6MLl amcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=dhigiG7r2vYGCxl5bErW87uWnRuAFN/RI/oKaHTvtWo=; fh=A7ZOXinL+UTz0cvNWeKUfpIYR5g4GYY0QYDO/9nUDzA=; b=XbwGIvvDHLbbaOrv8iPlyMbPMaWY3psTYWU/MVCTZWx4prGi5Pu3uRsyJODn0Ll9SX hQizK7qReyut7luNFPBEurLPOIp10qd5ZfSqCKTvue/rQQax8NClwIpXm5ITdovdRZSL 1wLH9hsmDUZw0xGkGZFyHCahltEZSqDOInfA7RUhFcy7QPqRcYf9m7S13O2l0UUBHUjq tBv4jYOfogJri+qzZnyNKnvd+lLGwruUbSd7j5sF3emOUGIFb1xfYUNYgc+2x5Qg3BnK 6Zo3wa6i9yBa78uG+ySeiwYlcHvLQaGaHDrUgjQRrvvYMjMRJ4DJuKLL+ZioffNv8GrC 7NOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z2atiAmx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id b5-20020a655785000000b00577680ccf1bsi294838pgr.709.2023.10.11.11.24.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:24:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Z2atiAmx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 2F0CD8198004; Wed, 11 Oct 2023 11:24:45 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234887AbjJKSY3 (ORCPT + 18 others); Wed, 11 Oct 2023 14:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233077AbjJKSY1 (ORCPT ); Wed, 11 Oct 2023 14:24:27 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E6A09E for ; Wed, 11 Oct 2023 11:24:25 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-522bd411679so331664a12.0 for ; Wed, 11 Oct 2023 11:24:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697048664; x=1697653464; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=dhigiG7r2vYGCxl5bErW87uWnRuAFN/RI/oKaHTvtWo=; b=Z2atiAmxDdFFn0tHYBnyNwVv9ppdGm3cDltOTI2JurVWQGyGUso/sRWCtA9N51Vg2m gkleRHdZ/BH7YoPAPMKPguK2NC3iny7ugCUgQAdX6tcH2vt+iUz3b/zY/iZNyK17k7Z1 cDzeo979dd65pE450Jqw5Mymmf/nlpBL8XI7Phz9rnOFQ+I7cg+sh0KTNma+/ippTooq b+HsX1xKTxy58EzFnTUCx6cQWAWFBli928YxEdOzU/eIb4/K17c0tjE13cg10QTkMKPs 7bfqBLye7iB2w0IfpDYgsPzI5lMgA4io1NYnvKYS5TVHsSLrfahuW8Q2S8kWEf5mmRhQ PMfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697048664; x=1697653464; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dhigiG7r2vYGCxl5bErW87uWnRuAFN/RI/oKaHTvtWo=; b=rdOckAMvpPovBf7iUEwv+3is8fr2VzDF5PiISAjdcChF0lm3ygk7t8ShwH78tgNZ/+ botPD9/QuCOkayz+N2ji6KWFzB9FJ28s7x4VYuWvo+dvsWGY6J8CtKkMFV29L46gyTOU CFOlP+Zv5QUgZ9MPYk5oAiliw325mCpC58rjVnkZfIZYeEVQ6T8Yrs4TAkhWwphpIqCX 3ZE3MfkNLr+TN+eaaYoYTSeJcoPFKRJS07EZZIgrcxzc6sPSFUBZk1n8dAXpVtDsh3o4 oF8eNcc8tHaxUFm2JYZTel+VTnw80t2vTfv+wUYSc7Ym9r3iKlINfC9FfSZAoHFEbl4e b2ow== X-Gm-Message-State: AOJu0YzCBQp9o63JB3i4J3DoUXkiQtw39QU6267+H6M6aOzr3i3EUzzs oi6DVCF2ROM6HORd9kkUgA== X-Received: by 2002:a05:6402:b89:b0:53d:eca8:8775 with SMTP id cf9-20020a0564020b8900b0053deca88775mr1359175edb.26.1697048663739; Wed, 11 Oct 2023 11:24:23 -0700 (PDT) Received: from p183 ([46.53.254.83]) by smtp.gmail.com with ESMTPSA id j18-20020a508a92000000b0053deb97e8e6sm733724edj.28.2023.10.11.11.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 11:24:23 -0700 (PDT) Date: Wed, 11 Oct 2023 21:24:21 +0300 From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH] fs: move and constify sysctl_nr_open_min, sysctl_nr_open_max Message-ID: <02591c1e-936b-46bf-ad2b-402b33338eee@p183> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 11 Oct 2023 11:24:45 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779484524129520768 X-GMAIL-MSGID: 1779484524129520768 sysctl_nr_open_min, sysctl_nr_open_max variables are really hard limits on fs.nr_open sysctl, they aren't interesting to the rest of the code and are constants (sysctl_nr_open is not constant obviously). Signed-off-by: Alexey Dobriyan --- fs/file.c | 5 ----- fs/file_table.c | 10 ++++++++-- include/linux/file.h | 2 -- 3 files changed, 8 insertions(+), 9 deletions(-) --- a/fs/file.c +++ b/fs/file.c @@ -25,11 +25,6 @@ #include "internal.h" unsigned int sysctl_nr_open __read_mostly = 1024*1024; -unsigned int sysctl_nr_open_min = BITS_PER_LONG; -/* our min() is unusable in constant expressions ;-/ */ -#define __const_min(x, y) ((x) < (y) ? (x) : (y)) -unsigned int sysctl_nr_open_max = - __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG; static void __free_fdtable(struct fdtable *fdt) { --- a/fs/file_table.c +++ b/fs/file_table.c @@ -111,6 +111,12 @@ static int proc_nr_files(struct ctl_table *table, int write, void *buffer, return proc_doulongvec_minmax(table, write, buffer, lenp, ppos); } +static const unsigned int sysctl_nr_open_min = BITS_PER_LONG; +/* our min() is unusable in constant expressions ;-/ */ +#define __const_min(x, y) ((x) < (y) ? (x) : (y)) +static const unsigned int sysctl_nr_open_max = + __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG; + static struct ctl_table fs_stat_sysctls[] = { { .procname = "file-nr", @@ -134,8 +140,8 @@ static struct ctl_table fs_stat_sysctls[] = { .maxlen = sizeof(unsigned int), .mode = 0644, .proc_handler = proc_dointvec_minmax, - .extra1 = &sysctl_nr_open_min, - .extra2 = &sysctl_nr_open_max, + .extra1 = (void *)&sysctl_nr_open_min, + .extra2 = (void *)&sysctl_nr_open_max, }, { } }; --- a/include/linux/file.h +++ b/include/linux/file.h @@ -113,6 +113,4 @@ int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags); extern void flush_delayed_fput(void); extern void __fput_sync(struct file *); -extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max; - #endif /* __LINUX_FILE_H */