From: Maxim Patlasov <mpatlasov@parallels.com>
To: miklos@szeredi.hu
Cc: dev@parallels.com, xemul@parallels.com,
fuse-devel@lists.sourceforge.net, bfoster@redhat.com,
linux-kernel@vger.kernel.org, devel@openvz.org
Subject: [PATCH 3/3] fuse: implement exclusive wakeup for blocked_waitq
Date: Wed, 26 Dec 2012 16:45:09 +0400 [thread overview]
Message-ID: <20121226124500.24502.77774.stgit@maximpc.sw.ru> (raw)
In-Reply-To: <20121226124319.24502.41536.stgit@maximpc.sw.ru>
The patch solves thundering herd problem. So far as previous patches ensured
that only allocations for background may block, it's safe to wake up one
waiter. Whoever it is, it will wake up another one in request_end() afterwards.
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
---
fs/fuse/dev.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index c7bef93..7ed2096 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -112,8 +112,8 @@ struct fuse_req *fuse_get_req_internal(struct fuse_conn *fc,
int intr;
block_sigs(&oldset);
- intr = wait_event_interruptible(fc->blocked_waitq,
- !fc->blocked);
+ intr = wait_event_interruptible_exclusive(fc->blocked_waitq,
+ !fc->blocked);
restore_sigs(&oldset);
err = -EINTR;
if (intr)
@@ -224,6 +224,13 @@ struct fuse_req *fuse_get_req_nofail(struct fuse_conn *fc, struct file *file)
void fuse_put_request(struct fuse_conn *fc, struct fuse_req *req)
{
if (atomic_dec_and_test(&req->count)) {
+ if (unlikely(req->background)) {
+ spin_lock(&fc->lock);
+ if (!fc->blocked)
+ wake_up(&fc->blocked_waitq);
+ spin_unlock(&fc->lock);
+ }
+
if (req->waiting)
atomic_dec(&fc->num_waiting);
@@ -321,10 +328,14 @@ __releases(fc->lock)
list_del(&req->intr_entry);
req->state = FUSE_REQ_FINISHED;
if (req->background) {
- if (fc->num_background == fc->max_background) {
+ req->background = 0;
+
+ if (fc->num_background == fc->max_background)
fc->blocked = 0;
- wake_up_all(&fc->blocked_waitq);
- }
+
+ if (!fc->blocked)
+ wake_up(&fc->blocked_waitq);
+
if (fc->num_background == fc->congestion_threshold &&
fc->connected && fc->bdi_initialized) {
clear_bdi_congested(&fc->bdi, BLK_RW_SYNC);
next prev parent reply other threads:[~2012-12-26 12:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-26 12:44 [PATCH 0/3] fuse: fix accounting background requests Maxim Patlasov
2012-12-26 12:44 ` [PATCH 1/3] fuse: make request allocations for background processing explicit Maxim Patlasov
2012-12-26 12:44 ` [PATCH 2/3] fuse: skip blocking on allocations of synchronous requests Maxim Patlasov
2012-12-26 12:45 ` Maxim Patlasov [this message]
2013-02-06 17:12 ` [PATCH 0/3] fuse: fix accounting background requests Miklos Szeredi
2013-03-21 13:04 ` Maxim V. Patlasov
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=20121226124500.24502.77774.stgit@maximpc.sw.ru \
--to=mpatlasov@parallels.com \
--cc=bfoster@redhat.com \
--cc=dev@parallels.com \
--cc=devel@openvz.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=xemul@parallels.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