lkml.org 
[lkml]   [2008]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    SubjectRe: [patch] speed up / fix the new generic semaphore code (fix AIM7 40% regression with 2.6.26-rc1)

    * Ingo Molnar <mingo@elte.hu> wrote:

    > + if (unlikely(sem->count <= 0))
    > __down(sem);
    > + sem->count--;

    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--;

    \
     
     \ /
      Last update: 2008-05-08 14:31    [W:4.498 / U:0.108 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site