From patchwork Fri Mar 18 10:07:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12785127 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 D4BCBC433FE for ; Fri, 18 Mar 2022 10:09:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 707558D0006; Fri, 18 Mar 2022 06:09:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B69D8D0001; Fri, 18 Mar 2022 06:09:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57EAA8D0006; Fri, 18 Mar 2022 06:09:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0226.hostedemail.com [216.40.44.226]) by kanga.kvack.org (Postfix) with ESMTP id 4A20D8D0001 for ; Fri, 18 Mar 2022 06:09:26 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 06F3B18128B0A for ; Fri, 18 Mar 2022 10:09:26 +0000 (UTC) X-FDA: 79257084732.17.08D0EF9 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf11.hostedemail.com (Postfix) with ESMTP id 9402E40009 for ; Fri, 18 Mar 2022 10:09:25 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id 6so4734027pgg.0 for ; Fri, 18 Mar 2022 03:09:25 -0700 (PDT) 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=VeiakI6ZdfDqy26wAEKtPtiKSfYNO4Hqsr8Ua8hMV6s=; b=RDQVX1ZRVvaucfFOAP3mBrB+koiw+26bwZKvIYeeTs9vsVtInLLnzToEhxEYTdN3ut ktUd0StaxKeGjBvUjKB7VKrY/VDc3VFbPXOe0TGBIKu5UEG1v0lvtubKLYNMaa75In78 xcs7Or2qQHTGxd4TttERqtkqxUQlMfb5qHJkMA5Fp9fBFxYUU7uuu55o7C7GwZcjQsRQ DLsXM42iBnB84MxvsJvE9jmVZYgtVZiG02+14Twn5UBcdG2qUx6trWh2k2eZKX9PLq/G l4iQpMy3PEelpVzA5kUBnDvgDu0Gs0NYhJz+c5WRLndFcTXsyrArxFXPGyHUVfCAlJxg yv8g== 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=VeiakI6ZdfDqy26wAEKtPtiKSfYNO4Hqsr8Ua8hMV6s=; b=AEoQzD1wzM5d2/gxjnvv/51gPaFSHFfHxxKrHO9Th5gs+K4cRvfDekJ82/ZL2IpCOQ nnWA47QttrTUiJ2JtlY0QiiyDIPL4tskfWLaF5gilyijZEk5wyd/CqmaFkfdiWOM9O/S KBBe9LrbRXkB7PHz1seool8H63rF1qlzavMNl5bJIgq2VArj3C/ITbAnDEajBsTWonJe IeIhZVN+Knum8xkvtb7cwyrN640ngoUKoa/8I3mJqGHsOcZEdPn3EhVsnIy/J83ynGoP SAEVkKgwG7Wbh20yNSF2yTLyXM180sdiZ2RQSv/v05R1EVaPwGQx1y95nfLKvgNF3gdS QbsA== X-Gm-Message-State: AOAM533EVmSGBsvMtaruEESRgD7JWUnQt3JWb19a/e2fQiMLoV90cIZG RZHrPN9fz+YNsxaJKskfWxJKNQ== X-Google-Smtp-Source: ABdhPJxCCJnh1IXzUQpPAo1+tedl1QUehfYAAocuezbBd0A4UaNgvcR+Z92fhQTN/b1bZhBXA8y/uw== X-Received: by 2002:a65:418b:0:b0:382:250b:4dda with SMTP id a11-20020a65418b000000b00382250b4ddamr3508780pgq.428.1647598164788; Fri, 18 Mar 2022 03:09:24 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.241]) by smtp.gmail.com with ESMTPSA id j3-20020a056a00234300b004fa042e8216sm9541252pfj.2.2022.03.18.03.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Mar 2022 03:09:24 -0700 (PDT) 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 v4 3/4] sysctl: allow to set extra1 to SYSCTL_ONE Date: Fri, 18 Mar 2022 18:07:19 +0800 Message-Id: <20220318100720.14524-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220318100720.14524-1-songmuchun@bytedance.com> References: <20220318100720.14524-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 9402E40009 X-Stat-Signature: hw5q5sjnk5gk5hiq4rutdp8bz7zpofhj Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=RDQVX1ZR; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf11.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.215.181 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspam-User: X-HE-Tag: 1647598165-296062 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 770d5f7c7ae4..1e89c3e428ad 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1638,7 +1638,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, };