[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B145CE9.1060608@kernel.org>
Date: Tue, 01 Dec 2009 09:01:45 +0900
From: Tejun Heo <tj@...nel.org>
To: Christoph Lameter <cl@...ux-foundation.org>
CC: Amerigo Wang <amwang@...hat.com>, linux-kernel@...r.kernel.org,
akpm@...ux-foundation.org
Subject: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk()
pcpu_[de]populate_chunk() check whether there's actually any work to
do at the beginning and exit early if not. This checking is done by
seeing whether the first iteration of pcpu_for_each_[un]pop_region()
covers the whole requested region. The resulting code is a bit
unusual in that it's loop-like but never loops which apparently
confuses people. Add comments to explain it.
Signed-off-by: Tejun Heo <tj@...nel.org>
Reported-by: Amerigo Wang <amwang@...hat.com>
Cc: Christoph Lameter <cl@...ux-foundation.org>
---
Added to percpu#for-next. This should be clear enough, right?
mm/percpu.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index 442010c..c264315 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -912,10 +912,15 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size)
unsigned long *populated;
int rs, re;
- /* quick path, check whether it's empty already */
+ /*
+ * Quick path, check whether it's already empty. If the
+ * region is completely empty, the first iteration will cover
+ * the whole region.
+ */
pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
if (rs == page_start && re == page_end)
return;
+ /* it didn't cover the whole thing, break to slow path */
break;
}
@@ -967,10 +972,15 @@ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size)
unsigned int cpu;
int rs, re, rc;
- /* quick path, check whether all pages are already there */
+ /*
+ * Quick path, check whether all pages are already there. If
+ * the region is fully populated, the first iteration will
+ * cover the whole region.
+ */
pcpu_for_each_pop_region(chunk, rs, re, page_start, page_end) {
if (rs == page_start && re == page_end)
goto clear;
+ /* it didn't cover the whole thing, break to slow path */
break;
}
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists