linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Mel Gorman <mgorman@techsingularity.net>
Cc: Doug Anderson <dianders@chromium.org>,
	Hillf Danton <hdanton@sina.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	 Yu Zhao <yuzhao@google.com>,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v2 1/4] mm/filemap: Add folio_lock_timeout()
Date: Wed, 26 Apr 2023 08:24:36 -0700	[thread overview]
Message-ID: <CAHk-=wiTw-Ct60_P+jnOfjKBAvpNJyvZENhA477Th0K6b6S3fA@mail.gmail.com> (raw)
In-Reply-To: <20230426100918.ku32k6mqoogsnijn@techsingularity.net>

On Wed, Apr 26, 2023 at 3:09 AM Mel Gorman <mgorman@techsingularity.net> wrote:
>
> The reason I don't consider this patch a NAK candidate is that this is not
> conditional locking as such because no special action is taken if the lock
> cannot be acquired.

If this comes from my rant against not having conditional locking for
the O_NDELAY (well, the io_uring equivalent) IO path, then no, I don't
think something like lock_page_timout() is "conditional locking".

Some caller wanting to get the lock, but being willing to just go on
and do something else after a timeout is fine. Within the context of
something like memory compaction internally for the kernel that is
fundamentally opportunistic anyway, that sounds fine to me.

In fact, in contexts like that, even trylock is fine. We obviously
have trylock in lots of places of the kernel.

My "no conditional locking" is really that I do not think it's sane to
have user IO fail with EAGAIN just because some data structure
happened to be busy. It's a debugging nightmare with unlikely things
that happen only in special conditions. Doing IO is not some
"opportunistic" thing.

We've actually had things like that before where people tried to make
O_NDELAY mean "no locking" (I think that was driven at least partly by
the old in-kernel web server patches), and it also causes actual
problems with user space then busy-looping in a select() loop, because
the select doesn't consider some low-level lock to be a waiting event.

(The io_uring case is _slightly_ different from our historical issues
in this area, in that the kernel can fall back to the user worker
thread case, but it's all mixed up in that same IO path and that's why
I absolutely hated that "if (X) trylock else proper_lock" approach).

So a unconditional "lock with timeout" in the context of "we can just
skip this if it times out" is perfectly fine by me.

That said - the kcompactd code is not code I know, so maybe there are
*other* issues with that patch, so this is also not an ACK from me.

So please consider this just a "that is a very different case from the
one I complained about".

                Linus


  parent reply	other threads:[~2023-04-26 15:24 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 22:12 [PATCH v2 0/4] migrate: Avoid unbounded blocks in MIGRATE_SYNC_LIGHT Douglas Anderson
2023-04-21 22:12 ` [PATCH v2 1/4] mm/filemap: Add folio_lock_timeout() Douglas Anderson
2023-04-22  5:18   ` Hillf Danton
     [not found]     ` <20230423081203.1812-1-hdanton@sina.com>
2023-04-23  8:35       ` Gao Xiang
2023-04-23  9:49         ` Hillf Danton
2023-04-23 10:45           ` Gao Xiang
2023-04-24 16:56     ` Doug Anderson
2023-04-25  1:09       ` Hillf Danton
2023-04-25 14:19         ` Doug Anderson
2023-04-26  4:42           ` Hillf Danton
2023-04-26  4:55             ` Doug Anderson
2023-04-26 10:09           ` Mel Gorman
2023-04-26 15:14             ` Matthew Wilcox
2023-04-26 20:46               ` Doug Anderson
2023-04-26 21:26                 ` Matthew Wilcox
2023-04-26 21:39                   ` Doug Anderson
2023-04-27  2:16                     ` Matthew Wilcox
2023-04-27  9:48                     ` Mel Gorman
2023-04-28  8:17                       ` Hillf Danton
2023-04-26 15:24             ` Linus Torvalds [this message]
2023-04-23  7:50   ` Huang, Ying
2023-04-24  8:22   ` Mel Gorman
2023-04-24 16:22     ` Doug Anderson
2023-04-25  8:00       ` Mel Gorman
2023-04-21 22:12 ` [PATCH v2 2/4] buffer: Add lock_buffer_timeout() Douglas Anderson
2023-04-23  8:47   ` Huang, Ying
2023-04-21 22:12 ` [PATCH v2 3/4] migrate_pages: Don't wait forever locking pages in MIGRATE_SYNC_LIGHT Douglas Anderson
2023-04-23  7:59   ` Huang, Ying
2023-04-24  9:38   ` Mel Gorman
2023-04-21 22:12 ` [PATCH v2 4/4] migrate_pages: Don't wait forever locking buffers " Douglas Anderson

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='CAHk-=wiTw-Ct60_P+jnOfjKBAvpNJyvZENhA477Th0K6b6S3fA@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=dianders@chromium.org \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.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 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).