diff options
| author | Jan Engelhardt <jengelh@medozas.de> | 2012-04-19 14:44:39 -0400 |
|---|---|---|
| committer | Paul E. McKenney <paulmck@linux.vnet.ibm.com> | 2012-04-24 23:54:51 -0400 |
| commit | d8169d4c369e8aa2fda10df705a4957331b5a4db (patch) | |
| tree | ce8a08d5bd1a58f5e4703f39b2cc2033a8b03994 /include/linux | |
| parent | c9336643e1440f4dfc89ad4ac6185813619abb8c (diff) | |
rcu: Make __kfree_rcu() less dependent on compiler choices
Currently, __kfree_rcu() is implemented as an inline function, and
contains a BUILD_BUG_ON() that malfunctions if __kfree_rcu() is compiled
as an out-of-line function. Unfortunately, there are compiler settings
(e.g., -O0) that can result in __kfree_rcu() being compiled out of line,
resulting in annoying build breakage. This commit therefore converts
both __kfree_rcu() and __is_kfree_rcu_offset() from inline functions to
macros to prevent such misbehavior on the part of the compiler.
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/rcupdate.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 20fb776a1d4a..d5dfb109dfe1 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
| @@ -922,6 +922,21 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset) | |||
| 922 | kfree_call_rcu(head, (rcu_callback)offset); | 922 | kfree_call_rcu(head, (rcu_callback)offset); |
| 923 | } | 923 | } |
| 924 | 924 | ||
| 925 | /* | ||
| 926 | * Does the specified offset indicate that the corresponding rcu_head | ||
| 927 | * structure can be handled by kfree_rcu()? | ||
| 928 | */ | ||
| 929 | #define __is_kfree_rcu_offset(offset) ((offset) < 4096) | ||
| 930 | |||
| 931 | /* | ||
| 932 | * Helper macro for kfree_rcu() to prevent argument-expansion eyestrain. | ||
| 933 | */ | ||
| 934 | #define __kfree_rcu(head, offset) \ | ||
| 935 | do { \ | ||
| 936 | BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \ | ||
| 937 | call_rcu(head, (void (*)(struct rcu_head *))(unsigned long)(offset)); \ | ||
| 938 | } while (0) | ||
| 939 | |||
| 925 | /** | 940 | /** |
| 926 | * kfree_rcu() - kfree an object after a grace period. | 941 | * kfree_rcu() - kfree an object after a grace period. |
| 927 | * @ptr: pointer to kfree | 942 | * @ptr: pointer to kfree |
| @@ -944,6 +959,9 @@ void __kfree_rcu(struct rcu_head *head, unsigned long offset) | |||
| 944 | * | 959 | * |
| 945 | * Note that the allowable offset might decrease in the future, for example, | 960 | * Note that the allowable offset might decrease in the future, for example, |
| 946 | * to allow something like kmem_cache_free_rcu(). | 961 | * to allow something like kmem_cache_free_rcu(). |
| 962 | * | ||
| 963 | * The BUILD_BUG_ON check must not involve any function calls, hence the | ||
| 964 | * checks are done in macros here. | ||
| 947 | */ | 965 | */ |
| 948 | #define kfree_rcu(ptr, rcu_head) \ | 966 | #define kfree_rcu(ptr, rcu_head) \ |
| 949 | __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) | 967 | __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) |
