From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,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 65F4DC28CBC for ; Wed, 6 May 2020 23:14:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2E7F42068E for ; Wed, 6 May 2020 23:14:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E7F42068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB75F900002; Wed, 6 May 2020 19:13:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B40A68E0003; Wed, 6 May 2020 19:13:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0895900002; Wed, 6 May 2020 19:13:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0142.hostedemail.com [216.40.44.142]) by kanga.kvack.org (Postfix) with ESMTP id 852AC8E0003 for ; Wed, 6 May 2020 19:13:59 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 45E75499605 for ; Wed, 6 May 2020 23:13:59 +0000 (UTC) X-FDA: 76787848998.24.toys27_7a195b44a9320 X-HE-Tag: toys27_7a195b44a9320 X-Filterd-Recvd-Size: 3989 Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Wed, 6 May 2020 23:13:58 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id f6so1761654pgm.1 for ; Wed, 06 May 2020 16:13:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yNC3GM3ywGXGoZzk8/YUTPNRyoicVYswjVnBQiUzaYs=; b=doHXEED+hCH+moZaO9t1bH+5AR/YDYBwgw7cO3ko4hoGOCZhm1qyo6+ed/qcjeps0D xj+AFHzWYypec8HFpe5btEi3mCO7DKDd+S7Hai6gMqSX0GXoYI/t5ev2oK6Jni3/mlCA 6gw2gbWH3Q/sw1dkxs5Kh86OK2wLpdcA8h7lZ/8xLztQWWVFrK7+bwsnrAjfoCseK6XI c/Dg2l0n5IOkNJw70SOoGst9hakgC/yzi1TYRtNaBFze4YCWlysw2CW0ZfM8GxHw60TW wro+MZrFO1M0Er7uAsVS8FrMefbcdFZyYmwFVLmQl/6NmSlozq1dLUCIIw+TQUTctOfJ xdAQ== X-Gm-Message-State: AGi0Pua3W8vPtOFqn9ClyLnWh39fkDJXwll7Z1y4VdTX4mc4X4nBEObL UGeXF5DiFiLAUb1sxAGOgQU= X-Google-Smtp-Source: APiQypI1cZz5e5aUdny1xt+BmLGd0u9WZ/XOxzZEhrSJwWx5Olumva6WOJu2WNhYATPEGbj5pYvHsA== X-Received: by 2002:a62:1994:: with SMTP id 142mr180656pfz.259.1588806837760; Wed, 06 May 2020 16:13:57 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id f6sm2924188pfn.189.2020.05.06.16.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 16:13:56 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 505C5403EA; Wed, 6 May 2020 23:13:55 +0000 (UTC) From: Luis Chamberlain To: cl@linux.com, akpm@linux-foundation.org Cc: arnd@arndb.de, willy@infradead.org, aquini@redhat.com, keescook@chromium.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH] mm: expland documentation over __read_mostly Date: Wed, 6 May 2020 23:13:53 +0000 Message-Id: <20200506231353.32451-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: __read_mostly can easily be misused by folks, its not meant for just read-only data. There are performance reasons for using it, but we also don't provide any guidance about its use. Provide a bit more guidance over it use. Acked-by: Christoph Lameter Signed-off-by: Luis Chamberlain --- I sent this 2 years ago, but it fell through the cracks. This time I'm adding Andrew Morton now, the fix0r-of-falling-through-the-cracks. Resending as I just saw a patch which doesn't clearly justifiy the merits of the use of __read_mostly on it. include/linux/cache.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/cache.h b/include/linux/cache.h index 750621e41d1c..8106fb304fa7 100644 --- a/include/linux/cache.h +++ b/include/linux/cache.h @@ -15,8 +15,14 @@ =20 /* * __read_mostly is used to keep rarely changing variables out of freque= ntly - * updated cachelines. If an architecture doesn't support it, ignore the - * hint. + * updated cachelines. Its use should be reserved for data that is used + * frequently in hot paths. Performance traces can help decide when to u= se + * this. You want __read_mostly data to be tightly packed, so that in th= e + * best case multiple frequently read variables for a hot path will be n= ext + * to each other in order to reduce the number of cachelines needed to + * execute a critial path. We should be mindful and selective of its use= . + * ie: if you're going to use it please supply a *good* justification in= your + * commit log */ #ifndef __read_mostly #define __read_mostly --=20 2.25.1