All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <amwang@redhat.com>
To: Tejun Heo <tj@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Subject: [PATCH] percpu: refactor the code in pcpu_[de]populate_chunk()
Date: Tue, 01 Dec 2009 15:13:27 +0800	[thread overview]
Message-ID: <4B14C217.90203@redhat.com> (raw)
In-Reply-To: <4B14BEB6.5090105@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 551 bytes --]

Tejun Heo wrote:
> On 12/01/2009 03:35 PM, Cong Wang wrote:
>> What do you think about the patch below? Untested.
> 
> Oh, yeah, that's prettier.  Just one thing, can you please move rs
> initialization right above the pcpu_next_[un]pop() call?  The
> input/output parameters for those functions are already pretty
> confusing, let's make it at least a bit clearer.
> 

Sure, done.

------------->

Using break statement at the end of a for loop is confusing,
refactor it by replacing the for loop.

Signed-off-by: WANG Cong <amwang@redhat.com>

---


[-- Attachment #2: mm-percpu_c-remove-two-useless-break.diff --]
[-- Type: text/plain, Size: 1147 bytes --]

diff --git a/mm/percpu.c b/mm/percpu.c
index 5adfc26..2941ed9 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -914,11 +914,10 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size)
 	int rs, re;
 
 	/* quick path, check whether it's empty already */
-	pcpu_for_each_unpop_region(chunk, rs, re, page_start, page_end) {
-		if (rs == page_start && re == page_end)
-			return;
-		break;
-	}
+	rs = page_start;
+	pcpu_next_unpop(chunk, &rs, &re, page_end);
+	if (rs == page_start && re == page_end)
+		return;
 
 	/* immutable chunks can't be depopulated */
 	WARN_ON(chunk->immutable);
@@ -969,11 +968,10 @@ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size)
 	int rs, re, rc;
 
 	/* quick path, check whether all pages are already there */
-	pcpu_for_each_pop_region(chunk, rs, re, page_start, page_end) {
-		if (rs == page_start && re == page_end)
-			goto clear;
-		break;
-	}
+	rs = page_start;
+	pcpu_next_pop(chunk, &rs, &re, page_end);
+	if (rs == page_start && re == page_end)
+		goto clear;
 
 	/* need to allocate and map pages, this chunk can't be immutable */
 	WARN_ON(chunk->immutable);

  reply	other threads:[~2009-12-01  7:11 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     ` [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk() Tejun Heo
2009-12-01  2:02       ` 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                     ` Cong Wang [this message]
2009-12-01 14:31                       ` [PATCH] percpu: refactor the code " 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=4B14C217.90203@redhat.com \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.