Re: One comment on the __release_region in kernel/resource.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





2011/10/3 KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
On Sun, 2 Oct 2011 21:57:07 +0800
Wei Yang <weiyang.kernel@xxxxxxxxx> wrote:

> Dear experts,
>
> I am viewing the source code of __release_region() in kernel/resource.c.
> And I have one comment for the performance issue.
>
> For example, we have a resource tree like this.
> 10-89
>    20-79
>        30-49
>        55-59
>        60-64
>        65-69
>    80-89
> 100-279
>
> If the caller wants to release a region of [50,59], the original code will
> execute four times in the for loop in the subtree of 20-79.
>
> After changing the code below, it will execute two times instead.
>
> By using the "git annotate", I see this code is committed by Linus as the
> initial version. So don't get more information about why this code is
> written
> in this way.
>
> Maybe the case I thought will not happen in the real world?
>
> Your comment is warmly welcome. :)
>
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 8461aea..81525b4 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -931,7 +931,7 @@ void __release_region(struct resource *parent,
> resource_size_t start,
>        for (;;) {
>                struct resource *res = *p;
>
> -               if (!res)
> +               if (!res || res->start > start)

Hmm ?
       res->start > end ?

 I think res->start > start is fine.
__release_region will release the exact the region, no overlap.
So if res->start > start, this means there is no exact region to release.
The required to release region doesn't exist.


Thanks,
-Kame




--
Wei Yang
Help You, Help Me


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]