diff options
author | akpm@osdl.org <akpm@osdl.org> | 2005-05-01 11:58:47 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-01 11:58:47 -0400 |
commit | d59dd4620fb8d6422555a9e2b82a707718e68327 (patch) | |
tree | 78205657d24efcaa3f8314064951ac3814ed95a7 /kernel | |
parent | 0d8d4d42f2d00eb65262b49f4edd4cf7ef4eb6fc (diff) |
[PATCH] use smp_mb/wmb/rmb where possible
Replace a number of memory barriers with smp_ variants. This means we won't
take the unnecessary hit on UP machines.
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/kthread.c | 2 | ||||
-rw-r--r-- | kernel/profile.c | 2 | ||||
-rw-r--r-- | kernel/ptrace.c | 2 | ||||
-rw-r--r-- | kernel/stop_machine.c | 10 | ||||
-rw-r--r-- | kernel/sys.c | 20 | ||||
-rw-r--r-- | kernel/timer.c | 2 |
6 files changed, 19 insertions, 19 deletions
diff --git a/kernel/kthread.c b/kernel/kthread.c index e377e2244103..f50f174e92da 100644 --- a/kernel/kthread.c +++ b/kernel/kthread.c | |||
@@ -174,7 +174,7 @@ int kthread_stop(struct task_struct *k) | |||
174 | 174 | ||
175 | /* Must init completion *before* thread sees kthread_stop_info.k */ | 175 | /* Must init completion *before* thread sees kthread_stop_info.k */ |
176 | init_completion(&kthread_stop_info.done); | 176 | init_completion(&kthread_stop_info.done); |
177 | wmb(); | 177 | smp_wmb(); |
178 | 178 | ||
179 | /* Now set kthread_should_stop() to true, and wake it up. */ | 179 | /* Now set kthread_should_stop() to true, and wake it up. */ |
180 | kthread_stop_info.k = k; | 180 | kthread_stop_info.k = k; |
diff --git a/kernel/profile.c b/kernel/profile.c index a38fa70075fe..a66be468c422 100644 --- a/kernel/profile.c +++ b/kernel/profile.c | |||
@@ -522,7 +522,7 @@ static int __init create_hash_tables(void) | |||
522 | return 0; | 522 | return 0; |
523 | out_cleanup: | 523 | out_cleanup: |
524 | prof_on = 0; | 524 | prof_on = 0; |
525 | mb(); | 525 | smp_mb(); |
526 | on_each_cpu(profile_nop, NULL, 0, 1); | 526 | on_each_cpu(profile_nop, NULL, 0, 1); |
527 | for_each_online_cpu(cpu) { | 527 | for_each_online_cpu(cpu) { |
528 | struct page *page; | 528 | struct page *page; |
diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 88b306c4e841..f5cc1cec0fb4 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c | |||
@@ -135,7 +135,7 @@ int ptrace_attach(struct task_struct *task) | |||
135 | (current->gid != task->sgid) || | 135 | (current->gid != task->sgid) || |
136 | (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) | 136 | (current->gid != task->gid)) && !capable(CAP_SYS_PTRACE)) |
137 | goto bad; | 137 | goto bad; |
138 | rmb(); | 138 | smp_rmb(); |
139 | if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) | 139 | if (!task->mm->dumpable && !capable(CAP_SYS_PTRACE)) |
140 | goto bad; | 140 | goto bad; |
141 | /* the same process cannot be attached many times */ | 141 | /* the same process cannot be attached many times */ |
diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c index c39ed70af174..6116b25aa7cf 100644 --- a/kernel/stop_machine.c +++ b/kernel/stop_machine.c | |||
@@ -33,7 +33,7 @@ static int stopmachine(void *cpu) | |||
33 | set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); | 33 | set_cpus_allowed(current, cpumask_of_cpu((int)(long)cpu)); |
34 | 34 | ||
35 | /* Ack: we are alive */ | 35 | /* Ack: we are alive */ |
36 | mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ | 36 | smp_mb(); /* Theoretically the ack = 0 might not be on this CPU yet. */ |
37 | atomic_inc(&stopmachine_thread_ack); | 37 | atomic_inc(&stopmachine_thread_ack); |
38 | 38 | ||
39 | /* Simple state machine */ | 39 | /* Simple state machine */ |
@@ -43,14 +43,14 @@ static int stopmachine(void *cpu) | |||
43 | local_irq_disable(); | 43 | local_irq_disable(); |
44 | irqs_disabled = 1; | 44 | irqs_disabled = 1; |
45 | /* Ack: irqs disabled. */ | 45 | /* Ack: irqs disabled. */ |
46 | mb(); /* Must read state first. */ | 46 | smp_mb(); /* Must read state first. */ |
47 | atomic_inc(&stopmachine_thread_ack); | 47 | atomic_inc(&stopmachine_thread_ack); |
48 | } else if (stopmachine_state == STOPMACHINE_PREPARE | 48 | } else if (stopmachine_state == STOPMACHINE_PREPARE |
49 | && !prepared) { | 49 | && !prepared) { |
50 | /* Everyone is in place, hold CPU. */ | 50 | /* Everyone is in place, hold CPU. */ |
51 | preempt_disable(); | 51 | preempt_disable(); |
52 | prepared = 1; | 52 | prepared = 1; |
53 | mb(); /* Must read state first. */ | 53 | smp_mb(); /* Must read state first. */ |
54 | atomic_inc(&stopmachine_thread_ack); | 54 | atomic_inc(&stopmachine_thread_ack); |
55 | } | 55 | } |
56 | /* Yield in first stage: migration threads need to | 56 | /* Yield in first stage: migration threads need to |
@@ -62,7 +62,7 @@ static int stopmachine(void *cpu) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* Ack: we are exiting. */ | 64 | /* Ack: we are exiting. */ |
65 | mb(); /* Must read state first. */ | 65 | smp_mb(); /* Must read state first. */ |
66 | atomic_inc(&stopmachine_thread_ack); | 66 | atomic_inc(&stopmachine_thread_ack); |
67 | 67 | ||
68 | if (irqs_disabled) | 68 | if (irqs_disabled) |
@@ -77,7 +77,7 @@ static int stopmachine(void *cpu) | |||
77 | static void stopmachine_set_state(enum stopmachine_state state) | 77 | static void stopmachine_set_state(enum stopmachine_state state) |
78 | { | 78 | { |
79 | atomic_set(&stopmachine_thread_ack, 0); | 79 | atomic_set(&stopmachine_thread_ack, 0); |
80 | wmb(); | 80 | smp_wmb(); |
81 | stopmachine_state = state; | 81 | stopmachine_state = state; |
82 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) | 82 | while (atomic_read(&stopmachine_thread_ack) != stopmachine_num_threads) |
83 | cpu_relax(); | 83 | cpu_relax(); |
diff --git a/kernel/sys.c b/kernel/sys.c index 462d78d55895..df2ddcc6863b 100644 --- a/kernel/sys.c +++ b/kernel/sys.c | |||
@@ -525,7 +525,7 @@ asmlinkage long sys_setregid(gid_t rgid, gid_t egid) | |||
525 | if (new_egid != old_egid) | 525 | if (new_egid != old_egid) |
526 | { | 526 | { |
527 | current->mm->dumpable = 0; | 527 | current->mm->dumpable = 0; |
528 | wmb(); | 528 | smp_wmb(); |
529 | } | 529 | } |
530 | if (rgid != (gid_t) -1 || | 530 | if (rgid != (gid_t) -1 || |
531 | (egid != (gid_t) -1 && egid != old_rgid)) | 531 | (egid != (gid_t) -1 && egid != old_rgid)) |
@@ -556,7 +556,7 @@ asmlinkage long sys_setgid(gid_t gid) | |||
556 | if(old_egid != gid) | 556 | if(old_egid != gid) |
557 | { | 557 | { |
558 | current->mm->dumpable=0; | 558 | current->mm->dumpable=0; |
559 | wmb(); | 559 | smp_wmb(); |
560 | } | 560 | } |
561 | current->gid = current->egid = current->sgid = current->fsgid = gid; | 561 | current->gid = current->egid = current->sgid = current->fsgid = gid; |
562 | } | 562 | } |
@@ -565,7 +565,7 @@ asmlinkage long sys_setgid(gid_t gid) | |||
565 | if(old_egid != gid) | 565 | if(old_egid != gid) |
566 | { | 566 | { |
567 | current->mm->dumpable=0; | 567 | current->mm->dumpable=0; |
568 | wmb(); | 568 | smp_wmb(); |
569 | } | 569 | } |
570 | current->egid = current->fsgid = gid; | 570 | current->egid = current->fsgid = gid; |
571 | } | 571 | } |
@@ -596,7 +596,7 @@ static int set_user(uid_t new_ruid, int dumpclear) | |||
596 | if(dumpclear) | 596 | if(dumpclear) |
597 | { | 597 | { |
598 | current->mm->dumpable = 0; | 598 | current->mm->dumpable = 0; |
599 | wmb(); | 599 | smp_wmb(); |
600 | } | 600 | } |
601 | current->uid = new_ruid; | 601 | current->uid = new_ruid; |
602 | return 0; | 602 | return 0; |
@@ -653,7 +653,7 @@ asmlinkage long sys_setreuid(uid_t ruid, uid_t euid) | |||
653 | if (new_euid != old_euid) | 653 | if (new_euid != old_euid) |
654 | { | 654 | { |
655 | current->mm->dumpable=0; | 655 | current->mm->dumpable=0; |
656 | wmb(); | 656 | smp_wmb(); |
657 | } | 657 | } |
658 | current->fsuid = current->euid = new_euid; | 658 | current->fsuid = current->euid = new_euid; |
659 | if (ruid != (uid_t) -1 || | 659 | if (ruid != (uid_t) -1 || |
@@ -703,7 +703,7 @@ asmlinkage long sys_setuid(uid_t uid) | |||
703 | if (old_euid != uid) | 703 | if (old_euid != uid) |
704 | { | 704 | { |
705 | current->mm->dumpable = 0; | 705 | current->mm->dumpable = 0; |
706 | wmb(); | 706 | smp_wmb(); |
707 | } | 707 | } |
708 | current->fsuid = current->euid = uid; | 708 | current->fsuid = current->euid = uid; |
709 | current->suid = new_suid; | 709 | current->suid = new_suid; |
@@ -748,7 +748,7 @@ asmlinkage long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid) | |||
748 | if (euid != current->euid) | 748 | if (euid != current->euid) |
749 | { | 749 | { |
750 | current->mm->dumpable = 0; | 750 | current->mm->dumpable = 0; |
751 | wmb(); | 751 | smp_wmb(); |
752 | } | 752 | } |
753 | current->euid = euid; | 753 | current->euid = euid; |
754 | } | 754 | } |
@@ -798,7 +798,7 @@ asmlinkage long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid) | |||
798 | if (egid != current->egid) | 798 | if (egid != current->egid) |
799 | { | 799 | { |
800 | current->mm->dumpable = 0; | 800 | current->mm->dumpable = 0; |
801 | wmb(); | 801 | smp_wmb(); |
802 | } | 802 | } |
803 | current->egid = egid; | 803 | current->egid = egid; |
804 | } | 804 | } |
@@ -845,7 +845,7 @@ asmlinkage long sys_setfsuid(uid_t uid) | |||
845 | if (uid != old_fsuid) | 845 | if (uid != old_fsuid) |
846 | { | 846 | { |
847 | current->mm->dumpable = 0; | 847 | current->mm->dumpable = 0; |
848 | wmb(); | 848 | smp_wmb(); |
849 | } | 849 | } |
850 | current->fsuid = uid; | 850 | current->fsuid = uid; |
851 | } | 851 | } |
@@ -875,7 +875,7 @@ asmlinkage long sys_setfsgid(gid_t gid) | |||
875 | if (gid != old_fsgid) | 875 | if (gid != old_fsgid) |
876 | { | 876 | { |
877 | current->mm->dumpable = 0; | 877 | current->mm->dumpable = 0; |
878 | wmb(); | 878 | smp_wmb(); |
879 | } | 879 | } |
880 | current->fsgid = gid; | 880 | current->fsgid = gid; |
881 | key_fsgid_changed(current); | 881 | key_fsgid_changed(current); |
diff --git a/kernel/timer.c b/kernel/timer.c index ecb3d67c0e14..207aa4f0aa10 100644 --- a/kernel/timer.c +++ b/kernel/timer.c | |||
@@ -1007,7 +1007,7 @@ asmlinkage long sys_getppid(void) | |||
1007 | * Make sure we read the pid before re-reading the | 1007 | * Make sure we read the pid before re-reading the |
1008 | * parent pointer: | 1008 | * parent pointer: |
1009 | */ | 1009 | */ |
1010 | rmb(); | 1010 | smp_rmb(); |
1011 | parent = me->group_leader->real_parent; | 1011 | parent = me->group_leader->real_parent; |
1012 | if (old != parent) | 1012 | if (old != parent) |
1013 | continue; | 1013 | continue; |