2019-09-10 08:25:54

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 0/9] hacking: make 'kernel hacking' menu better structurized

This series is a trivial improvment for the layout of 'kernel hacking'
configuration menu. Now we have many items in it which makes takes
a little time to look up them since they are not well structurized yet.

Early discussion is here:
https://lkml.org/lkml/2019/9/1/39

This is a preview:

│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ printk and dmesg options ---> │ │
│ │ Compile-time checks and compiler options ---> │ │
│ │ Generic Kernel Debugging Instruments ---> │ │
│ │ -*- Kernel debugging │ │
│ │ [*] Miscellaneous debug code │ │
│ │ Memory Debugging ---> │ │
│ │ [ ] Debug shared IRQ handlers │ │
│ │ Debug Oops, Lockups and Hangs ---> │ │
│ │ Scheduler Debugging ---> │ │
│ │ [*] Enable extra timekeeping sanity checking │ │
│ │ Lock Debugging (spinlocks, mutexes, etc...) ---> │ │
│ │ -*- Stack backtrace support │ │
│ │ [ ] Warn for all uses of unseeded randomness │ │
│ │ [ ] kobject debugging │ │
│ │ Debug kernel data structures ---> │ │
│ │ [ ] Debug credential management │ │
│ │ RCU Debugging ---> │ │
│ │ [ ] Force round-robin CPU selection for unbound work items │ │
│ │ [ ] Force extended block device numbers and spread them │ │
│ │ [ ] Enable CPU hotplug state control │ │
│ │ [*] Latency measuring infrastructure │ │
│ │ [*] Tracers ---> │ │
│ │ [ ] Remote debugging over FireWire early on boot │ │
│ │ [*] Sample kernel code ---> │ │
│ │ [*] Filter access to /dev/mem │ │
│ │ [ ] Filter I/O access to /dev/mem │ │
│ │ [ ] Additional debug code for syzbot │ │
│ │ x86 Debugging ---> │ │
│ │ Kernel Testing and Coverage ---> │ │
│ │ │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────┘

v3:
o change subject prefix.
v2:
o rebase to linux-next.
o move DEBUG_FS to 'Generic Kernel Debugging Instruments'
o move DEBUG_NOTIFIERS to 'Debug kernel data structures'

Changbin Du (9):
hacking: Group sysrq/kgdb/ubsan into 'Generic Kernel Debugging
Instruments'
hacking: Create submenu for arch special debugging options
hacking: Group kernel data structures debugging together
hacking: Move kernel testing and coverage options to same submenu
hacking: Move Oops into 'Lockups and Hangs'
hacking: Move SCHED_STACK_END_CHECK after DEBUG_STACK_USAGE
hacking: Create a submenu for scheduler debugging options
hacking: Move DEBUG_BUGVERBOSE to 'printk and dmesg options'
hacking: Move DEBUG_FS to 'Generic Kernel Debugging Instruments'

lib/Kconfig.debug | 659 ++++++++++++++++++++++++----------------------
1 file changed, 340 insertions(+), 319 deletions(-)

--
2.20.1


2019-09-10 08:25:55

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 7/9] hacking: Create a submenu for scheduler debugging options

Create a submenu 'Scheduler Debugging' for scheduler debugging options.

Signed-off-by: Changbin Du <[email protected]>
---
lib/Kconfig.debug | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ce545bb80ea2..ce891713c914 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -991,6 +991,8 @@ config WQ_WATCHDOG

endmenu # "Debug lockups and hangs"

+menu "Scheduler Debugging"
+
config SCHED_DEBUG
bool "Collect scheduler debugging info"
depends on DEBUG_KERNEL && PROC_FS
@@ -1017,6 +1019,8 @@ config SCHEDSTATS
application, you can say N to avoid the very slight overhead
this adds.

+endmenu
+
config DEBUG_TIMEKEEPING
bool "Enable extra timekeeping sanity checking"
help
--
2.20.1

2019-09-10 08:26:42

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 5/9] hacking: Move Oops into 'Lockups and Hangs'

They are similar options so place them together.

Signed-off-by: Changbin Du <[email protected]>
---
lib/Kconfig.debug | 58 +++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 7b3552531d02..1385e17122a1 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -793,7 +793,35 @@ config DEBUG_SHIRQ
Drivers ought to be able to handle interrupts coming in at those
points; some don't and need to be caught.

-menu "Debug Lockups and Hangs"
+menu "Debug Oops, Lockups and Hangs"
+
+config PANIC_ON_OOPS
+ bool "Panic on Oops"
+ help
+ Say Y here to enable the kernel to panic when it oopses. This
+ has the same effect as setting oops=panic on the kernel command
+ line.
+
+ This feature is useful to ensure that the kernel does not do
+ anything erroneous after an oops which could result in data
+ corruption or other issues.
+
+ Say N if unsure.
+
+config PANIC_ON_OOPS_VALUE
+ int
+ range 0 1
+ default 0 if !PANIC_ON_OOPS
+ default 1 if PANIC_ON_OOPS
+
+config PANIC_TIMEOUT
+ int "panic timeout"
+ default 0
+ help
+ Set the timeout value (in seconds) until a reboot occurs when the
+ the kernel panics. If n = 0, then we wait forever. A timeout
+ value n > 0 will wait n seconds before rebooting, while a timeout
+ value n < 0 will reboot immediately.

config LOCKUP_DETECTOR
bool
@@ -951,34 +979,6 @@ config WQ_WATCHDOG

endmenu # "Debug lockups and hangs"

-config PANIC_ON_OOPS
- bool "Panic on Oops"
- help
- Say Y here to enable the kernel to panic when it oopses. This
- has the same effect as setting oops=panic on the kernel command
- line.
-
- This feature is useful to ensure that the kernel does not do
- anything erroneous after an oops which could result in data
- corruption or other issues.
-
- Say N if unsure.
-
-config PANIC_ON_OOPS_VALUE
- int
- range 0 1
- default 0 if !PANIC_ON_OOPS
- default 1 if PANIC_ON_OOPS
-
-config PANIC_TIMEOUT
- int "panic timeout"
- default 0
- help
- Set the timeout value (in seconds) until a reboot occurs when the
- the kernel panics. If n = 0, then we wait forever. A timeout
- value n > 0 will wait n seconds before rebooting, while a timeout
- value n < 0 will reboot immediately.
-
config SCHED_DEBUG
bool "Collect scheduler debugging info"
depends on DEBUG_KERNEL && PROC_FS
--
2.20.1

2019-09-10 08:27:03

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 8/9] hacking: Move DEBUG_BUGVERBOSE to 'printk and dmesg options'

I think DEBUG_BUGVERBOSE is a dmesg option which gives more debug info
to dmesg.

Signed-off-by: Changbin Du <[email protected]>
---
lib/Kconfig.debug | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index ce891713c914..ceefe0c1e78b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -164,6 +164,15 @@ config DYNAMIC_DEBUG
See Documentation/admin-guide/dynamic-debug-howto.rst for additional
information.

+config DEBUG_BUGVERBOSE
+ bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
+ depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
+ default y
+ help
+ Say Y here to make BUG() panics output the file name and line number
+ of the BUG call as well as the EIP and oops trace. This aids
+ debugging but costs about 70-100K of memory.
+
endmenu # "printk and dmesg options"

menu "Compile-time checks and compiler options"
@@ -1323,15 +1332,6 @@ config DEBUG_KOBJECT_RELEASE
config HAVE_DEBUG_BUGVERBOSE
bool

-config DEBUG_BUGVERBOSE
- bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
- depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
- default y
- help
- Say Y here to make BUG() panics output the file name and line number
- of the BUG call as well as the EIP and oops trace. This aids
- debugging but costs about 70-100K of memory.
-
menu "Debug kernel data structures"

config DEBUG_LIST
--
2.20.1

2019-09-10 09:05:49

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v3 0/9] hacking: make 'kernel hacking' menu better structurized

On 9/9/19 7:44 AM, Changbin Du wrote:
> This series is a trivial improvment for the layout of 'kernel hacking'
> configuration menu. Now we have many items in it which makes takes
> a little time to look up them since they are not well structurized yet.
>
> Early discussion is here:
> https://lkml.org/lkml/2019/9/1/39
>
> This is a preview:
>
> │ ┌─────────────────────────────────────────────────────────────────────────┐ │
> │ │ printk and dmesg options ---> │ │
> │ │ Compile-time checks and compiler options ---> │ │
> │ │ Generic Kernel Debugging Instruments ---> │ │
> │ │ -*- Kernel debugging │ │
> │ │ [*] Miscellaneous debug code │ │
> │ │ Memory Debugging ---> │ │
> │ │ [ ] Debug shared IRQ handlers │ │
> │ │ Debug Oops, Lockups and Hangs ---> │ │
> │ │ Scheduler Debugging ---> │ │
> │ │ [*] Enable extra timekeeping sanity checking │ │
> │ │ Lock Debugging (spinlocks, mutexes, etc...) ---> │ │
> │ │ -*- Stack backtrace support │ │
> │ │ [ ] Warn for all uses of unseeded randomness │ │
> │ │ [ ] kobject debugging │ │
> │ │ Debug kernel data structures ---> │ │
> │ │ [ ] Debug credential management │ │
> │ │ RCU Debugging ---> │ │
> │ │ [ ] Force round-robin CPU selection for unbound work items │ │
> │ │ [ ] Force extended block device numbers and spread them │ │
> │ │ [ ] Enable CPU hotplug state control │ │
> │ │ [*] Latency measuring infrastructure │ │
> │ │ [*] Tracers ---> │ │
> │ │ [ ] Remote debugging over FireWire early on boot │ │
> │ │ [*] Sample kernel code ---> │ │
> │ │ [*] Filter access to /dev/mem │ │
> │ │ [ ] Filter I/O access to /dev/mem │ │
> │ │ [ ] Additional debug code for syzbot │ │
> │ │ x86 Debugging ---> │ │
> │ │ Kernel Testing and Coverage ---> │ │
> │ │ │ │
> │ │ │ │
> │ └─────────────────────────────────────────────────────────────────────────┘ │
> ├─────────────────────────────────────────────────────────────────────────────┤
> │ <Select> < Exit > < Help > < Save > < Load > │
> └─────────────────────────────────────────────────────────────────────────────┘
>
> v3:
> o change subject prefix.
> v2:
> o rebase to linux-next.
> o move DEBUG_FS to 'Generic Kernel Debugging Instruments'
> o move DEBUG_NOTIFIERS to 'Debug kernel data structures'
>
> Changbin Du (9):
> hacking: Group sysrq/kgdb/ubsan into 'Generic Kernel Debugging
> Instruments'
> hacking: Create submenu for arch special debugging options
> hacking: Group kernel data structures debugging together
> hacking: Move kernel testing and coverage options to same submenu
> hacking: Move Oops into 'Lockups and Hangs'
> hacking: Move SCHED_STACK_END_CHECK after DEBUG_STACK_USAGE
> hacking: Create a submenu for scheduler debugging options
> hacking: Move DEBUG_BUGVERBOSE to 'printk and dmesg options'
> hacking: Move DEBUG_FS to 'Generic Kernel Debugging Instruments'
>
> lib/Kconfig.debug | 659 ++++++++++++++++++++++++----------------------
> 1 file changed, 340 insertions(+), 319 deletions(-)

Hi,
Looks good to me.

I verified that the before and after kernel .config file contains the same
symbols and values (for allmodconfig).
I also tested with menuconfig, nconfig, gconfig, and xconfig.

for all 9 patches:
Acked-by: Randy Dunlap <[email protected]>
Tested-by: Randy Dunlap <[email protected]>

Thanks.
--
~Randy

2019-09-10 18:26:52

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 2/9] hacking: Create submenu for arch special debugging options

The arch special options are a little long, so create a submenu for them.

Signed-off-by: Changbin Du <[email protected]>
---
lib/Kconfig.debug | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index bd3938483514..cc4d8e71ae81 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -2164,6 +2164,10 @@ config DEBUG_AID_FOR_SYZBOT
help
This option is intended for testing by syzbot.

+menu "$(SRCARCH) Debugging"
+
source "arch/$(SRCARCH)/Kconfig.debug"

+endmenu
+
endmenu # Kernel hacking
--
2.20.1

2019-09-10 18:27:35

by Changbin Du

[permalink] [raw]
Subject: [PATCH v3 1/9] hacking: Group sysrq/kgdb/ubsan into 'Generic Kernel Debugging Instruments'

Group generic kernel debugging instruments sysrq/kgdb/ubsan together into
a new submenu.

Signed-off-by: Changbin Du <[email protected]>
---
lib/Kconfig.debug | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 10023dbac8e4..bd3938483514 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -419,6 +419,8 @@ config DEBUG_FORCE_WEAK_PER_CPU

endmenu # "Compiler options"

+menu "Generic Kernel Debugging Instruments"
+
config MAGIC_SYSRQ
bool "Magic SysRq key"
depends on !UML
@@ -452,6 +454,12 @@ config MAGIC_SYSRQ_SERIAL
This option allows you to decide whether you want to enable the
magic SysRq key.

+source "lib/Kconfig.kgdb"
+
+source "lib/Kconfig.ubsan"
+
+endmenu
+
config DEBUG_KERNEL
bool "Kernel debugging"
help
@@ -2111,10 +2119,6 @@ config BUG_ON_DATA_CORRUPTION

source "samples/Kconfig"

-source "lib/Kconfig.kgdb"
-
-source "lib/Kconfig.ubsan"
-
config ARCH_HAS_DEVMEM_IS_ALLOWED
bool

--
2.20.1

2019-09-22 19:16:21

by Changbin Du

[permalink] [raw]
Subject: Re: [PATCH v3 0/9] hacking: make 'kernel hacking' menu better structurized

Gentle ping for status of this series. thx!

On Mon, Sep 09, 2019 at 10:44:44PM +0800, Changbin Du wrote:
> This series is a trivial improvment for the layout of 'kernel hacking'
> configuration menu. Now we have many items in it which makes takes
> a little time to look up them since they are not well structurized yet.
>
> Early discussion is here:
> https://lkml.org/lkml/2019/9/1/39
>
> This is a preview:
>
> │ ┌─────────────────────────────────────────────────────────────────────────┐ │
> │ │ printk and dmesg options ---> │ │
> │ │ Compile-time checks and compiler options ---> │ │
> │ │ Generic Kernel Debugging Instruments ---> │ │
> │ │ -*- Kernel debugging │ │
> │ │ [*] Miscellaneous debug code │ │
> │ │ Memory Debugging ---> │ │
> │ │ [ ] Debug shared IRQ handlers │ │
> │ │ Debug Oops, Lockups and Hangs ---> │ │
> │ │ Scheduler Debugging ---> │ │
> │ │ [*] Enable extra timekeeping sanity checking │ │
> │ │ Lock Debugging (spinlocks, mutexes, etc...) ---> │ │
> │ │ -*- Stack backtrace support │ │
> │ │ [ ] Warn for all uses of unseeded randomness │ │
> │ │ [ ] kobject debugging │ │
> │ │ Debug kernel data structures ---> │ │
> │ │ [ ] Debug credential management │ │
> │ │ RCU Debugging ---> │ │
> │ │ [ ] Force round-robin CPU selection for unbound work items │ │
> │ │ [ ] Force extended block device numbers and spread them │ │
> │ │ [ ] Enable CPU hotplug state control │ │
> │ │ [*] Latency measuring infrastructure │ │
> │ │ [*] Tracers ---> │ │
> │ │ [ ] Remote debugging over FireWire early on boot │ │
> │ │ [*] Sample kernel code ---> │ │
> │ │ [*] Filter access to /dev/mem │ │
> │ │ [ ] Filter I/O access to /dev/mem │ │
> │ │ [ ] Additional debug code for syzbot │ │
> │ │ x86 Debugging ---> │ │
> │ │ Kernel Testing and Coverage ---> │ │
> │ │ │ │
> │ │ │ │
> │ └─────────────────────────────────────────────────────────────────────────┘ │
> ├─────────────────────────────────────────────────────────────────────────────┤
> │ <Select> < Exit > < Help > < Save > < Load > │
> └─────────────────────────────────────────────────────────────────────────────┘
>
> v3:
> o change subject prefix.
> v2:
> o rebase to linux-next.
> o move DEBUG_FS to 'Generic Kernel Debugging Instruments'
> o move DEBUG_NOTIFIERS to 'Debug kernel data structures'
>
> Changbin Du (9):
> hacking: Group sysrq/kgdb/ubsan into 'Generic Kernel Debugging
> Instruments'
> hacking: Create submenu for arch special debugging options
> hacking: Group kernel data structures debugging together
> hacking: Move kernel testing and coverage options to same submenu
> hacking: Move Oops into 'Lockups and Hangs'
> hacking: Move SCHED_STACK_END_CHECK after DEBUG_STACK_USAGE
> hacking: Create a submenu for scheduler debugging options
> hacking: Move DEBUG_BUGVERBOSE to 'printk and dmesg options'
> hacking: Move DEBUG_FS to 'Generic Kernel Debugging Instruments'
>
> lib/Kconfig.debug | 659 ++++++++++++++++++++++++----------------------
> 1 file changed, 340 insertions(+), 319 deletions(-)
>
> --
> 2.20.1
>

--
Cheers,
Changbin Du