Skip to contentSkip to conversation

netconsole: switch init_netconsole() to late_initcall if build-in

PATCH Applied Lin Ming 4 participants 6 messages Sep 13, 2011 – Sep 20, 2011

Subsystems (3)
lore
Share & tools
lore

Lin Ming

author
#0 lore raw

PATCH 1/1 netconsole: switch init_netconsole() to late_initcall if build-in

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall if build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +4 -0
index dfc8272..914be29 100644
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */
Signature · 1 line
1.7.2.5
#1 lore raw
Quoted 8 lines · Lin Ming

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall if build-in.

Putting one or two lines of comments into the code would be nicer, otherwise people have to dig git log to see why. ;-)

Thanks!

author
#2 lore raw
Quoted 6 lines · Américo Wang
Quoted 5 lines · Lin Ming

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Quoted 6 lines
Quoted 3 lines

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall if build-in.

Putting one or two lines of comments into the code would be nicer, otherwise people have to dig git log to see why. ;-)

Will add.

Thanks.

#3 lore raw
In reply to Lin Ming
Quoted 18 lines · On Tue, 13 Sep 2011 15:45:39 +0800 Lin Ming <[email protected]> wrote:

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall if build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +0 -0
index dfc8272..914be29 100644

drivers/net/netconsole.c static void __exit cleanup_netconsole(void) · line 807

Quoted 9 lines
drivers/net/netconsole.c +4 -0
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */

The ifdefs (which should have used CONFIG_MODULE) aren't needed. Because late_initcall() and module_init() are identical if CONFIG_MODULE, and because one day we might want to run the exitcalls for built-in code (UML actually does this at present).

author
#4 lore raw
Quoted 23 lines · Andrew Morton
Quoted 21 lines · On Tue, 13 Sep 2011 15:45:39 +0800 Lin Ming <[email protected]> wrote:

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall if build-in.

---
 drivers/net/netconsole.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/netconsole.c +0 -0
index dfc8272..914be29 100644
@@ -799,5 +799,9 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
Quoted 11 lines

drivers/net/netconsole.c static void __exit cleanup_netconsole(void) · line 807

Quoted 6 lines
drivers/net/netconsole.c +4 -0
+#ifdef MODULE
 module_init(init_netconsole);
 module_exit(cleanup_netconsole);
+#else
+late_initcall(init_netconsole);
+#endif /* !MODULE */

The ifdefs (which should have used CONFIG_MODULE) aren't needed. Because late_initcall() and module_init() are identical if CONFIG_MODULE, and because one day we might want to run the exitcalls for built-in code (UML actually does this at present).

Thanks for comments.
Updated as below.

Quoted 1 line

From 035af5dca36a3b9e255758a46214e0e6d2b5b6a3 Mon Sep 17 00:00:00 2001

From: Lin Ming <[email protected]>
Date: Tue, 13 Sep 2011 16:35:46 +0800
Subject: [PATCH -v3] netconsole: switch init_netconsole() to late_initcall

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall.

---
 drivers/net/netconsole.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/net/netconsole.c +7 -1
index dfc8272..ed2a397 100644
@@ -799,5 +799,11 @@ static void __exit cleanup_netconsole(void)
 	}
 }
 
-module_init(init_netconsole);
+/*
+ * Use late_initcall to ensure netconsole is
+ * initialized after network device driver if built-in.
+ *
+ * late_initcall() and module_init() are identical if built as module.
+ */
+late_initcall(init_netconsole);
 module_exit(cleanup_netconsole);
Signature · 1 line
1.7.2.5
maintainer Applied
#5 lore raw

From: Lin Ming <[email protected]>
Date: Tue, 13 Sep 2011 16:38:50 +0800

Quoted 11 lines

Subject: [PATCH -v3] netconsole: switch init_netconsole() to late_initcall

Commit 88491d8(drivers/net: Kconfig & Makefile cleanup) causes a regression that netconsole does not work if netconsole and network device driver are build into kernel, because netconsole is linked before network device driver.

Andrew Morton suggested to fix this with initcall ordering. Fixes it by switching init_netconsole() to late_initcall.

Applied, thanks.