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=-3.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 D9D11C433E0 for ; Tue, 9 Jun 2020 04:35:10 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E8A120812 for ; Tue, 9 Jun 2020 04:35:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="gnvPwY0r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8E8A120812 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 34E758D0026; Tue, 9 Jun 2020 00:35:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FD588D0011; Tue, 9 Jun 2020 00:35:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 23AAB8D0026; Tue, 9 Jun 2020 00:35:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id 0B00D8D0011 for ; Tue, 9 Jun 2020 00:35:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C3414180F3D92 for ; Tue, 9 Jun 2020 04:35:09 +0000 (UTC) X-FDA: 76908408738.15.idea07_1415de226dbf Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 9B265180F29DB for ; Tue, 9 Jun 2020 04:35:09 +0000 (UTC) X-HE-Tag: idea07_1415de226dbf X-Filterd-Recvd-Size: 3185 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 9 Jun 2020 04:35:09 +0000 (UTC) Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3CC7520884; Tue, 9 Jun 2020 04:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591677308; bh=oyOItwMvmuomcYbv8Ti7V3IhoY3Wgu5f6ee5yGmccuE=; h=Date:From:To:Subject:In-Reply-To:From; b=gnvPwY0rJ4ZL1qOI/Bd5krO9SN4cX/yHYyAJveMsdaTvFxC7OWpp7ait5RfnHdLVn r9dcjYEbxVSAcdmvTEYZhekKpJXsYJU3hVvKP4k18mwvPBraHxIBs698lPkcBvr2yM lEDlLYNruJHgz6Z9fvFZR/mt6MGZDdyYXrqIC9Fo= Date: Mon, 08 Jun 2020 21:35:07 -0700 From: Andrew Morton To: akpm@linux-foundation.org, aquini@redhat.com, arnd@arndb.de, cl@linux.com, keescook@chromium.org, linux-mm@kvack.org, mcgrof@kernel.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 93/93] include/linux/cache.h: expand documentation over __read_mostly Message-ID: <20200609043507.T5yqheABR%akpm@linux-foundation.org> In-Reply-To: <20200608212922.5b7fa74ca3f4e2444441b7f9@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 9B265180F29DB X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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: From: Luis Chamberlain Subject: include/linux/cache.h: expand documentation over __read_mostly __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 its use. Link: http://lkml.kernel.org/r/20200507161424.2584-1-mcgrof@kernel.org Signed-off-by: Luis Chamberlain Acked-by: Christoph Lameter Reviewed-by: Kees Cook Acked-by: Rafael Aquini Cc: Arnd Bergmann Cc: Matthew Wilcox Signed-off-by: Andrew Morton --- include/linux/cache.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/include/linux/cache.h~mm-expand-documentation-over-__read_mostly +++ a/include/linux/cache.h @@ -15,8 +15,14 @@ /* * __read_mostly is used to keep rarely changing variables out of frequently - * 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 use + * this. You want __read_mostly data to be tightly packed, so that in the + * best case multiple frequently read variables for a hot path will be next + * to each other in order to reduce the number of cachelines needed to + * execute a critical 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 _