* Ingo Molnar <mingo@elte.hu> wrote:Peter pointed it out that because sem->count is u32, the <= 0 is in fact a "== 0" condition - the patch below does that. As expected gcc figured out the same thing too so the resulting code output did not change. (so this is just a cleanup) i've got this lined up in sched.git and it's undergoing testing right now. If that testing goes fine and if there are no objections i'll send a pull request for it later today. Ingo ----------------> Subject: semaphores: improve code From: Ingo Molnar <mingo@elte.hu> Date: Thu May 08 14:19:23 CEST 2008 No code changed: kernel/semaphore.o: text data bss dec hex filename 1207 0 0 1207 4b7 semaphore.o.before 1207 0 0 1207 4b7 semaphore.o.after md5: c10198c2952bd345a1edaac6db891548 semaphore.o.before.asm c10198c2952bd345a1edaac6db891548 semaphore.o.after.asm Signed-off-by: Ingo Molnar <mingo@elte.hu> --- kernel/semaphore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) Index: linux/kernel/semaphore.c =================================================================== --- linux.orig/kernel/semaphore.c +++ linux/kernel/semaphore.c @@ -54,7 +54,7 @@ void down(struct semaphore *sem) unsigned long flags; spin_lock_irqsave(&sem->lock, flags); - if (unlikely(sem->count <= 0)) + if (unlikely(!sem->count)) __down(sem); sem->count--; spin_unlock_irqrestore(&sem->lock, flags); @@ -76,7 +76,7 @@ int down_interruptible(struct semaphore int result = 0; spin_lock_irqsave(&sem->lock, flags); - if (unlikely(sem->count <= 0)) + if (unlikely(!sem->count)) result = __down_interruptible(sem); if (!result) sem->count--; @@ -102,7 +102,7 @@ int down_killable(struct semaphore *sem) int result = 0; spin_lock_irqsave(&sem->lock, flags); - if (unlikely(sem->count <= 0)) + if (unlikely(!sem->count)) result = __down_killable(sem); if (!result) sem->count--; @@ -156,7 +156,7 @@ int down_timeout(struct semaphore *sem, int result = 0; spin_lock_irqsave(&sem->lock, flags); - if (unlikely(sem->count <= 0)) + if (unlikely(!sem->count)) result = __down_timeout(sem, jiffies); if (!result) sem->count--; --
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| James Bottomley | Re: Integration of SCST in the mainstream Linux kernel |
| Stephen Rothwell | Re: Announce: Linux-next (Or Andrew's dream :-)) |
| Arjan van de Ven | Re: [malware-list] [RFC 0/5] [TALPA] Intro to a linux interfaceforon access scanning |
| Patrick McHardy | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Eric W. Biederman | Re: namespace support requires network modules to say "GPL" |
git: | |
