Skip to content

Commit f64205a

Browse files
Aaron Tomlinmcgrof
authored andcommitted
module: Move kdb module related code out of main kdb code
No functional change. This patch migrates the kdb 'lsmod' command support out of main kdb code into its own file under kernel/module. In addition to the above, a minor style warning i.e. missing a blank line after declarations, was resolved too. The new file was added to MAINTAINERS. Finally we remove linux/module.h as it is entirely redundant. Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org> Acked-by: Daniel Thompson <daniel.thompson@linaro.org> Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 parent 44c0953 commit f64205a

10 files changed

Lines changed: 59 additions & 60 deletions

File tree

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10907,6 +10907,7 @@ F: drivers/tty/serial/kgdboc.c
1090710907
F: include/linux/kdb.h
1090810908
F: include/linux/kgdb.h
1090910909
F: kernel/debug/
10910+
F: kernel/module/kdb.c
1091010911

1091110912
KHADAS MCU MFD DRIVER
1091210913
M: Neil Armstrong <narmstrong@baylibre.com>

include/linux/kdb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,5 +222,6 @@ enum {
222222

223223
extern int kdbgetintenv(const char *, int *);
224224
extern int kdb_set(int, const char **);
225+
int kdb_lsmod(int argc, const char **argv);
225226

226227
#endif /* !_KDB_H */

kernel/debug/kdb/kdb_io.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
1010
*/
1111

12-
#include <linux/module.h>
1312
#include <linux/types.h>
1413
#include <linux/ctype.h>
1514
#include <linux/kernel.h>

kernel/debug/kdb/kdb_keyboard.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <linux/kdb.h>
1212
#include <linux/keyboard.h>
1313
#include <linux/ctype.h>
14-
#include <linux/module.h>
1514
#include <linux/io.h>
1615

1716
/* Keyboard Controller Registers on normal PCs. */

kernel/debug/kdb/kdb_main.c

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/utsname.h>
2727
#include <linux/vmalloc.h>
2828
#include <linux/atomic.h>
29-
#include <linux/module.h>
3029
#include <linux/moduleparam.h>
3130
#include <linux/mm.h>
3231
#include <linux/init.h>
@@ -2004,54 +2003,6 @@ static int kdb_ef(int argc, const char **argv)
20042003
return 0;
20052004
}
20062005

2007-
#if defined(CONFIG_MODULES)
2008-
/*
2009-
* kdb_lsmod - This function implements the 'lsmod' command. Lists
2010-
* currently loaded kernel modules.
2011-
* Mostly taken from userland lsmod.
2012-
*/
2013-
static int kdb_lsmod(int argc, const char **argv)
2014-
{
2015-
struct module *mod;
2016-
2017-
if (argc != 0)
2018-
return KDB_ARGCOUNT;
2019-
2020-
kdb_printf("Module Size modstruct Used by\n");
2021-
list_for_each_entry(mod, kdb_modules, list) {
2022-
if (mod->state == MODULE_STATE_UNFORMED)
2023-
continue;
2024-
2025-
kdb_printf("%-20s%8u 0x%px ", mod->name,
2026-
mod->core_layout.size, (void *)mod);
2027-
#ifdef CONFIG_MODULE_UNLOAD
2028-
kdb_printf("%4d ", module_refcount(mod));
2029-
#endif
2030-
if (mod->state == MODULE_STATE_GOING)
2031-
kdb_printf(" (Unloading)");
2032-
else if (mod->state == MODULE_STATE_COMING)
2033-
kdb_printf(" (Loading)");
2034-
else
2035-
kdb_printf(" (Live)");
2036-
kdb_printf(" 0x%px", mod->core_layout.base);
2037-
2038-
#ifdef CONFIG_MODULE_UNLOAD
2039-
{
2040-
struct module_use *use;
2041-
kdb_printf(" [ ");
2042-
list_for_each_entry(use, &mod->source_list,
2043-
source_list)
2044-
kdb_printf("%s ", use->target->name);
2045-
kdb_printf("]\n");
2046-
}
2047-
#endif
2048-
}
2049-
2050-
return 0;
2051-
}
2052-
2053-
#endif /* CONFIG_MODULES */
2054-
20552006
/*
20562007
* kdb_env - This function implements the 'env' command. Display the
20572008
* current environment variables.

kernel/debug/kdb/kdb_private.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ extern void kdb_kbd_cleanup_state(void);
226226
#define kdb_kbd_cleanup_state()
227227
#endif /* ! CONFIG_KDB_KEYBOARD */
228228

229-
#ifdef CONFIG_MODULES
230-
extern struct list_head *kdb_modules;
231-
#endif /* CONFIG_MODULES */
232-
233229
extern char kdb_prompt_str[];
234230

235231
#define KDB_WORD_SIZE ((int)sizeof(unsigned long))

kernel/debug/kdb/kdb_support.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <linux/stddef.h>
1818
#include <linux/vmalloc.h>
1919
#include <linux/ptrace.h>
20-
#include <linux/module.h>
2120
#include <linux/highmem.h>
2221
#include <linux/hardirq.h>
2322
#include <linux/delay.h>

kernel/module/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ obj-$(CONFIG_DEBUG_KMEMLEAK) += debug_kmemleak.o
1717
obj-$(CONFIG_KALLSYMS) += kallsyms.o
1818
obj-$(CONFIG_PROC_FS) += procfs.o
1919
obj-$(CONFIG_SYSFS) += sysfs.o
20+
obj-$(CONFIG_KGDB_KDB) += kdb.o

kernel/module/kdb.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Module kdb support
4+
*
5+
* Copyright (C) 2010 Jason Wessel
6+
*/
7+
8+
#include <linux/module.h>
9+
#include <linux/kdb.h>
10+
#include "internal.h"
11+
12+
/*
13+
* kdb_lsmod - This function implements the 'lsmod' command. Lists
14+
* currently loaded kernel modules.
15+
* Mostly taken from userland lsmod.
16+
*/
17+
int kdb_lsmod(int argc, const char **argv)
18+
{
19+
struct module *mod;
20+
21+
if (argc != 0)
22+
return KDB_ARGCOUNT;
23+
24+
kdb_printf("Module Size modstruct Used by\n");
25+
list_for_each_entry(mod, &modules, list) {
26+
if (mod->state == MODULE_STATE_UNFORMED)
27+
continue;
28+
29+
kdb_printf("%-20s%8u 0x%px ", mod->name,
30+
mod->core_layout.size, (void *)mod);
31+
#ifdef CONFIG_MODULE_UNLOAD
32+
kdb_printf("%4d ", module_refcount(mod));
33+
#endif
34+
if (mod->state == MODULE_STATE_GOING)
35+
kdb_printf(" (Unloading)");
36+
else if (mod->state == MODULE_STATE_COMING)
37+
kdb_printf(" (Loading)");
38+
else
39+
kdb_printf(" (Live)");
40+
kdb_printf(" 0x%px", mod->core_layout.base);
41+
42+
#ifdef CONFIG_MODULE_UNLOAD
43+
{
44+
struct module_use *use;
45+
46+
kdb_printf(" [ ");
47+
list_for_each_entry(use, &mod->source_list,
48+
source_list)
49+
kdb_printf("%s ", use->target->name);
50+
kdb_printf("]\n");
51+
}
52+
#endif
53+
}
54+
55+
return 0;
56+
}

kernel/module/main.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@ static void mod_update_bounds(struct module *mod)
108108
__mod_update_bounds(mod->init_layout.base, mod->init_layout.size);
109109
}
110110

111-
#ifdef CONFIG_KGDB_KDB
112-
struct list_head *kdb_modules = &modules; /* kdb needs the list of modules */
113-
#endif /* CONFIG_KGDB_KDB */
114-
115111
static void module_assert_mutex_or_preempt(void)
116112
{
117113
#ifdef CONFIG_LOCKDEP

0 commit comments

Comments
 (0)