mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: trenn@suse.de
To: jbaron@redhat.com
Cc: trenn@suse.de, linux-kernel@vger.kernel.org,
	yehuda@hq.newdream.net, astarikovskiy@novell.com
Subject: [patch 3/3] Dynamic Debug: Initialize dynamic debug earlier via arch_initcall
Date: Tue, 20 Jul 2010 15:44:50 +0200	[thread overview]
Message-ID: <20100720134730.081078353@ett.arch.suse.de> (raw)
In-Reply-To: <20100720134447.983521886@ett.arch.suse.de>

[-- Attachment #1: patches.drivers/dynamic_debug_make_arch_initcall.patch --]
[-- Type: text/plain, Size: 3084 bytes --]

Having the ddebug_query= boot parameter it makes sense to set up
dynamic debug as soon as possible.

I expect sysfs files cannot be set up via an arch_initcall, because
this one is even before fs_initcall. Therefore I splitted the
dynamic_debug_init function into an early one and a later one providing
/sys/../dynamic_debug/control file.

Possibly dynamic_debug can be initialized even earlier, not sure whether
this still makes sense then. I picked up arch_initcall as it covers
quite a lot already.

Dynamic debug seem to not need memory (kmalloc) set up yet.
If it is possible to move initialization even before __setup boot
parameter processing, the temporary variable to copy away the boot paramter
and later use it in dynamic_debug_init() is not needed anymore.

This has been tested with ddebug_query="file ec.c +p"
and I could retrieve pr_debug() messages early at boot during ACPI setup:
ACPI: EC: Look up EC in DSDT
ACPI: EC: ---> status = 0x08
ACPI: EC: transaction start
ACPI: EC: <--- command = 0x80
ACPI: EC: ~~~> interrupt
ACPI: EC: ---> status = 0x08
ACPI: EC: <--- data = 0xa4
...
ACPI: Interpreter enabled
ACPI: (supports S0 S3 S4 S5)
ACPI: Using IOAPIC for interrupt routing
ACPI: EC: ---> status = 0x00
ACPI: EC: transaction start
ACPI: EC: <--- command = 0x80


Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: jbaron@redhat.com
CC: linux-kernel@vger.kernel.org
CC: yehuda@hq.newdream.net
CC: astarikovskiy@novell.com


---
 lib/dynamic_debug.c |   33 +++++++++++++++++++++++----------
 1 file changed, 23 insertions(+), 10 deletions(-)

Index: linux-2.6.34-master/lib/dynamic_debug.c
===================================================================
--- linux-2.6.34-master.orig/lib/dynamic_debug.c
+++ linux-2.6.34-master/lib/dynamic_debug.c
@@ -748,13 +748,14 @@ static void ddebug_remove_all_tables(voi
 	mutex_unlock(&ddebug_lock);
 }
 
-static int __init dynamic_debug_init(void)
+static __initdata int ddebug_init_success;
+
+static int __init dynamic_debug_init_debugfs(void)
 {
 	struct dentry *dir, *file;
-	struct _ddebug *iter, *iter_start;
-	const char *modname = NULL;
-	int ret = 0;
-	int n = 0;
+
+	if (!ddebug_init_success)
+		return -ENODEV;
 
 	dir = debugfs_create_dir("dynamic_debug", NULL);
 	if (!dir)
@@ -765,6 +766,16 @@ static int __init dynamic_debug_init(voi
 		debugfs_remove(dir);
 		return -ENOMEM;
 	}
+	return 0;
+}
+
+static int __init dynamic_debug_init(void)
+{
+	struct _ddebug *iter, *iter_start;
+	const char *modname = NULL;
+	int ret = 0;
+	int n = 0;
+
 	if (__start___verbose != __stop___verbose) {
 		iter = __start___verbose;
 		modname = iter->modname;
@@ -795,11 +806,13 @@ static int __init dynamic_debug_init(voi
 	}
 
 out_free:
-	if (ret) {
+	if (ret)
 		ddebug_remove_all_tables();
-		debugfs_remove(dir);
-		debugfs_remove(file);
-	}
+	else
+		ddebug_init_success = 1;
 	return 0;
 }
-module_init(dynamic_debug_init);
+/* Allow early initialization for boot messages via boot param */
+arch_initcall(dynamic_debug_init);
+/* Debugfs setup must be done later */
+module_init(dynamic_debug_init_debugfs);


      parent reply	other threads:[~2010-07-20 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 13:44 [patch 0/3] Dynamic Debug providing early boot debug messages via boot parameter trenn
2010-07-20 13:44 ` [patch 1/3] Dynamic Debug: Split out query string parsing/setup from proc_write trenn
2010-07-20 13:44 ` [patch 2/3] Dynamic Debug: Introduce ddebug_query= boot parameter trenn
2010-07-20 13:44 ` trenn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100720134730.081078353@ett.arch.suse.de \
    --to=trenn@suse.de \
    --cc=astarikovskiy@novell.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yehuda@hq.newdream.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome