Re: [patch 05/15] Generic Mutex Subsystem, mutex-core.patch




* Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> How expensive is the xchg? Since __mutex_lock_common is called even
> when it's going to wake up. Maybe it might be more efficient to add
> something like:
>
> if (atomic_cmpxchg(&lock->count, 1, 0) {
> debug_set_owner(lock, ti __IP__);
> debug_unlock_irqrestore(&debug_lock, *flags, ti);
> return 1;
> }
>
> This way we save the overhead of grabbing another spinlock, adding the
> task to the wait_list and changing it's state.

in the first pass we definitely need to add ourselves to the list first
- hence have to grab the lock. Even after the schedule(), we have to
xchg it to -1, not 0. This is crutial to 'not drop the ball' property of
one-waiter-in-flight logic - we must not lose the -1 'there are more
waiters pending' property. Plus, we have the grab the lock because we
remove ourselves from the wait-list after the schedule(). So i'm not
sure your suggested optimization is possible.

Ingo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: "scheduling while atomic" ?
    ... >another process that will grab that same spinlock will deadlock the CPU ... >will schedule, and regrab it afterwards. ... I grab a lock using ...
    (Linux-Kernel)
  • Dont contrast soon while youre hunting out of a sure mile.
    ... It can typically grab to humble polite helicopters. ... Edith never shyly depended by the schedule. ... obediently prohibiting superintendent at times my tour. ...
    (sci.crypt)
  • Re: [patch 00/15] Generic Mutex Subsystem
    ... > tries to grab it again, the other CPU will _not_ get it. ... I introduced a "lock stealing" ... The reason is that if you have a high priority process ... So when we have PREEMPT, your fairness is not being very fair. ...
    (Linux-Kernel)
  • Re: Games Im looking forward to today
    ... I ever saw as a F4 lock was UCLA. ... schedule was not quite as bad as you originally stated, ... opinion by adding the phrase "I think". ... Sock - you could have hung in here back in the good ole' days when it ...
    (rec.sport.basketball.college)
  • Re: [PATCH 1/6] kill-the-BKL/reiserfs: release write lock on fs_changed()
    ... batched and you don't release the lock unnecessarily in the unloaded case. ... And I guess this pattern matches most of the cond_resched ... do something that might schedule ... echo schedule> set_ftrace_filter ...
    (Linux-Kernel)