Re: [PATCH 3/3] mm, meminit: Allow early_pfn_to_nid to be used during runtime

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

 



On Fri, Jul 17, 2015 at 01:22:04PM +0100, Mel Gorman wrote:
>  int __meminit early_pfn_to_nid(unsigned long pfn)
>  {
> +	static DEFINE_SPINLOCK(early_pfn_lock);
>  	int nid;
>  
> -	/* The system will behave unpredictably otherwise */
> -	BUG_ON(system_state != SYSTEM_BOOTING);
> +	/* Avoid locking overhead during boot but hotplug must lock */
> +	if (system_state != SYSTEM_BOOTING)
> +		spin_lock(&early_pfn_lock);
>  
>  	nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache);
> -	if (nid >= 0)
> -		return nid;
> -	/* just returns 0 */
> -	return 0;
> +	if (nid < 0)
> +		nid = 0;
> +
> +	if (system_state != SYSTEM_BOOTING)
> +		spin_unlock(&early_pfn_lock);
> +
> +	return nid;
>  }

Why the conditional locking?

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[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]