linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Waiman Long' <longman@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
	Jann Horn <jannh@google.com>,
	Vasiliy Kulikov <segoon@openwall.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Bernd Edlinger <bernd.edlinger@hotmail.de>,
	Oleg Nesterov <oleg@redhat.com>,
	"Christopher Yeoh" <cyeoh@au1.ibm.com>,
	Cyrill Gorcunov <gorcunov@gmail.com>,
	"Sargun Dhillon" <sargun@sargun.me>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Arnaldo Carvalho de Melo <acme@kernel.org>
Subject: RE: [PATCH 2/3] rwsem: Implement down_read_interruptible
Date: Tue, 8 Dec 2020 16:23:50 +0000	[thread overview]
Message-ID: <1be90b66dfe84a4c8a1e65bd40692c57@AcuMS.aculab.com> (raw)
In-Reply-To: <edfd0eb8-192e-60be-f0ca-2a72a26caa07@redhat.com>

From: Waiman Long
> Sent: 08 December 2020 15:34
> 
> On 12/8/20 4:12 AM, David Laight wrote:
> > From: Waiman Long
> >> Sent: 07 December 2020 19:02
> > ...
> >>> How much more difficult would it be to also add a timeout option?
> >>> I looked at adding one to the mutex code - and fell into a big pile
> >>> of replicated code.
> >>>
> >>> ISTM that one the initial locked exchange (and spin) fails a few
> >>> extra instructions when heading for the sleep don't really matter
> >>>
> >> Actually, I had tried that before. See
> >>
> >> https://lore.kernel.org/lkml/20190911150537.19527-1-longman@redhat.com/
> >>
> >> That is for rwsem, but the same can be done for mutex. However, Peter
> >> didn't seem to like the idea of a timeout parameter. Anyway, it is
> >> certainly doable if there is a good use case for it.
> > 'Unfortunately' my use-case if for an out-of-tree driver.
> >
> > The problem I was solving is a status call blocking because
> > some other code is 'stuck' (probably an oops) with a mutex held.
> >
> > The code used to use down_timeout() (it was written for 2.4).
> > When I changed to mutex_(to get optimistic spinning) I lost
> > the ability to do the timeouts.
> 
> The primary reason for sending out that patchset was to work around some
> circular locking problem in existing code even though these circular
> locking scenarios are not likely to happen. Your case is certainly
> another potential circular locking problem as well.

If you've got lock-ordering problems they need fixing.
Neither signals nor timeouts are real solutions.
Either may help diagnose the problem, but they aren't fixes.

OTOH if it reasonable to have a request interrupted by a signal
it must also be reasonable to implement a timeout.
Of course, one might wonder whether 'correct' code should ever
be waiting on a mutex for any length of time.
So is there even a justification for interruptible waits for mutex.

FWIW I could implement my timeouts using SIGALARM - but it is a lot
of work :-)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2020-12-08 16:25 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 20:09 [PATCH 0/3] exec: Transform exec_update_mutex into a rw_semaphore Eric W. Biederman
2020-12-03 20:10 ` [PATCH 1/3] rwsem: Implement down_read_killable_nested Eric W. Biederman
2020-12-04  1:58   ` Waiman Long
2020-12-09 18:38   ` [tip: locking/core] " tip-bot2 for Eric W. Biederman
2020-12-03 20:11 ` [PATCH 2/3] rwsem: Implement down_read_interruptible Eric W. Biederman
2020-12-04  1:59   ` Waiman Long
2020-12-07  9:02     ` Peter Zijlstra
2020-12-07 15:33       ` Waiman Long
2020-12-07 16:58         ` David Laight
2020-12-07 19:02           ` Waiman Long
2020-12-08  9:12             ` David Laight
2020-12-08 12:32               ` Peter Zijlstra
2020-12-08 13:13                 ` David Laight
2020-12-08 15:34               ` Waiman Long
2020-12-08 16:23                 ` David Laight [this message]
2020-12-07 15:56       ` Eric W. Biederman
2020-12-08 14:52         ` Peter Zijlstra
2020-12-08 18:27           ` Eric W. Biederman
2020-12-09 18:36             ` Peter Zijlstra
2020-12-10 19:33               ` Eric W. Biederman
2020-12-11  8:16                 ` Peter Zijlstra
2020-12-09 18:38       ` [tip: locking/core] locking/rwsem: Introduce rwsem_write_trylock() tip-bot2 for Peter Zijlstra
2020-12-09 18:38       ` [tip: locking/core] locking/rwsem: Fold __down_{read,write}*() tip-bot2 for Peter Zijlstra
2020-12-09 18:38       ` [tip: locking/core] locking/rwsem: Better collate rwsem_read_trylock() tip-bot2 for Peter Zijlstra
2020-12-09 18:38   ` [tip: locking/core] rwsem: Implement down_read_interruptible tip-bot2 for Eric W. Biederman
2020-12-03 20:12 ` [PATCH 3/3] exec: Transform exec_update_mutex into a rw_semaphore Eric W. Biederman
2020-12-04 16:08   ` Bernd Edlinger
2020-12-04 17:21     ` Linus Torvalds
2020-12-04 19:34       ` Eric W. Biederman
2020-12-04 20:10         ` Linus Torvalds
2020-12-04 20:30           ` Bernd Edlinger
2020-12-04 20:48             ` Linus Torvalds
2020-12-04 21:48               ` Davidlohr Bueso
2020-12-05 18:05                 ` Eric W. Biederman
2020-12-07  9:15                   ` Peter Zijlstra
2020-12-07  9:09               ` Peter Zijlstra
2020-12-07 18:40                 ` Linus Torvalds
2020-12-08  8:34                   ` [PATCH] perf: Break deadlock involving exec_update_mutex Peter Zijlstra
2020-12-08 18:37                     ` Linus Torvalds
2020-12-10 18:38                     ` Davidlohr Bueso
2020-12-10 19:40                       ` Eric W. Biederman
2020-12-05 17:43           ` [PATCH 3/3] exec: Transform exec_update_mutex into a rw_semaphore Eric W. Biederman
2020-12-04 17:39     ` Eric W. Biederman
2020-12-03 22:42 ` [PATCH 0/3] " Linus Torvalds
2020-12-04  1:56   ` Waiman Long
2020-12-04  4:54   ` Davidlohr Bueso

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=1be90b66dfe84a4c8a1e65bd40692c57@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=acme@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bernd.edlinger@hotmail.de \
    --cc=christian.brauner@ubuntu.com \
    --cc=cyeoh@au1.ibm.com \
    --cc=ebiederm@xmission.com \
    --cc=gorcunov@gmail.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sargun@sargun.me \
    --cc=segoon@openwall.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).