summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/instrumented.h8
-rw-r--r--lib/Kconfig.debug8
2 files changed, 15 insertions, 1 deletions
diff --git a/include/linux/instrumented.h b/include/linux/instrumented.h
index e34b6a557e0a..a1b4cf81adc2 100644
--- a/include/linux/instrumented.h
+++ b/include/linux/instrumented.h
@@ -59,7 +59,13 @@ static __always_inline void instrument_read_write(const volatile void *v, size_t
static __always_inline void instrument_atomic_check_alignment(const volatile void *v, size_t size)
{
#ifndef __DISABLE_EXPORTS
- WARN_ON_ONCE(IS_ENABLED(CONFIG_DEBUG_ATOMIC) && ((unsigned long)v & (size - 1)));
+ if (IS_ENABLED(CONFIG_DEBUG_ATOMIC)) {
+ unsigned int mask = size - 1;
+
+ if (IS_ENABLED(CONFIG_DEBUG_ATOMIC_LARGEST_ALIGN))
+ mask &= sizeof(struct { long x; } __aligned_largest) - 1;
+ WARN_ON_ONCE((unsigned long)v & mask);
+ }
#endif
}
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 9eb685d1ec44..7eed3b197ca9 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1370,6 +1370,14 @@ config DEBUG_ATOMIC
This option has potentially significant overhead.
+config DEBUG_ATOMIC_LARGEST_ALIGN
+ bool "Check alignment only up to __aligned_largest"
+ depends on DEBUG_ATOMIC
+ help
+ If you say Y here then the check for natural alignment of
+ atomic accesses will be constrained to the compiler's largest
+ alignment for scalar types.
+
menu "Lock Debugging (spinlocks, mutexes, etc...)"
config LOCK_DEBUGGING_SUPPORT