mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
Introduce Hazard Pointers debug assert, which detects misuse of hazard pointers, namely failure to detach the hazard pointer from its owner thread before releasing it from a different thread. Prints the following to the console when a failure is detected: Hazard Pointer (addr=000000006885a05f) released on remote task without being detached from task. Acquire: caller=hazptr_torture_read_lock+0x43/0xa0 [hazptrtorture], pid=3727, cpu=1. Release: pid=3725, cpu=139. WARNING: ./include/linux/hazptr.h:225 at hazptr_torture_read_unlock+0x68/0xf0 [hazptrtorture], CPU#139: hazptr_torture_/3725 Modules linked in: hazptrtorture torture nft_masq nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nf_tables nfnetlink CPU: 139 UID: 0 PID: 3725 Comm: hazptr_torture_ Not tainted 7.1.0-rc4+ #9 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:hazptr_torture_read_unlock+0x74/0xf0 [hazptrtorture] Code: 74 31 8b 4f 40 4c 8b 43 48 49 c7 c2 22 c9 56 c0 48 c7 c7 3b c9 56 c0 4c 8d 1d b8 32 f1 ff 52 48 89 fa 4c 89 df 50 51 4c 89 d1 <67> 48 0f b9 3a 48 83 c4 18 48 8b 03 48 8d 53 18 48 c7 00 00 00 00 RSP: 0018:ff621a2a479b3de0 EFLAGS: 00010293 RAX: 0000000000000e8d RBX: ff12ea30d3913488 RCX: ffffffffc056c922 RDX: ffffffffc056c93b RSI: ffffffffc0562280 RDI: ffffffffc0562030 RBP: ff621a2a479b3e50 R08: ffffffffc064ee53 R09: 0000000000000e8f R10: ffffffffc056c922 R11: ffffffffc0562030 R12: 0000000000000000 R13: ffffffffc0562280 R14: ff12ea30d3913488 R15: ff621a2a479b3e50 FS: 0000000000000000(0000) GS:ff12ea5011a84000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f39b6e4b010 CR3: 0000000114c6e005 CR4: 0000000000771ef0 PKRU: 55555554 Call Trace: <TASK> hazptr_torture_reader_tail+0x8e/0x210 [hazptrtorture] hazptr_torture_reader+0x145/0xb30 [hazptrtorture] ? srso_alias_return_thunk+0x5/0xfbef5 ? set_cpus_allowed_ptr+0x36/0x60 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? __pfx_hazptr_torture_reader+0x10/0x10 [hazptrtorture] kthread+0xdf/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x216/0x2d0 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1a/0x30 </TASK> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Boqun Feng <boqun@kernel.org> Cc: <rcu@vger.kernel.org> Cc: <lkmm@lists.linux.dev>
264 lines
9.2 KiB
Plaintext
264 lines
9.2 KiB
Plaintext
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# RCU-related debugging configuration options
|
|
#
|
|
|
|
menu "RCU Debugging"
|
|
|
|
config PROVE_RCU
|
|
def_bool PROVE_LOCKING
|
|
|
|
config PROVE_RCU_LIST
|
|
bool "RCU list lockdep debugging"
|
|
depends on PROVE_RCU && RCU_EXPERT
|
|
default n
|
|
help
|
|
Enable RCU lockdep checking for list usages. By default it is
|
|
turned off since there are several list RCU users that still
|
|
need to be converted to pass a lockdep expression. To prevent
|
|
false-positive splats, we keep it default disabled but once all
|
|
users are converted, we can remove this config option.
|
|
|
|
config TORTURE_TEST
|
|
tristate
|
|
default n
|
|
|
|
config RCU_SCALE_TEST
|
|
tristate "performance tests for RCU"
|
|
depends on DEBUG_KERNEL
|
|
select TORTURE_TEST
|
|
default n
|
|
help
|
|
This option provides a kernel module that runs performance
|
|
tests on the RCU infrastructure. The kernel module may be built
|
|
after the fact on the running kernel to be tested, if desired.
|
|
|
|
Say Y here if you want RCU performance tests to be built into
|
|
the kernel.
|
|
Say M if you want the RCU performance tests to build as a module.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_TORTURE_TEST
|
|
tristate "torture tests for RCU"
|
|
depends on DEBUG_KERNEL
|
|
select TORTURE_TEST
|
|
default n
|
|
help
|
|
This option provides a kernel module that runs torture tests
|
|
on the RCU infrastructure. The kernel module may be built
|
|
after the fact on the running kernel to be tested, if desired.
|
|
|
|
Say Y here if you want RCU torture tests to be built into
|
|
the kernel.
|
|
Say M if you want the RCU torture tests to build as a module.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_TORTURE_TEST_CHK_RDR_STATE
|
|
bool "Check rcutorture reader state"
|
|
depends on RCU_TORTURE_TEST
|
|
default n
|
|
help
|
|
This option causes rcutorture to check the desired rcutorture
|
|
reader state for each segment against the actual context.
|
|
Note that PREEMPT_COUNT must be enabled if the preempt-disabled
|
|
and bh-disabled checks are to take effect, and that PREEMPT_RCU
|
|
must be enabled for the RCU-nesting checks to take effect.
|
|
These checks add overhead, and this Kconfig options is therefore
|
|
disabled by default.
|
|
|
|
Say Y here if you want rcutorture reader contexts checked.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_TORTURE_TEST_LOG_CPU
|
|
bool "Log CPU for rcutorture failures"
|
|
depends on RCU_TORTURE_TEST
|
|
default n
|
|
help
|
|
This option causes rcutorture to decorate each entry of its
|
|
log of failure/close-call rcutorture reader segments with the
|
|
number of the CPU that the reader was running on at the time.
|
|
This information can be useful, but it does incur additional
|
|
overhead, overhead that can make both failures and close calls
|
|
less probable.
|
|
|
|
Say Y here if you want CPU IDs logged.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_TORTURE_TEST_LOG_GP
|
|
bool "Log grace-period numbers for rcutorture failures"
|
|
depends on RCU_TORTURE_TEST
|
|
default n
|
|
help
|
|
This option causes rcutorture to decorate each entry of its
|
|
log of failure/close-call rcutorture reader segments with the
|
|
corresponding grace-period sequence numbers. This information
|
|
can be useful, but it does incur additional overhead, overhead
|
|
that can make both failures and close calls less probable.
|
|
|
|
Say Y here if you want grace-period sequence numbers logged.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_REF_SCALE_TEST
|
|
tristate "Scalability tests for read-side synchronization (RCU and others)"
|
|
depends on DEBUG_KERNEL
|
|
select TORTURE_TEST
|
|
default n
|
|
help
|
|
This option provides a kernel module that runs performance tests
|
|
useful comparing RCU with various read-side synchronization mechanisms.
|
|
The kernel module may be built after the fact on the running kernel to be
|
|
tested, if desired.
|
|
|
|
Say Y here if you want these performance tests built into the kernel.
|
|
Say M if you want to build it as a module instead.
|
|
Say N if you are unsure.
|
|
|
|
config HAZPTR_TORTURE_TEST
|
|
tristate "Torture tests for hazard pointers"
|
|
depends on DEBUG_KERNEL
|
|
select TORTURE_TEST
|
|
default n
|
|
help
|
|
This option provides in-kernel hazard-pointer stress tests.
|
|
|
|
Say Y here if you want hazard-pointer testing built into the kernel.
|
|
Say M if you want to build them as a module instead.
|
|
Say N if you are unsure.
|
|
|
|
config RCU_CPU_STALL_TIMEOUT
|
|
int "RCU CPU stall timeout in seconds"
|
|
depends on RCU_STALL_COMMON
|
|
range 3 300
|
|
default 21
|
|
help
|
|
If a given RCU grace period extends more than the specified
|
|
number of seconds, a CPU stall warning is printed. If the
|
|
RCU grace period persists, additional CPU stall warnings are
|
|
printed at more widely spaced intervals.
|
|
|
|
config RCU_EXP_CPU_STALL_TIMEOUT
|
|
int "Expedited RCU CPU stall timeout in milliseconds"
|
|
depends on RCU_STALL_COMMON
|
|
range 0 300000
|
|
default 0
|
|
help
|
|
If a given expedited RCU grace period extends more than the
|
|
specified number of milliseconds, a CPU stall warning is printed.
|
|
If the RCU grace period persists, additional CPU stall warnings
|
|
are printed at more widely spaced intervals. A value of zero
|
|
says to use the RCU_CPU_STALL_TIMEOUT value converted from
|
|
seconds to milliseconds.
|
|
|
|
config RCU_CPU_STALL_CPUTIME
|
|
bool "Provide additional RCU stall debug information"
|
|
depends on RCU_STALL_COMMON
|
|
default n
|
|
help
|
|
Collect statistics during the sampling period, such as the number of
|
|
(hard interrupts, soft interrupts, task switches) and the cputime of
|
|
(hard interrupts, soft interrupts, kernel tasks) are added to the
|
|
RCU stall report. For multiple continuous RCU stalls, all sampling
|
|
periods begin at half of the first RCU stall timeout.
|
|
The boot option rcupdate.rcu_cpu_stall_cputime has the same function
|
|
as this one, but will override this if it exists.
|
|
|
|
config RCU_CPU_STALL_NOTIFIER
|
|
bool "Provide RCU CPU-stall notifiers"
|
|
depends on RCU_STALL_COMMON
|
|
depends on DEBUG_KERNEL
|
|
depends on RCU_EXPERT
|
|
default n
|
|
help
|
|
WARNING: You almost certainly do not want this!!!
|
|
|
|
Enable RCU CPU-stall notifiers, which are invoked just before
|
|
printing the RCU CPU stall warning. As such, bugs in notifier
|
|
callbacks can prevent stall warnings from being printed.
|
|
And the whole reason that a stall warning is being printed is
|
|
that something is hung up somewhere. Therefore, the notifier
|
|
callbacks must be written extremely carefully, preferably
|
|
containing only lockless code. After all, it is quite possible
|
|
that the whole reason that the RCU CPU stall is happening in
|
|
the first place is that someone forgot to release whatever lock
|
|
that you are thinking of acquiring. In which case, having your
|
|
notifier callback acquire that lock will hang, preventing the
|
|
RCU CPU stall warning from appearing.
|
|
|
|
Say Y here if you want RCU CPU stall notifiers (you don't want them)
|
|
Say N if you are unsure.
|
|
|
|
config RCU_TRACE
|
|
bool "Enable tracing for RCU"
|
|
depends on DEBUG_KERNEL
|
|
default y if TREE_RCU
|
|
select TRACE_CLOCK
|
|
help
|
|
This option enables additional tracepoints for ftrace-style
|
|
event tracing.
|
|
|
|
Say Y here if you want to enable RCU tracing
|
|
Say N if you are unsure.
|
|
|
|
config RCU_EQS_DEBUG
|
|
bool "Provide debugging asserts for adding NO_HZ support to an arch"
|
|
depends on DEBUG_KERNEL
|
|
help
|
|
This option provides consistency checks in RCU's handling of
|
|
NO_HZ. These checks have proven quite helpful in detecting
|
|
bugs in arch-specific NO_HZ code.
|
|
|
|
Say N here if you need ultimate kernel/user switch latencies
|
|
Say Y if you are unsure
|
|
|
|
config RCU_STRICT_GRACE_PERIOD
|
|
bool "Provide debug RCU implementation with short grace periods"
|
|
depends on DEBUG_KERNEL && RCU_EXPERT && NR_CPUS <= 4 && !TINY_RCU
|
|
default n
|
|
select PREEMPT_COUNT if PREEMPT=n
|
|
help
|
|
Select this option to build an RCU variant that is strict about
|
|
grace periods, making them as short as it can. This limits
|
|
scalability, destroys real-time response, degrades battery
|
|
lifetime and kills performance. Don't try this on large
|
|
machines, as in systems with more than about 10 or 20 CPUs.
|
|
But in conjunction with tools like KASAN, it can be helpful
|
|
when looking for certain types of RCU usage bugs, for example,
|
|
too-short RCU read-side critical sections.
|
|
|
|
|
|
config RCU_DYNTICKS_TORTURE
|
|
bool "Minimize RCU dynticks counter size"
|
|
depends on RCU_EXPERT && !COMPILE_TEST
|
|
default n
|
|
help
|
|
This option sets the width of the dynticks counter to its
|
|
minimum usable value. This minimum width greatly increases
|
|
the probability of flushing out bugs involving counter wrap,
|
|
but it also increases the probability of extending grace period
|
|
durations. This Kconfig option should therefore be avoided in
|
|
production due to the consequent increased probability of OOMs.
|
|
|
|
This has no value for production and is only for testing.
|
|
|
|
config TRIVIAL_PREEMPT_RCU
|
|
bool "Textbook trivial preemptible RCU in rcutorture"
|
|
depends on RCU_EXPERT && RCU_TORTURE_TEST
|
|
default n
|
|
help
|
|
This option enables a textbook preemptible RCU that is
|
|
implemented in rcutorture. Its sole purpose is to validate
|
|
code used in books, papers, and presentations.
|
|
|
|
This has no value for production and is only for testing.
|
|
|
|
config HAZPTR_DEBUG
|
|
bool "Provide debugging asserts for Hazard Pointers"
|
|
depends on DEBUG_KERNEL
|
|
default n
|
|
help
|
|
This option provides consistency checks for Hazard pointers.
|
|
|
|
Say Y here if you want to enable those assert, N otherwise.
|
|
|
|
endmenu # "RCU Debugging"
|