From: Oleg Nesterov <oleg@redhat.com>
To: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
"mingo@kernel.org" <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>, Neil Brown <neilb@suse.de>,
Michael Shaver <jmshaver@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched: Avoid that __wait_on_bit_lock() hangs
Date: Fri, 12 Aug 2016 18:16:12 +0200 [thread overview]
Message-ID: <20160812161611.GC30930@redhat.com> (raw)
In-Reply-To: <20160811173651.GA31803@redhat.com>
On 08/11, Oleg Nesterov wrote:
>
> I'll send another debugging patch tomorrow, I was a bit busy today. The next
> step is obvious, we need to know the caller.
Please drop two patches I sent before anf try the new one below.
Which kernel version do you use?
Oleg.
---
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index e5a3244..533da3ab 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -711,6 +711,15 @@ static inline int page_has_private(struct page *page)
return !!(page->flags & PAGE_FLAGS_PRIVATE);
}
+void unlock_page_x(struct page *page);
+static inline void __ClearPageLocked_x(struct page *page)
+{
+ if (PageLocked(compound_head(page)))
+ unlock_page_x(page);
+}
+
+#define __ClearPageLocked(page) __ClearPageLocked_x(page)
+
#undef PF_ANY
#undef PF_HEAD
#undef PF_NO_TAIL
diff --git a/mm/filemap.c b/mm/filemap.c
index 20f3b1f..fb320fb 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -837,6 +837,43 @@ void unlock_page(struct page *page)
}
EXPORT_SYMBOL(unlock_page);
+void unlock_page_x(struct page *__page)
+{
+ struct page *page = compound_head(__page);
+ wait_queue_head_t *wq = page_waitqueue(page);
+ struct wait_bit_key key = __WAIT_BIT_KEY_INITIALIZER(&page->flags, PG_locked);
+ wait_queue_t *curr, *next;
+ unsigned long flags;
+ bool w = false;
+
+ #define W() do { \
+ if (!w) { w = true; pr_crit("XXXXXXXXXXXX\n"); dump_stack(); } \
+ } while (0)
+
+ clear_bit_unlock(PG_locked, &page->flags);
+ smp_mb__after_atomic();
+
+ if (!waitqueue_active(wq))
+ return;
+
+ spin_lock_irqsave(&wq->lock, flags);
+ list_for_each_entry_safe(curr, next, &wq->task_list, task_list) {
+ if (curr->func == wake_bit_function) {
+ struct wait_bit_queue *wb = container_of(curr, struct wait_bit_queue, wait);
+ if (wb->key.flags == key.flags && wb->key.bit_nr == PG_locked) {
+ W();
+ pr_crit("XXX flags = %x, waiter:\n", curr->flags);
+ sched_show_task(curr->private);
+ }
+ } else {
+ W();
+ pr_crit("XXX flags = %x, func = %pF\n", curr->flags, curr->func);
+ }
+ curr->func(curr, TASK_NORMAL, 0, &key);
+ }
+ spin_unlock_irqrestore(&wq->lock, flags);
+}
+
/**
* end_page_writeback - end writeback against a page
* @page: the page
next prev parent reply other threads:[~2016-08-12 16:16 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-03 16:35 [PATCH] sched: Avoid that __wait_on_bit_lock() hangs Bart Van Assche
2016-08-03 18:11 ` Peter Zijlstra
2016-08-03 18:56 ` Bart Van Assche
2016-08-03 21:30 ` Oleg Nesterov
2016-08-03 21:51 ` Bart Van Assche
2016-08-04 14:09 ` Peter Zijlstra
2016-08-04 14:31 ` Bart Van Assche
2016-08-05 17:41 ` Bart Van Assche
2016-08-08 10:22 ` Peter Zijlstra
2016-08-08 14:38 ` Bart Van Assche
2016-08-08 16:20 ` Oleg Nesterov
2016-08-08 18:31 ` Bart Van Assche
2016-08-09 17:14 ` Oleg Nesterov
2016-08-09 18:48 ` Bart Van Assche
2016-08-09 23:10 ` Bart Van Assche
2016-08-10 10:45 ` Oleg Nesterov
2016-08-10 16:01 ` Bart Van Assche
2016-08-10 16:27 ` Oleg Nesterov
2016-08-10 19:58 ` Bart Van Assche
2016-08-11 17:36 ` Oleg Nesterov
2016-08-12 16:16 ` Oleg Nesterov [this message]
2016-08-12 16:27 ` Bart Van Assche
2016-08-12 22:47 ` Bart Van Assche
2016-08-13 16:32 ` Oleg Nesterov
2016-08-15 23:39 ` Bart Van Assche
2016-08-16 13:06 ` Oleg Nesterov
2016-08-16 16:54 ` Bart Van Assche
2016-08-17 17:30 ` Oleg Nesterov
2016-08-13 17:07 ` Oleg Nesterov
2016-08-09 23:56 ` Bart Van Assche
2016-08-10 10:57 ` Oleg Nesterov
2016-08-10 11:03 ` Peter Zijlstra
2016-08-04 0:05 ` Bart Van Assche
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=20160812161611.GC30930@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bart.vanassche@sandisk.com \
--cc=hannes@cmpxchg.org \
--cc=jmshaver@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=neilb@suse.de \
--cc=peterz@infradead.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