lkml.org 
[lkml]   [2009]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
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@kernel.org>
Reported-by: Amerigo Wang <amwang@redhat.com>
Cc: Christoph Lameter <cl@linux-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


\
 
 \ /
  Last update: 2009-12-01 01:05    [W:0.376 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site