From: Oleg Nesterov <oleg@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>, Michal Hocko <mhocko@kernel.org>,
Linux-MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tim Chen <tim.c.chen@linux.intel.com>,
Michal Hocko <mhocko@suse.com>
Subject: Re: [RFC PATCH] mm: silence soft lockups from unlock_page
Date: Fri, 24 Jul 2020 17:24:25 +0200 [thread overview]
Message-ID: <20200724152424.GC17209@redhat.com> (raw)
In-Reply-To: <CAHk-=wgvGOnMF0ePU4xS236bOsP8jouj3rps+ysCaGXvCjh2Dg@mail.gmail.com>
On 07/23, Linus Torvalds wrote:
>
> But I'll walk over my patch mentally one more time. Here's the current
> version, anyway.
Both patches look correct to me, feel free to add
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
> @@ -1013,18 +1014,40 @@ static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync,
> if (wait_page->bit_nr != key->bit_nr)
> return 0;
>
> + /* Stop walking if it's locked */
> + if (wait->flags & WQ_FLAG_EXCLUSIVE) {
> + if (test_and_set_bit(key->bit_nr, &key->page->flags))
> + return -1;
> + } else {
> + if (test_bit(key->bit_nr, &key->page->flags))
> + return -1;
> + }
not sure this makes any sense, but this looks like another user of
trylock_page_bit_common(), see the patch below on top of 1/2.
Oleg.
--- mm/filemap.c~ 2020-07-24 17:09:34.728133846 +0200
+++ mm/filemap.c 2020-07-24 17:23:52.279185374 +0200
@@ -1000,6 +1000,14 @@
wait_queue_entry_t wait;
};
+static int trylock_page_bit_common(struct page *page, int bit_nr,
+ struct wait_queue_entry *wait)
+{
+ return wait->flags & WQ_FLAG_EXCLUSIVE ?
+ !test_and_set_bit(bit_nr, &page->flags) :
+ !test_bit(bit_nr, &page->flags);
+}
+
static int wake_page_function(wait_queue_entry_t *wait, unsigned mode, int sync, void *arg)
{
int ret;
@@ -1015,13 +1023,8 @@
return 0;
/* Stop walking if it's locked */
- if (wait->flags & WQ_FLAG_EXCLUSIVE) {
- if (test_and_set_bit(key->bit_nr, &key->page->flags))
- return -1;
- } else {
- if (test_bit(key->bit_nr, &key->page->flags))
- return -1;
- }
+ if (!trylock_page_bit_common(key->page, key->bit_nr, wait))
+ return -1;
/*
* Let the waiter know we have done the page flag
@@ -1126,14 +1129,6 @@
*/
};
-static inline int trylock_page_bit_common(struct page *page, int bit_nr,
- enum behavior behavior)
-{
- return behavior == EXCLUSIVE ?
- !test_and_set_bit(bit_nr, &page->flags) :
- !test_bit(bit_nr, &page->flags);
-}
-
static inline int wait_on_page_bit_common(wait_queue_head_t *q,
struct page *page, int bit_nr, int state, enum behavior behavior)
{
@@ -1170,7 +1165,7 @@
*/
spin_lock_irq(&q->lock);
SetPageWaiters(page);
- if (!trylock_page_bit_common(page, bit_nr, behavior))
+ if (!trylock_page_bit_common(page, bit_nr, wait))
__add_wait_queue_entry_tail(q, wait);
spin_unlock_irq(&q->lock);
next prev parent reply other threads:[~2020-07-24 15:24 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 6:32 [RFC PATCH] mm: silence soft lockups from unlock_page Michal Hocko
2020-07-21 11:10 ` Qian Cai
2020-07-21 11:25 ` Michal Hocko
2020-07-21 11:44 ` Qian Cai
2020-07-21 12:17 ` Michal Hocko
2020-07-21 13:23 ` Qian Cai
2020-07-21 13:38 ` Michal Hocko
2020-07-21 14:15 ` Qian Cai
2020-07-21 14:17 ` Chris Down
2020-07-21 15:00 ` Michal Hocko
2020-07-21 15:33 ` Linus Torvalds
2020-07-21 15:49 ` Michal Hocko
2020-07-22 18:29 ` Linus Torvalds
2020-07-22 21:29 ` Hugh Dickins
2020-07-22 22:10 ` Linus Torvalds
2020-07-22 23:42 ` Linus Torvalds
2020-07-23 0:23 ` Linus Torvalds
2020-07-23 12:47 ` Oleg Nesterov
2020-07-23 17:32 ` Linus Torvalds
2020-07-23 18:01 ` Oleg Nesterov
2020-07-23 18:22 ` Linus Torvalds
2020-07-23 19:03 ` Linus Torvalds
2020-07-24 14:45 ` Oleg Nesterov
2020-07-23 20:03 ` Linus Torvalds
2020-07-23 23:11 ` Hugh Dickins
2020-07-23 23:43 ` Linus Torvalds
2020-07-24 0:07 ` Hugh Dickins
2020-07-24 0:46 ` Linus Torvalds
2020-07-24 3:45 ` Hugh Dickins
2020-07-24 15:24 ` Oleg Nesterov [this message]
2020-07-24 17:32 ` Linus Torvalds
2020-07-24 23:25 ` Linus Torvalds
2020-07-25 2:08 ` Hugh Dickins
2020-07-25 2:46 ` Linus Torvalds
2020-07-25 10:14 ` Oleg Nesterov
2020-07-25 18:48 ` Linus Torvalds
2020-07-25 19:27 ` Oleg Nesterov
2020-07-25 19:51 ` Linus Torvalds
2020-07-26 13:57 ` Oleg Nesterov
2020-07-25 21:19 ` Hugh Dickins
2020-07-26 4:22 ` Hugh Dickins
2020-07-26 20:30 ` Hugh Dickins
2020-07-26 20:41 ` Linus Torvalds
2020-07-26 22:09 ` Hugh Dickins
2020-07-27 19:35 ` Greg KH
2020-08-06 5:46 ` Hugh Dickins
2020-08-18 13:50 ` Greg KH
2020-08-06 5:21 ` Hugh Dickins
2020-08-06 17:07 ` Linus Torvalds
2020-08-06 18:00 ` Matthew Wilcox
2020-08-06 18:32 ` Linus Torvalds
2020-08-07 18:41 ` Hugh Dickins
2020-08-07 19:07 ` Linus Torvalds
2020-08-07 19:35 ` Matthew Wilcox
2020-08-03 13:14 ` Michal Hocko
2020-08-03 17:56 ` Linus Torvalds
2020-07-25 9:39 ` Oleg Nesterov
2020-07-23 8:03 ` Michal Hocko
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=20200724152424.GC17209@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=mhocko@suse.com \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.