lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <41bddbee-948a-987c-eb72-108a465a7082@redhat.com>
Date:   Fri, 13 Aug 2021 14:47:35 -0400
From:   Waiman Long <llong@...hat.com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Waiman Long <llong@...hat.com>,
        Xiaoming Ni <nixiaoming@...wei.com>,
        linux-kernel@...r.kernel.org, peterz@...radead.org,
        mingo@...hat.com, will@...nel.org, boqun.feng@...il.com
Cc:     wangle6@...wei.com, xiaoqian9@...wei.com, shaolexi@...wei.com
Subject: Re: [PATCH] semaphore: Add might_sleep() to down_*() family

On 8/13/21 1:27 PM, Thomas Gleixner wrote:
> On Sun, Aug 08 2021 at 23:01, Waiman Long wrote:
>> On 8/8/21 10:12 PM, Xiaoming Ni wrote:
>>> Semaphore is sleeping lock. Add might_sleep() to down*() family
>>> (with exception of down_trylock()) to detect atomic context sleep.
>>> @@ -157,6 +160,7 @@ int down_timeout(struct semaphore *sem, long timeout)
>>>    	unsigned long flags;
>>>    	int result = 0;
>>>    
>>> +	might_sleep();
>>>    	raw_spin_lock_irqsave(&sem->lock, flags);
>>>    	if (likely(sem->count > 0))
>>>    		sem->count--;
>> I think it is simpler to just put a "might_sleep()" in __down_common()
>> which is the function where sleep can actually happen.
> No. Putting it in __down_common() is wrong, because that covers only the
> contended case.
>
> But we want to cover the potential sleep, i.e. checking even in the
> non-contended case, which is what might_sleep() is about.

You are right. Thanks for the correction.

Cheers,
Longman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ