From patchwork Thu Jun 3 01:09:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 12295959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70F29C4708F for ; Thu, 3 Jun 2021 01:09:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17110613F1 for ; Thu, 3 Jun 2021 01:09:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17110613F1 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E83576B0071; Wed, 2 Jun 2021 21:09:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CEF566B0074; Wed, 2 Jun 2021 21:09:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACCB26B0072; Wed, 2 Jun 2021 21:09:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 621096B0071 for ; Wed, 2 Jun 2021 21:09:44 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 067FE181AC9C6 for ; Thu, 3 Jun 2021 01:09:44 +0000 (UTC) X-FDA: 78210630288.14.9DFFDFA Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf24.hostedemail.com (Postfix) with ESMTP id 4EDB1A000241 for ; Thu, 3 Jun 2021 01:09:30 +0000 (UTC) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.43/8.16.0.43) with SMTP id 15316He5030071 for ; Wed, 2 Jun 2021 18:09:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=3MmMITvsDJqzOtppii3pb1p4qWk7gOuagZYy/UljbZk=; b=P+D+QmlORztjqeRt+nakU/0dqKMUUESzj2heogjDC+/wv/ep67qGh+UC0zUm3IpqnlQH IhIzdAWeS8NXWthAHNgLjbguruky+8J7dXrBt+YNQ3oTqlKJGq+V6Jo3COfqANMPwl3/ rNH4jQBjtrzBsj2oO1Klb7X4tV0Xzg53d0U= Received: from mail.thefacebook.com ([163.114.132.120]) by m0089730.ppops.net with ESMTP id 38xby4bnw9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 02 Jun 2021 18:09:42 -0700 Received: from intmgw001.46.prn1.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:21d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 2 Jun 2021 18:09:40 -0700 Received: by devvm3388.prn0.facebook.com (Postfix, from userid 111017) id C9DE97F1B341; Wed, 2 Jun 2021 18:09:32 -0700 (PDT) From: Roman Gushchin To: Dennis Zhou CC: Tejun Heo , Christoph Lameter , Andrew Morton , Vlastimil Babka , , , Roman Gushchin Subject: [PATCH v2 1/3] mm, memcg: mark cgroup_memory_nosocket, nokmem and noswap as __ro_after_init Date: Wed, 2 Jun 2021 18:09:29 -0700 Message-ID: <20210603010931.1472512-2-guro@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210603010931.1472512-1-guro@fb.com> References: <20210603010931.1472512-1-guro@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: jTjxYeirIoc7Jlyp0r0fgoX6rchN3PgM X-Proofpoint-GUID: jTjxYeirIoc7Jlyp0r0fgoX6rchN3PgM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-06-02_11:2021-06-02,2021-06-02 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 spamscore=0 clxscore=1015 bulkscore=0 mlxlogscore=910 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106030006 X-FB-Internal: deliver Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=fb.com header.s=facebook header.b=P+D+QmlO; spf=pass (imf24.hostedemail.com: domain of "prvs=578884e26b=guro@fb.com" designates 67.231.153.30 as permitted sender) smtp.mailfrom="prvs=578884e26b=guro@fb.com"; dmarc=pass (policy=reject) header.from=fb.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 4EDB1A000241 X-Stat-Signature: 6ea97mrzsd89buz5nwh19i985wqwzkg9 X-HE-Tag: 1622682570-225686 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: cgroup_memory_nosocket, cgroup_memory_nokmem and cgroup_memory_noswap are initialized during the kernel initialization and never change their value afterwards. cgroup_memory_nosocket, cgroup_memory_nokmem are written only from cgroup_memory(), which is marked as __init. cgroup_memory_noswap is written from setup_swap_account() and mem_cgroup_swap_init(), both are marked as __init. Mark all three variables as __ro_after_init. Signed-off-by: Roman Gushchin --- mm/memcontrol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e064ac0d850a..e6203ee24a11 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -80,14 +80,14 @@ struct mem_cgroup *root_mem_cgroup __read_mostly; DEFINE_PER_CPU(struct mem_cgroup *, int_active_memcg); /* Socket memory accounting disabled? */ -static bool cgroup_memory_nosocket; +static bool cgroup_memory_nosocket __ro_after_init; /* Kernel memory accounting disabled? */ -static bool cgroup_memory_nokmem; +static bool cgroup_memory_nokmem __ro_after_init; /* Whether the swap controller is active */ #ifdef CONFIG_MEMCG_SWAP -bool cgroup_memory_noswap __read_mostly; +bool cgroup_memory_noswap __ro_after_init; #else #define cgroup_memory_noswap 1 #endif