From patchwork Mon Mar 7 13:07:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12771828 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 9D592C433F5 for ; Mon, 7 Mar 2022 13:08:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 361638D0006; Mon, 7 Mar 2022 08:08:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E7FA8D0001; Mon, 7 Mar 2022 08:08:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AFF18D0006; Mon, 7 Mar 2022 08:08:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 0D8348D0001 for ; Mon, 7 Mar 2022 08:08:54 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id BE08AA7994 for ; Mon, 7 Mar 2022 13:08:53 +0000 (UTC) X-FDA: 79217620146.22.3329473 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf25.hostedemail.com (Postfix) with ESMTP id 79B3AA0004 for ; Mon, 7 Mar 2022 13:08:53 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id mg21-20020a17090b371500b001bef9e4657cso13224962pjb.0 for ; Mon, 07 Mar 2022 05:08:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+FAEIk56iYrAuK3MHoOT3nS4Qb+vOqV2LEpPx2yYRAU=; b=UjMZLsDLy9mCu8/dtQDwPqLjHTvTyNUIOUo6ybj/xzbcbHacSb2nQwfeBr+B3BjPcl mohyYwuVC1tn5KlIMmCvbleNlC4A1Fqy4LrySAQwkwZSQe9FjDR1sWCmmtSbauF/HwNZ EVNiL4Qb7fq3FTb8DdjLQDlAguAnJg3sKhK56EShokt7xobJdH9+KVtKc9C+rBjCjMrO ZYS5+r69TrKsEbdZTSPTjFyqjZK1k0/Za0HblRZ3OGdsa+ZP/TRwR7fxfhFGqVf/7wkI ZmXJRV3/kro/+He81jlubfv0cCdqHlyx4ThM2Kc4/fr7cv+I3CJLI9CUKEApUNZO+k0A /Uaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+FAEIk56iYrAuK3MHoOT3nS4Qb+vOqV2LEpPx2yYRAU=; b=d0jivYjNOaPyItj0QvBUnhx8TEo0w5TxTg6eItv2kmvdI0Xzw8T+FDZZYir4tAAxKa 8UCAzlmE3LQdBck7QamFJPko+6xrzi/ZJ34aFXK9xEhcleZjq8zbtM98QKWFjw6MwPDs FLnUMURA0Jj82wtusKD1NtTO3FI69u+Spr2DPhajjuYp4+NYZB4MkVwjpEhMGMx6IXpd XBqEyjNmXX0lTYiKZKngA6NFmID3fIoZqWJwjmHixuffk/Sd/RcpsiHO5Nax5Pv0j26i 3i+AUfB0jApK3SGAtK84loA7+jhCc5BbedvazKOYijDZQiFldO6AOROy6LW/4UwkJkSh Kmlw== X-Gm-Message-State: AOAM533btpE+po7kJ9ZKEM+whcRHCKtEvK+xlZ1Ccq5vs+XoOhSTxXyb FV56ShSTAQeP9Pef87TUH28T7Q== X-Google-Smtp-Source: ABdhPJxq9zQCb9Rxmm8KdTGq3LEG09tBwTdNh4JsDI4M5Ye2wPb5suJqnSJDNrAzNc8BX+kYsp7OwQ== X-Received: by 2002:a17:902:ef4c:b0:14f:7548:dae3 with SMTP id e12-20020a170902ef4c00b0014f7548dae3mr11899068plx.92.1646658532607; Mon, 07 Mar 2022 05:08:52 -0800 (PST) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.245]) by smtp.gmail.com with ESMTPSA id x9-20020aa79409000000b004f704d33ca0sm3258528pfo.136.2022.03.07.05.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 05:08:52 -0800 (PST) From: Muchun Song To: corbet@lwn.net, mike.kravetz@oracle.com, akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, osalvador@suse.de, david@redhat.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com, Muchun Song Subject: [PATCH v3 3/4] sysctl: allow to set extra1 to SYSCTL_ONE Date: Mon, 7 Mar 2022 21:07:07 +0800 Message-Id: <20220307130708.58771-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220307130708.58771-1-songmuchun@bytedance.com> References: <20220307130708.58771-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 79B3AA0004 X-Stat-Signature: b4xgikqrfpokbfsbihxf7xjamd99gyaf X-Rspam-User: Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=UjMZLsDL; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf25.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam03 X-HE-Tag: 1646658533-117555 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: proc_do_static_key() does not consider the situation where a sysctl is only allowed to be enabled and cannot be disabled under certain circumstances since it set "->extra1" to SYSCTL_ZERO unconditionally. This patch add the functionality to set "->extra1" accordingly. Signed-off-by: Muchun Song --- kernel/sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 64065abf361e..ab3e9c937268 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1631,7 +1631,7 @@ int proc_do_static_key(struct ctl_table *table, int write, .data = &val, .maxlen = sizeof(val), .mode = table->mode, - .extra1 = SYSCTL_ZERO, + .extra1 = table->extra1 == SYSCTL_ONE ? SYSCTL_ONE : SYSCTL_ZERO, .extra2 = SYSCTL_ONE, };