[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <555186f2-8240-f7d0-e1b0-9ad1a67ff34c@huawei.com>
Date: Wed, 6 Sep 2017 08:27:31 +0800
From: "chengjian (D)" <cj.chengjian@...wei.com>
To: Thomas Gleixner <tglx@...utronix.de>
CC: <huawei.libin@...wei.com>, <mingo@...hat.com>,
<peterz@...radead.org>, <dvhart@...radead.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: a competition when some threads acquire futex
>> diff --git a/kernel/futex.c b/kernel/futex.c
>> index 3d38eaf..0b2d17a 100644
>> --- a/kernel/futex.c
>> +++ b/kernel/futex.c
>> @@ -1545,6 +1545,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval,
>> struct futex_pi_state *pi_
>> spin_unlock(&hb->lock);
>> wake_up_q(&wake_q);
>> + _cond_resched( );
>
Hi Thomas,
I wrote _cond_resched( ) in futex_wake( ) which will be called to wake
up waiters
when the process release the futex.
But the patch producted by git format-patch displayed in wake_futex_pi( ).
```c
/*
* Wake up waiters matching bitset queued on this futex (uaddr).
*/
static int
futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)
{
struct futex_hash_bucket *hb;
struct futex_q *this, *next;
union futex_key key = FUTEX_KEY_INIT;
int ret;
DEFINE_WAKE_Q(wake_q);
if (!bitset)
return -EINVAL;
ret = get_futex_key(uaddr, flags & FLAGS_SHARED, &key, VERIFY_READ);
if (unlikely(ret != 0))
goto out;
hb = hash_futex(&key);
/* Make sure we really have tasks to wakeup */
if (!hb_waiters_pending(hb))
goto out_put_key;
spin_lock(&hb->lock);
plist_for_each_entry_safe(this, next, &hb->chain, list) {
if (match_futex (&this->key, &key)) {
if (this->pi_state || this->rt_waiter) {
ret = -EINVAL;
break;
}
/* Check if one of the bits is set in both bitsets */
if (!(this->bitset & bitset))
continue;
mark_wake_futex(&wake_q, this);
if (++ret >= nr_wake)
break;
}
}
spin_unlock(&hb->lock);
wake_up_q(&wake_q);
+ _cond_resched( );
out_put_key:
put_futex_key(&key);
out:
return ret;
}
```
Thanks.
Cheng Jian
Powered by blists - more mailing lists