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: Kent Overstreet <kmo@daterainc.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Jens Axboe <axboe@kernel.dk>,
	"Nicholas A. Bellinger" <nab@linux-iscsi.org>
Subject: [PATCH 4/4] percpu_ida: Do not steal all remote CPU tags at once
Date: Sun, 16 Feb 2014 12:25:29 +0100	[thread overview]
Message-ID: <20140216112528.GA13853@dhcp-26-207.brq.redhat.com> (raw)
In-Reply-To: <cover.1391688720.git.agordeev@redhat.com>

When stealing from a remote CPU all available tags are moved
from the remote CPU's cache to the stealing CPU's one. Since
the best CPU to steal from is not selected the victim might
actively performing IO and (as result of losing all local
tags) a further cycle of cache rebouncing and/or stealing
could be provoked.

This update is an attempt to soften the described scenario
and limit the number of tags to be stolen at once to the
value of percpu_batch_size.

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>
---
 lib/percpu_ida.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lib/percpu_ida.c b/lib/percpu_ida.c
index fad029c..b4c4cc7 100644
--- a/lib/percpu_ida.c
+++ b/lib/percpu_ida.c
@@ -84,20 +84,22 @@ static inline void steal_tags(struct percpu_ida *pool,
 		pool->cpu_last_stolen = cpu;
 		remote = per_cpu_ptr(pool->tag_cpu, cpu);
 
-		cpumask_clear_cpu(cpu, &pool->cpus_have_tags);
-
-		if (remote == tags)
+		if (remote == tags) {
+			cpumask_clear_cpu(cpu, &pool->cpus_have_tags);
 			continue;
+		}
 
 		spin_lock(&remote->lock);
 
 		if (remote->nr_free) {
-			memcpy(tags->freelist,
-			       remote->freelist,
-			       sizeof(unsigned) * remote->nr_free);
+			const struct percpu_ida *p = pool;
+
+			move_tags(tags->freelist, &tags->nr_free,
+				  remote->freelist, &remote->nr_free,
+				  min(remote->nr_free, p->percpu_batch_size));
 
-			tags->nr_free = remote->nr_free;
-			remote->nr_free = 0;
+			if (!remote->nr_free)
+				cpumask_clear_cpu(cpu, &pool->cpus_have_tags);
 		}
 
 		spin_unlock(&remote->lock);
-- 
1.7.7.6

-- 
Regards,
Alexander Gordeev
agordeev@redhat.com

  parent reply	other threads:[~2014-02-16 11:23 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 ` [PATCH RESEND 2/3] percpu_ida: Move waking up waiters out of atomic contexts Alexander Gordeev
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 ` Alexander Gordeev [this message]
2014-02-26 23:08   ` [PATCH 4/4] percpu_ida: Do not steal all remote CPU tags at once 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=20140216112528.GA13853@dhcp-26-207.brq.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®