Re: [patch 2/3 v2]swap: make each swap partition have one address_space

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

 



On Thu, 24 Jan 2013 18:24:14 +0800
Shaohua Li <shli@xxxxxxxxxx> wrote:

> Subject: mm: add memory barrier to prevent SwapCache bit and page private out of order
> 
> page_mapping() checks SwapCache bit first and then read page private. Adding
> memory barrier so page private has correct value before SwapCache bit set.
> 
> In some cases, page_mapping() isn't called with page locked. Without doing
> this, we might get a wrong swap address space with SwapCache bit set. Though I
> didn't found a problem with this so far (such code typically only checks if the
> page has mapping or the mapping can be dirty or migrated), this is too subtle
> and error-prone, so we want to avoid it.
> 
> ...
>
> --- linux.orig/mm/swap_state.c	2013-01-22 10:12:33.514490665 +0800
> +++ linux/mm/swap_state.c	2013-01-24 18:08:05.149390977 +0800
> @@ -89,6 +89,7 @@ static int __add_to_swap_cache(struct pa
>  
>  	page_cache_get(page);
>  	set_page_private(page, entry.val);
> +	smp_wmb();
>  	SetPageSwapCache(page);

SetPageSwapCache() uses set_bit() and arch/x86/include/asm/bitops.h
says "This function is atomic and may not be reordered".  

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