mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Hillf Danton <hdanton@sina.com>, Mukesh Ojha <quic_mojha@quicinc.com>
Cc: linux-kernel@vger.kernel.org, john.p.donnelly@oracle.com,
	linux-mm@kvack.org, Peter Zijlstra <peterz@infradead.org>,
	Will Deacon <will@kernel.org>, Boqun Feng <boqun.feng@gmail.com>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] locking/rwsem: Prevent non-first waiter from spinning in down_write() slowpath
Date: Wed, 12 Oct 2022 09:19:53 -0400	[thread overview]
Message-ID: <c8b590a0-3535-51f1-3c7d-a67da4bcfc5e@redhat.com> (raw)
In-Reply-To: <20221012040410.403-1-hdanton@sina.com>

On 10/12/22 00:04, Hillf Danton wrote:
>> you mean, you want to check and change waiter->handoff_set on every run
>> rwsem_try_write_lock().
>>
> Yes, with RWSEM_FLAG_HANDOFF set, it is too late for non first waiters to
> spin, and with both RWSEM_LOCK_MASK and RWSEM_FLAG_HANDOFF set, the rivals
> in the RWSEM_LOCK_MASK have an uphand over the first waiter wrt acquiring
> the lock, and it is not a bad option for the first waiter to take a step
> back off.
>
> 		if (count & RWSEM_LOCK_MASK) {
> 			if (has_handoff || (!rt_task(waiter->task) &&
> 					    !time_after(jiffies, waiter->timeout)))
> 				return false;
>
> 			new |= RWSEM_FLAG_HANDOFF;
> 		} else {
>
>> But does it break optimistic spinning ? @waiman ?
> Waiters spin for acquiring lock instead of lockup and your report shows
> spinning too much makes trouble. The key is stop spinning neither too
> late nor too early. My proposal is a simple one with as few heuristics
> added as possible.

Yes, too much spinning is bad if we have RT tasks in the mix, otherwise 
it should be fine.

Cheers,
Longman


       reply	other threads:[~2022-10-12 13:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221012040410.403-1-hdanton@sina.com>
2022-10-12 13:19 ` Waiman Long [this message]
2022-10-12 13:42 ` Mukesh Ojha
     [not found] <20221011104621.231-1-hdanton@sina.com>
2022-10-11 13:16 ` Mukesh Ojha
2022-10-12 13:16   ` Waiman Long
2022-10-12 13:14 ` Waiman Long
2022-09-29 18:04 Waiman Long
2022-09-29 18:06 ` Waiman Long
2022-09-30  4:47   ` Mukesh Ojha
2022-10-10 10:24   ` Mukesh Ojha
2022-10-10 16:57     ` Waiman Long
     [not found]       ` <03421f0e453143f6ae4a9a7a8a4f47f4@xiaomi.com>
     [not found]         ` <446288c6c7db4ab2b23f7041baa62335@xiaomi.com>
2022-10-12 13:21           ` Waiman Long
2022-09-29 21:15 ` John Donnelly
2022-09-30  1:09   ` Waiman Long
2022-09-30  4:46 ` Mukesh Ojha
2022-09-30 13:57   ` Waiman Long
2022-09-30  5:06 ` Mukesh Ojha
2022-09-30 14:08   ` Waiman Long
2022-09-30 16:03     ` Mukesh Ojha

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=c8b590a0-3535-51f1-3c7d-a67da4bcfc5e@redhat.com \
    --to=longman@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=hdanton@sina.com \
    --cc=john.p.donnelly@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=quic_mojha@quicinc.com \
    --cc=will@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®