public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Christoph Lameter <cl@linux-foundation.org>
Cc: Amerigo Wang <amwang@redhat.com>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk()
Date: Tue, 01 Dec 2009 09:01:45 +0900	[thread overview]
Message-ID: <4B145CE9.1060608@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.00.0911301258370.18682@router.home>

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


  reply	other threads:[~2009-12-01  0:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-30  9:12 [Patch] percpu: remove two suspicious break statements Amerigo Wang
2009-11-30 11:09 ` Tejun Heo
2009-11-30 19:01   ` Christoph Lameter
2009-12-01  0:01     ` Tejun Heo [this message]
2009-12-01  2:02       ` [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk() Cong Wang
2009-12-01  5:00         ` Tejun Heo
2009-12-01  5:09           ` Tejun Heo
2009-12-01  5:40             ` Cong Wang
2009-12-01  5:47               ` Tejun Heo
2009-12-01  6:35                 ` Cong Wang
2009-12-01  6:59                   ` Tejun Heo
2009-12-01  7:13                     ` [PATCH] percpu: refactor the code " Cong Wang
2009-12-01 14:31                       ` Tejun Heo

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=4B145CE9.1060608@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=amwang@redhat.com \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.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