]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
md: avoid potential long delay under pers_lock
authorChao Yu <chao2.yu@samsung.com>
Thu, 25 Sep 2014 07:28:34 +0000 (15:28 +0800)
committerNeilBrown <neilb@suse.de>
Tue, 14 Oct 2014 02:08:28 +0000 (13:08 +1100)
printk may cause long time lapse if value of printk_delay in sysctl is
configured large by user. If register_md_personality takes long time to print in
spinlock pers_lock, we may encounter high CPU usage rate when there are other
pers_lock competitors who may be blocked to spin.
We can avoid this condition by moving printk out of coverage of pers_lock
spinlock.

Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/md.c

index d96aa809473662997b764c1c95b8fa6df8ef4596..d3a33a95e527c507ac61ac47b8e5bfb6b9b4a2f4 100644 (file)
@@ -7187,9 +7187,10 @@ static const struct file_operations md_seq_fops = {
 
 int register_md_personality(struct md_personality *p)
 {
+       printk(KERN_INFO "md: %s personality registered for level %d\n",
+                                               p->name, p->level);
        spin_lock(&pers_lock);
        list_add_tail(&p->list, &pers_list);
-       printk(KERN_INFO "md: %s personality registered for level %d\n", p->name, p->level);
        spin_unlock(&pers_lock);
        return 0;
 }