Re: [PATCH][-mm] Fix setup_per_zone_pages_min() lock.

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

 



On Mon, 2007-09-03 at 19:46 +0900, KAMEZAWA Hiroyuki wrote:
> Fix setup_per_zone_pages_min().
> 
> Now setup_per_zone_pages_min() uses zone->lru_lock. This has 2 problems.
> 
> 1. setup_page_zone_pages_min() modifies zone->pages_min,pages_low,pages_high.
>    in atomic. But readers of these values tend not to take lru_lock.
>    (At least, we need lock between memory hotplug vs. sysctl)
> 2. setup_zone_migrate_reserve() should take zone->lock instead of lru_lock.
> 
> This patch replaces zone->lru_lock with zone->lock.
> 

Does it really matter as they routinely do not take zone->lru_lock
either? pages_min, pages_low and pages_high are currently examined on a
regular basis by zone_watermark_ok() without any locks held in the page
allocator and page reclaim path. Glancing through this, it would appear
that the code in question has the same level of locking protection with
zone->lru_lock or zone->lock.

Is memory hotadd specifically taking the lru_lock somewhere? I can only
think of the seqlock at the moment.

> Signed-off-by: KAMEZAWA Hiroyuki <[email protected]>

> 
> 
> ---
>  mm/page_alloc.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: devel-2.6.23-rc4-mm1-zone/mm/page_alloc.c
> ===================================================================
> --- devel-2.6.23-rc4-mm1-zone.orig/mm/page_alloc.c
> +++ devel-2.6.23-rc4-mm1-zone/mm/page_alloc.c
> @@ -4176,8 +4176,8 @@ void setup_per_zone_pages_min(void)
>  
>  	for_each_zone(zone) {
>  		u64 tmp;
> +		spin_lock_irqsave(&zone->lock, flags);
>  
> -		spin_lock_irqsave(&zone->lru_lock, flags);
>  		tmp = (u64)pages_min * zone->present_pages;
>  		do_div(tmp, lowmem_pages);
>  		if (is_highmem(zone)) {
> @@ -4208,8 +4208,9 @@ void setup_per_zone_pages_min(void)
>  
>  		zone->pages_low   = zone->pages_min + (tmp >> 2);
>  		zone->pages_high  = zone->pages_min + (tmp >> 1);
> +
>  		setup_zone_migrate_reserve(zone);
> -		spin_unlock_irqrestore(&zone->lru_lock, flags);
> +		spin_unlock_irqrestore(&zone->lock, flags);
>  	}
>  
>  	/* update totalreserve_pages */
> 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux