Skip to content

Commit 4fa7252

Browse files
mcgroftorvalds
authored andcommitted
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. Signed-off-by: Luis Chamberlain <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Kees Cook <[email protected]> Acked-by: Christoph Lameter <[email protected]> Acked-by: Rafael Aquini <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Matthew Wilcox <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 2a71e81 commit 4fa7252

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

include/linux/cache.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@
1515

1616
/*
1717
* __read_mostly is used to keep rarely changing variables out of frequently
18-
* updated cachelines. If an architecture doesn't support it, ignore the
19-
* hint.
18+
* updated cachelines. Its use should be reserved for data that is used
19+
* frequently in hot paths. Performance traces can help decide when to use
20+
* this. You want __read_mostly data to be tightly packed, so that in the
21+
* best case multiple frequently read variables for a hot path will be next
22+
* to each other in order to reduce the number of cachelines needed to
23+
* execute a critical path. We should be mindful and selective of its use.
24+
* ie: if you're going to use it please supply a *good* justification in your
25+
* commit log
2026
*/
2127
#ifndef __read_mostly
2228
#define __read_mostly

0 commit comments

Comments
 (0)