Re: [PATCH v4] printk: Add console owner and waiter logic to load balance console writes

From: Sergey Senozhatsky
Date: Tue Dec 12 2017 - 00:39:48 EST


Hello,

On (12/08/17 15:00), Petr Mladek wrote:
[..]
> > However, now that cross-release was introduces, lockdep can be applied
> > to semaphore operations. Actually, I have a plan to do that. I think it
> > would be better to make semaphore tracked with lockdep and remove all
> > these manual acquire() and release() here. What do you think about it?
>
> IMHO, it would be great to add lockdep annotations into semaphore
> operations.

certain types of locks have no guaranteed lock-unlock ordering.
e.g. readers-writer locks, semaphores, etc.

for readers-writer lock we can easily have

CPU0 CPU1 CPU2 CPU3 CPU4
read_lock
write_lock
// sleep because
// of CPU0
read_lock
read_unlock read_lock
read_unlock read_lock
read_unlock
read_unlock
// wake up CPU1

so for CPU1 the lock was "locked" by CPU0 and "unlocked" by CPU4.

semaphore not necessarily has the mutual-exclusion property, because
its ->count is not required to be set to 1. in printk we use semaphore
with ->count == 1, but that's just an accident.

-ss


p.s.
frankly, I don't see any "locking issues" in Steven's patch.