All of lore.kernel.org
 help / color / mirror / Atom feed
From: Waiman Long <llong@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Waiman Long <llong@redhat.com>,
	Xiaoming Ni <nixiaoming@huawei.com>,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com
Cc: wangle6@huawei.com, xiaoqian9@huawei.com, shaolexi@huawei.com
Subject: Re: [PATCH] semaphore: Add might_sleep() to down_*() family
Date: Fri, 13 Aug 2021 14:47:35 -0400	[thread overview]
Message-ID: <41bddbee-948a-987c-eb72-108a465a7082@redhat.com> (raw)
In-Reply-To: <877dgpp852.ffs@tglx>

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


  reply	other threads:[~2021-08-13 18:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-09  2:12 [PATCH] semaphore: Add might_sleep() to down_*() family Xiaoming Ni
2021-08-09  3:01 ` Waiman Long
2021-08-09  3:51   ` Xiaoming Ni
2021-08-09 12:52     ` Waiman Long
2021-08-09 14:33       ` Xiaoming Ni
2021-08-13 17:27   ` Thomas Gleixner
2021-08-13 18:47     ` Waiman Long [this message]
2021-08-13 14:43 ` Will Deacon
2021-08-23  9:39 ` [tip: locking/core] locking/semaphore: " tip-bot2 for Xiaoming Ni
2021-08-31 11:13 ` [PATCH] semaphore: " Guenter Roeck
2021-08-31 11:39   ` Hanjun Guo
2021-08-31 12:20     ` Thomas Gleixner
2021-08-31 11:40   ` Peter Zijlstra
2021-08-31 12:13   ` Thomas Gleixner
2021-08-31 12:34     ` Will Deacon
2021-08-31 17:42     ` Guenter Roeck
2021-09-01  8:37     ` [tip: smp/urgent] drivers: base: cacheinfo: Get rid of DEFINE_SMP_CALL_CACHE_FUNCTION() tip-bot2 for Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41bddbee-948a-987c-eb72-108a465a7082@redhat.com \
    --to=llong@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=nixiaoming@huawei.com \
    --cc=peterz@infradead.org \
    --cc=shaolexi@huawei.com \
    --cc=tglx@linutronix.de \
    --cc=wangle6@huawei.com \
    --cc=will@kernel.org \
    --cc=xiaoqian9@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.