mm: expland documentation over __read_mostly
Subsystems (2)
PATCH 1/1 mm: expland 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 it use.
--- 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.
[0] https://lkml.kernel.org/r/[email protected]
include/linux/cache.h +8 -2
@@ -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
Signature · 1 line
2.17.0
Quoted 27 lines · Luis R. Rodriguez
__read_mostlycan 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 <[email protected]>--- include/linux/cache.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)Every now and then we get a patch suggesting to use
__read_mostlyfor 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.
[0] https://lkml.kernel.org/r/[email protected]
include/linux/cache.h +0
-0@@ -15,8 +15,14 @@
include/linux/cache.h line 23
Quoted 10 lines
include/linux/cache.h +6
-2/* * __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.
of its use.
Quoted 6 lines
include/linux/cache.h +2
-0+* +* If an architecture doesn't support it, ignore the hint. */ #ifndef __read_mostly#define __read_mostly
Signature · 1 line
~Randy
Quoted 39 lines · Luis R. Rodriguez
__read_mostlycan 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 <[email protected]>---
include/linux/cache.h| 10 ++++++++--1 file changed, 8 insertions(+), 2 deletions(-)Every now and then we get a patch suggesting to use
__read_mostlyfor 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.[0]
https://lkml.kernel.org/r/[email protected]include/linux/cache.h +0
-0@@ -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
Quoted 8 lines
+ * frequently in hot paths. Performance traces can help decide when to use
+ * this. You want__read_mostlydata 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
Nit: in its use.
- Joel
Quoted 6 lines
use.
+ *
+ * If an architecture doesn't support it, ignore the hint. */
#ifndef__read_mostly
#define__read_mostly
Signature · 1 line
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Quoted 3 lines · Randy Dunlap
Quoted 1 line
+ * execute a critial path. We should be mindful and selective if its use.
of its use.
in its use.
David
Quoted 7 lines · David Howells
Quoted 3 lines · Randy Dunlap
Quoted 1 line
+ * execute a critial path. We should be mindful and selective if its use.
of its use.
in its use.
with its use.
Nah, just kidding. Let's go with "in".
Quoted 4 lines · Luis R. Rodriguez
__read_mostlycan 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.
Quoted 12 lines · Matthew Wilcox
Quoted 7 lines · David Howells
Quoted 3 lines · Randy Dunlap
Quoted 1 line
+ * execute a critial path. We should be mindful and selective if its use.
of its use.
in its use.
with its use.
Nah, just kidding. Let's go with "in".
Yeah, no, I don't care. Just flip a 3-sided coin.
Signature · 1 line
~Randy
Quoted 8 lines · Randy Dunlap
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · David Howells
Quoted 3 lines · Randy Dunlap
Quoted 1 line
+ * execute a critial path. We should be mindful and selective if its use.
of its use.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
in its use.
with its use.
Nah, just kidding. Let's go with "in".
Yeah, no, I don't care. Just flip a 3-sided coin.
Heh, the coin says "of".
I also added:
* ie: if you're going to use it please supply a *good* justification in your
* commit log.
Sending v2.
Luis