All of
 help / color / mirror / Atom feed
From: "Luis R. Rodriguez" <>
	"Luis R. Rodriguez" <>
Subject: [PATCH] mm: expland documentation over __read_mostly
Date: Mon,  7 May 2018 16:15:06 -0700	[thread overview]
Message-ID: <> (raw)

__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.

Signed-off-by: Luis R. Rodriguez <>
 include/linux/cache.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Every now and then we get a patch suggesting to use __read_mostly for
something new or old but with no justifications. Add a bit more
verbiage to help guide its users.

Is this sufficient documentation to at least ask for a reason in the commit
log as to why its being used for new entries? Or should we be explicit and
ask for such justifications in commit logs? Taken from prior discussions
with Christoph Lameter [0] over its use.


diff --git a/include/linux/cache.h b/include/linux/cache.h
index 750621e41d1c..62bc5adc0ed5 100644
--- a/include/linux/cache.h
+++ b/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 critial path. We should be mindful and selective if its use.
+ *
+ * If an architecture doesn't support it, ignore the hint.
 #ifndef __read_mostly
 #define __read_mostly

             reply	other threads:[~2018-05-07 23:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-07 23:15 Luis R. Rodriguez [this message]
2018-05-08  0:20 ` [PATCH] mm: expland documentation over __read_mostly Randy Dunlap
2018-05-08  3:23 ` Joel Fernandes
2018-05-08  8:28 ` David Howells
2018-05-08 11:23   ` Matthew Wilcox
2018-05-08 15:39     ` Randy Dunlap
2018-05-08 18:17       ` Luis R. Rodriguez
2018-05-08 12:54 ` Christopher Lameter
2020-05-06 23:13 Luis Chamberlain
2020-05-06 23:36 ` Rafael Aquini
2020-05-06 23:44 ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.