mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Gordeev <agordeev@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Gordeev <agordeev@redhat.com>,
	Kent Overstreet <kmo@daterainc.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Jens Axboe <axboe@kernel.dk>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>
Subject: [PATCH RESEND 2/3] percpu_ida: Move waking up waiters out of atomic contexts
Date: Thu,  6 Feb 2014 13:24:54 +0100	[thread overview]
Message-ID: <df714a474d1358bf594f3f6dc02cdcf296cef40d.1391688720.git.agordeev@redhat.com> (raw)
In-Reply-To: <cover.1391688720.git.agordeev@redhat.com>

Currently percpu_ida_free() waikes up waiters always with local
interrupts disabled and sometimes with pool->lock held. Yet, it
does not appear there is any reason why it could not be done out
of these atomic contexts.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Cc: Kent Overstreet <kmo@daterainc.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: "Nicholas A. Bellinger" <nab@linux-iscsi.org>
Acked-by: Kent Overstreet <kmo@daterainc.com>
---
 lib/percpu_ida.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index fccfb28..c2fa3dc 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -229,6 +229,7 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
 	struct percpu_ida_cpu *tags;
 	unsigned long flags;
 	unsigned nr_free;
+	bool wake_up = false;
 
 	BUG_ON(tag >= pool->nr_tags);
 
@@ -247,7 +248,7 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
 		 * Pairs with smp_rmb() in steal_tags()
 		 */
 		smp_wmb();
-		wake_up(&pool->wait);
+		wake_up = true;
 	}
 
 	if (nr_free == pool->percpu_max_size) {
@@ -261,13 +262,15 @@ void percpu_ida_free(struct percpu_ida *pool, unsigned tag)
 			move_tags(pool->freelist, &pool->nr_free,
 				  tags->freelist, &tags->nr_free,
 				  pool->percpu_batch_size);
-
-			wake_up(&pool->wait);
+			wake_up = true;
 		}
 		spin_unlock(&pool->lock);
 	}
 
 	local_irq_restore(flags);
+
+	if (wake_up)
+		wake_up(&pool->wait);
 }
 EXPORT_SYMBOL_GPL(percpu_ida_free);
 
-- 
1.7.7.6


  parent reply	other threads:[~2014-02-06 12:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 12:24 [PATCH RESEND 0/3] percpu_ida: Various tweaks Alexander Gordeev
2014-02-06 12:24 ` [PATCH RESEND 1/3] percpu_ida: Fix data race on cpus_have_tags cpumask Alexander Gordeev
2014-02-26 23:05   ` Kent Overstreet
2014-03-02 14:42     ` Ming Lei
2014-03-11 14:03       ` Alexander Gordeev
2014-03-11 15:34         ` Ming Lei
2014-03-11 15:59           ` Alexander Gordeev
2014-03-11 16:31           ` Alexander Gordeev
2014-03-12 11:27             ` Ming Lei
2014-02-06 12:24 ` Alexander Gordeev [this message]
2014-02-06 12:24 ` [PATCH RESEND 3/3] percpu_ida: Sanity check initialization parameters Alexander Gordeev
2014-02-26 23:07   ` Kent Overstreet
2014-02-16 11:25 ` [PATCH 4/4] percpu_ida: Do not steal all remote CPU tags at once Alexander Gordeev
2014-02-26 23:08   ` Kent Overstreet
2014-02-26 21:11 ` [PATCH RESEND 0/3] percpu_ida: Various tweaks Alexander Gordeev
2014-02-26 23:01   ` Kent Overstreet

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=df714a474d1358bf594f3f6dc02cdcf296cef40d.1391688720.git.agordeev@redhat.com \
    --to=agordeev@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=kmo@daterainc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --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

all inboxes | Powered by JetHome®