From patchwork Wed Mar 30 15:37:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12796034 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 61E11C433FE for ; Wed, 30 Mar 2022 15:38:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F13F58D0001; Wed, 30 Mar 2022 11:38:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC3B76B0078; Wed, 30 Mar 2022 11:38:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D649B8D0001; Wed, 30 Mar 2022 11:38:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0155.hostedemail.com [216.40.44.155]) by kanga.kvack.org (Postfix) with ESMTP id C961A6B0075 for ; Wed, 30 Mar 2022 11:38:38 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 81613A45D6 for ; Wed, 30 Mar 2022 15:38:38 +0000 (UTC) X-FDA: 79301459916.19.8240ABC Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf26.hostedemail.com (Postfix) with ESMTP id 104F9140010 for ; Wed, 30 Mar 2022 15:38:37 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id g9-20020a17090ace8900b001c7cce3c0aeso200546pju.2 for ; Wed, 30 Mar 2022 08:38:37 -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=nrS6qOjHi3EhirqIG6pDj0g4N09YKZLwksyGxAsNeS5zL69Y2hwg/RfRuCxzrUtxYl v7jQN4L85S48zZt4kac2+icIhFRUUxt7mMBo1eL+aynzkPZtu/RdgQkVfX6e1FT5rbk0 qbCzDVoGSMEsX2SgJ0bM2JCSlsPYBypGz/DZLvhCFT6uOPlbNB1yIi8S//burANkm550 iP1jWXu0vst/oHtGxCzZUjgDpC0OOlqglIlFR3wWARtJQ1KSAVOpYTv1tK2TNUOx3kvI xQuzHjcx3IdHCGQJ4FJ2eBVgrthM2ZABheWSIccFndfxGfNeE+1uV2UiV3xa1hSIA56t bGcA== 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=cgRMFg3ndvDR+cxEms74xHgcjedeiIo8MsXKjJqhTjS8ijcUJd9yG12194cUiVDQtR GBt6sviGRO5JziCOdxZMpDE7ldN5YiP8ayEEZ3CNyGYoTW4CJNfQ8mxpEM71Gfs55kEZ W+g4DeA0d3XsbRDL9jo1AX9/E18SEfwgwd3rf79bBb3cxXUXtuR7mvC9ZTYX+ddxeS2S l4YmVr50NYzCQYnMgQkmdq+mYqJ0myzKPEFLhlH6y0iB9GoFEJnS/ueVJbxnQNKKe0Z6 ryj6f2EJ91iC7pk7p3K3TIZ4o+Da3AqnSLhk3DchqwwrLUuxwnzZQXdr/JeEPUq5jaQP uSkQ== X-Gm-Message-State: AOAM533Y1E90C+SD3wy+m8CZFBUs8xCy8FBxZF72c2pw8syLEJH9yl+D wvBS1L4AaYbtejNB2YGun2wEKA== X-Google-Smtp-Source: ABdhPJxYsUVAVVFAUKw0isQyNo9pKj3eD+47hgdFaTL8oWHpFu17OySjpRL49cBEu4QmAaAEKUAozQ== X-Received: by 2002:a17:90b:504:b0:1c7:3095:fd78 with SMTP id r4-20020a17090b050400b001c73095fd78mr6449pjz.142.1648654717088; Wed, 30 Mar 2022 08:38:37 -0700 (PDT) Received: from FVFYT0MHHV2J.bytedance.net ([139.177.225.239]) by smtp.gmail.com with ESMTPSA id y8-20020a17090aa40800b001c6ccb2c395sm6686039pjp.9.2022.03.30.08.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 08:38:36 -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, masahiroy@kernel.org 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 v6 3/4] sysctl: allow to set extra1 to SYSCTL_ONE Date: Wed, 30 Mar 2022 23:37:44 +0800 Message-Id: <20220330153745.20465-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220330153745.20465-1-songmuchun@bytedance.com> References: <20220330153745.20465-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=nrS6qOjH; spf=pass (imf26.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 104F9140010 X-Stat-Signature: sb9pu5396uc83j9bmgua7we915ybgmgh X-HE-Tag: 1648654717-36485 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, };