Skip to contentSkip to conversation

make elv_register() output atomic

PATCH In review Thibaut VARENE 2 participants 2 messages Mar 8, 2007 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 make elv_register() output atomic

Hi,

Booting 2.6.21-rc3-g45592145 I noticed the following on one of my machines in the bootlog:

io scheduler noop registered<6>Time: jiffies clocksource has been installed.

io scheduler deadline registered (default)

Looking at block/elevator.c, it appears that elv_register() uses two consecutive printks in a non-atomic way, leading to the above glitch. The attached trivial patch fixes this issue, by using a single printk.

HTH

T-Bone

PS: please CC-me in replies.

Signature · 2 lines
Thibaut VARENE
http://www.parisc-linux.org/~varenet/
block/elevator.c +4 -3
index 25f6ef2..96a00c8 100644
@@ -964,17 +964,18 @@ void elv_unregister_queue(struct request_queue *q)
 
 int elv_register(struct elevator_type *e)
 {
+	char *def = "";
 	spin_lock_irq(&elv_list_lock);
 	BUG_ON(elevator_find(e->elevator_name));
 	list_add_tail(&e->list, &elv_list);
 	spin_unlock_irq(&elv_list_lock);
 
-	printk(KERN_INFO "io scheduler %s registered", e->elevator_name);
 	if (!strcmp(e->elevator_name, chosen_elevator) ||
 			(!*chosen_elevator &&
 			 !strcmp(e->elevator_name, CONFIG_DEFAULT_IOSCHED)))
-				printk(" (default)");
-	printk("\n");
+				def = " (default)";
+
+	printk(KERN_INFO "io scheduler %s registered%s\n", e->elevator_name, def);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(elv_register);
#1 lore raw
Quoted 5 lines · Thibaut VARENE

Hi,

Booting 2.6.21-rc3-g45592145 I noticed the following on one of my machines in the bootlog:

Quoted 8 lines

io scheduler noop registered<6>Time: jiffies clocksource has been installed.

io scheduler deadline registered (default)

Looking at block/elevator.c, it appears that elv_register() uses two consecutive printks in a non-atomic way, leading to the above glitch. The attached trivial patch fixes this issue, by using a single printk.

Thanks, looks like a good fix!

Signature · 1 line
Jens Axboe