Skip to contentSkip to conversation

fix printk output

PATCH Superseded Sergei Ianovich 4 participants 7 messages Nov 27, 2013 – Apr 23, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix printk output

---
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +2 -1
index f5a3b1e..6f87299 100644
@@ -817,7 +817,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 
 	if (!(flags & O_NONBLOCK)) {
 		printk(KERN_WARNING
-		       "waiting module removal not supported: please upgrade");
+		       "waiting module removal not supported: "
+		       "please upgrade\n");
 	}
 
 	if (mutex_lock_interruptible(&module_mutex) != 0)
Signature · 1 line
1.8.4.2
#1 lore raw
Quoted 10 lines · Sergei Ianovich
---
 kernel/module.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/module.c +0 -0
index f5a3b1e..6f87299 100644

kernel/module.c SYSCALL_DEFINE2(delete_module, const char __user *, name_user, · line 821

Quoted 6 lines
kernel/module.c +2 -1
@@ -817,7 +817,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 
 	if (!(flags & O_NONBLOCK)) {
 		printk(KERN_WARNING
-		       "waiting module removal not supported: please upgrade");
+		       "waiting module removal not supported: "
+		       "please upgrade\n");

Please don't wrap long lines, even if they exceed the 80 line limit. It makes grepping for them harder.

#2 lore raw

PATCH v2 1/1 fix printk output

CC Hannes Frederic Sowa <[email protected]>

---
Changes v1..v2
* 1-for-1 match between source and output lines
* clarify warning
* print tool name to avoid confusion with what to upgrade

 kernel/module.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/module.c +3 -1
index f5a3b1e..0e627e7 100644
@@ -816,8 +816,10 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 	name[MODULE_NAME_LEN-1] = '\0';
 
 	if (!(flags & O_NONBLOCK)) {
+		char tool[TASK_COMM_LEN];
 		printk(KERN_WARNING
-		       "waiting module removal not supported: please upgrade");
+		       "waiting module removal no longer supported\n"
+		       "please upgrade %s\n", get_task_comm(tool, current));
 	}
 
 	if (mutex_lock_interruptible(&module_mutex) != 0)
Signature · 1 line
1.8.4.3
#3 lore raw
Quoted 7 lines · Sergei Ianovich
CC Hannes Frederic Sowa <[email protected]>

---
Changes v1..v2
* 1-for-1 match between source and output lines
* clarify warning
* print tool name to avoid confusion with what to upgrade

Hmm, the copy here is gratuitous. Using current->comm is safe, just possibly ambigious if someone is changing the task name at the same time.

And we really want this one line anyway:

printk(KERN_WARNING
"%s: waiting module removal not supported: please upgrade\n",

                        current->comm);

BTW, did you actually hit this?

Thanks,
Rusty.

Quoted 21 lines
 kernel/module.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/module.c +3 -1
index f5a3b1e..0e627e7 100644
@@ -816,8 +816,10 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
 	name[MODULE_NAME_LEN-1] = '\0';
 
 	if (!(flags & O_NONBLOCK)) {
+		char tool[TASK_COMM_LEN];
 		printk(KERN_WARNING
-		       "waiting module removal not supported: please upgrade");
+		       "waiting module removal no longer supported\n"
+		       "please upgrade %s\n", get_task_comm(tool, current));
 	}
 
 	if (mutex_lock_interruptible(&module_mutex) != 0)
Signature · 1 line
1.8.4.3
#4 lore raw
Quoted 9 lines · Rusty Russell

Sergei Ianovich <[email protected]> writes:
Hmm, the copy here is gratuitous. Using current->comm is safe, just possibly ambigious if someone is changing the task name at the same time.

And we really want this one line anyway:

printk(KERN_WARNING
"%s: waiting module removal not supported: please upgrade\n",

                        current->comm);

I would put tool's name in the end for clarity. Message comes from the kernel and the kernel recommends to upgrade the tool. "%s: ..." could make the impression that the tool recommends to upgrade the kernel.

Quoted 1 line

BTW, did you actually hit this?

# modprobe usb_storage
[  600.807274] usbcore: registered new interface driver usb-storage
# modprobe -r usb_storage
[  604.216318] waiting module removal not supported: please upgrade[
604.222164] usbcore: deregistering interface driver usb-storage
# modprobe -V
kmod version 9

I am using the latest kmod package from emdebian unstable-grip.

#5 lore raw
Quoted 11 lines · Sergei Ianovich
Quoted 1 line · Rusty Russell

BTW, did you actually hit this?

# modprobe usb_storage
[  600.807274] usbcore: registered new interface driver usb-storage
# modprobe -r usb_storage
[  604.216318] waiting module removal not supported: please upgrade[
604.222164] usbcore: deregistering interface driver usb-storage
# modprobe -V
kmod version 9
Quoted 1 line

I am using the latest kmod package from emdebian unstable-grip.

Sorry, was off on leave.

Hmm, Lucas intimated that kmod version 11 started passing this flag correctly.

In fact, kmod's modprobe *never* used the O_NONBLOCK (ie. KMOD_REMOVE_NOWAIT) flag, until it was finally enforced in

commit 7ab8804448377fb6b8854f2dd288608db01bb43b

Author: Lucas De Marchi <[email protected]>
Date:   Fri Sep 20 01:30:07 2013 -0500

See: tools/modprobe.c at that commit:

        static int rmmod_do_remove_module(struct kmod_module *mod)
        {
        	const char *modname = kmod_module_get_name(mod);
        	struct kmod_list *deps, *itr;
        	int flags = 0, err;
...
        	if (force)
        		flags |= KMOD_REMOVE_FORCE;

        	err = kmod_module_remove_module(mod, flags);

Perhaps we need to just get rid of the kernel message, since we're getting far too many false reports :(

Cheers,
Rusty.

#6 lore raw
Quoted 12 lines · Rusty Russell
Quoted 11 lines · Sergei Ianovich
Quoted 1 line · Rusty Russell

BTW, did you actually hit this?

# modprobe usb_storage
[  600.807274] usbcore: registered new interface driver usb-storage
# modprobe -r usb_storage
[  604.216318] waiting module removal not supported: please upgrade[
604.222164] usbcore: deregistering interface driver usb-storage
# modprobe -V
kmod version 9
Quoted 6 lines
Quoted 1 line

I am using the latest kmod package from emdebian unstable-grip.

Sorry, was off on leave.

Hmm, Lucas intimated that kmod version 11 started passing this flag correctly.

Sorry... rmmod was correctly updated but I forgot modprobe. My bad. Then when I enforced it on libkmod, modprobe ended up doing the right thing.

Quoted 21 lines

In fact, kmod's modprobe *never* used the O_NONBLOCK (ie. KMOD_REMOVE_NOWAIT) flag, until it was finally enforced in

commit 7ab8804448377fb6b8854f2dd288608db01bb43b

Author: Lucas De Marchi <[email protected]>
Date:   Fri Sep 20 01:30:07 2013 -0500

See: tools/modprobe.c at that commit:

        static int rmmod_do_remove_module(struct kmod_module *mod)
        {
                const char *modname = kmod_module_get_name(mod);
                struct kmod_list *deps, *itr;
                int flags = 0, err;
...
                if (force)
                        flags |= KMOD_REMOVE_FORCE;

                err = kmod_module_remove_module(mod, flags);
Quoted 2 lines

Perhaps we need to just get rid of the kernel message, since we're getting far too many false reports :(

Now that I realize only kmod 16 has the fix... maybe. But I think this commit could be easily backported to older versions if distros would like to avoid the upgrade (even if they should not since latest releases were more targeted to bug fixes). I'll try to push this or a similar patch downstream to package maintainers.

Again, sorry about that.

Lucas De Marchi