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: Re: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk()
Date: Tue, 01 Dec 2009 14:35:34 +0800 [thread overview]
Message-ID: <4B14B936.8080205@redhat.com> (raw)
In-Reply-To: <4B14ADE0.3020007@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1025 bytes --]
Tejun Heo wrote:
> Hello,
>
> On 12/01/2009 02:40 PM, Cong Wang wrote:
>>> So, I don't know. The first iteration only loop looks a bit unusual
>>> for sure but it isn't something conceptually convoluted.
>> Now this seems to be better. So with this change, we can do:
>>
>> pcpu_first_pop_region(chunk, rs, re, start, end);
>> if (rs < re && ...)
>> return;
>>
>> Right?
>
> Yeap, but is that any better? Passing lvalue loop parameters to loop
> constructs is customary. For almost all other cases, it's not, so
>
> pcpu_first_pop_region(chunk, &rs, &re, start, end)
>
> would be better but then we have two similar looking interfaces which
> take different types of parameters. Also, you probably can drop rs <
> re test there but for me it just seems easier to simply check the
> first iteration. If you think it's something worth changing and it
> looks better afterwards, please send a patch.
>
What do you think about the patch below? Untested.
-----------
Signed-off-by: WANG Cong <amwang@redhat.com>
[-- Attachment #2: mm-percpu_c-remove-two-useless-break.diff --]
[-- Type: text/plain, Size: 1326 bytes --]
diff --git a/mm/percpu.c b/mm/percpu.c
index 5adfc26..d1da616 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -911,14 +911,12 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size)
int page_end = PFN_UP(off + size);
struct page **pages;
unsigned long *populated;
- int rs, re;
+ int rs = page_start, 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;
- }
+ 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);
@@ -966,14 +964,12 @@ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size)
struct page **pages;
unsigned long *populated;
unsigned int cpu;
- int rs, re, rc;
+ int rs = page_start, 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;
- }
+ 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);
next prev parent reply other threads:[~2009-12-01 6:33 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 [this message]
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=4B14B936.8080205@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox