* [PATCH] percpu: simplify the pcpu_alloc()
@ 2010-08-10 15:00 Huang Shijie
2010-08-10 15:05 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Huang Shijie @ 2010-08-10 15:00 UTC (permalink / raw)
To: tj; +Cc: akpm, linux-mm, Huang Shijie
The `while' is not needed, replaced it with `if' to reduce
an unnecessary check.
Signed-off-by: Huang Shijie <shijie8@gmail.com>
---
mm/percpu.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/mm/percpu.c b/mm/percpu.c
index e61dc2c..2e50004 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -724,7 +724,8 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
goto fail_unlock;
}
- while ((new_alloc = pcpu_need_to_extend(chunk))) {
+ new_alloc = pcpu_need_to_extend(chunk);
+ if (new_alloc) {
spin_unlock_irqrestore(&pcpu_lock, flags);
if (pcpu_extend_area_map(chunk, new_alloc) < 0) {
err = "failed to extend area map of reserved chunk";
--
1.6.6.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] percpu: simplify the pcpu_alloc()
2010-08-10 15:00 [PATCH] percpu: simplify the pcpu_alloc() Huang Shijie
@ 2010-08-10 15:05 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2010-08-10 15:05 UTC (permalink / raw)
To: Huang Shijie; +Cc: akpm, linux-mm
On 08/10/2010 05:00 PM, Huang Shijie wrote:
> The `while' is not needed, replaced it with `if' to reduce
> an unnecessary check.
>
> Signed-off-by: Huang Shijie <shijie8@gmail.com>
> ---
> mm/percpu.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/mm/percpu.c b/mm/percpu.c
> index e61dc2c..2e50004 100644
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -724,7 +724,8 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved)
> goto fail_unlock;
> }
>
> - while ((new_alloc = pcpu_need_to_extend(chunk))) {
> + new_alloc = pcpu_need_to_extend(chunk);
> + if (new_alloc) {
> spin_unlock_irqrestore(&pcpu_lock, flags);
> if (pcpu_extend_area_map(chunk, new_alloc) < 0) {
> err = "failed to extend area map of reserved chunk";
I'd leave it as is. The check may be spurious now but if we ever end
up updating locking there to allow allocations from atomic contexts,
that while loop will be needed to check whether race hasn't happened
while the lock was dropped. This change would just make the code more
fragile without actually gaining anything.
Thanks.
--
tejun
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-10 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10 15:00 [PATCH] percpu: simplify the pcpu_alloc() Huang Shijie
2010-08-10 15:05 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).