[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <PH0PR11MB5880A552E7A3856D8F9165FBDA799@PH0PR11MB5880.namprd11.prod.outlook.com>
Date: Sat, 18 Dec 2021 07:24:07 +0000
From: "Zhang, Qiang1" <qiang1.zhang@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>,
"peterz@...radead.org" <peterz@...radead.org>,
"mingo@...hat.com" <mingo@...hat.com>,
"will@...nel.org" <will@...nel.org>,
"longman@...hat.com" <longman@...hat.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Zhang, Qiang1" <qiang1.zhang@...el.com>
Subject: RE: [PATCH v2] locking/rtmutex: Fix incorrect spinning condition
-----Original Message-----
From: Thomas Gleixner <tglx@...utronix.de>
Sent: 2021年12月18日 4:53
To: Zhang, Qiang1 <qiang1.zhang@...el.com>; peterz@...radead.org; mingo@...hat.com; will@...nel.org; longman@...hat.com
Cc: linux-kernel@...r.kernel.org; Zhang, Qiang1 <qiang1.zhang@...el.com>
Subject: Re: [PATCH v2] locking/rtmutex: Fix incorrect spinning condition
Zqiang,
On Fri, Dec 17 2021 at 15:42, Zqiang wrote:
> When the lock owner is on CPU and not need resched, the current waiter
> need to be checked, if it not longer top the waiter, stop spinning.
>
> Fixes: c3123c431447 ("locking/rtmutex: Dont dereference waiter lockless")
> Signed-off-by: Zqiang <qiang1.zhang@...el.com>
> ---
> v1->v2:
> Modify description information.
>
> kernel/locking/rtmutex.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
> index 0c1f2e3f019a..8555c4efe97c 100644
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -1383,7 +1383,7 @@ static bool rtmutex_spin_on_owner(struct rt_mutex_base *lock,
> * - the VCPU on which owner runs is preempted
> */
> if (!owner_on_cpu(owner) || need_resched() ||
> - rt_mutex_waiter_is_top_waiter(lock, waiter)) {
> + !rt_mutex_waiter_is_top_waiter(lock, waiter)) {
> res = false;
> break;
>
>good catch!
>
>Though this does not apply because the condition is incomplete. You
>somehow dropped this from the condition:
>
> vcpu_is_preempted(task_cpu(owner)))
>
>Please make always sure that your patches apply against Linus tree
>before sending them out.
This commit c0bed69daf4b ("locking: Make owner_on_cpu() into <linux/sched.h>")
make the following modifications in latest linux-next.
+static inline bool owner_on_cpu(struct task_struct *owner)
+{
+ /*
+ * As lock holder preemption issue, we both skip spinning if
+ * task is not on cpu or its cpu is preempted
+ */
+ return owner->on_cpu && !vcpu_is_preempted(task_cpu(owner));
+}
+
Thanks
Zqiang
>
>Thanks,
>
> tglx
Powered by blists - more mailing lists