frontswap: is frontswap_init called from swapoff safe?
I was looking at the swapfile.c parts of the recently-merged frontswap, and noticed that frontswap_init can be called from swapoff when try_to_unuse fails.
This looks odd to me. Whether it is safe or not depends on what frontswap_ops.init does, but the comment for __frontswap_init ("Called when a swap device is swapon'd") and the function name itself seem to imply it should be called only for swapon, not when relinking the swap_info after a failed swapoff.
In particular, if frontswap_ops.init assumes the swap map is empty, it would break, since as far as I know when try_to_unuse fails there are still pages in the swap.
(By the way, the comment above enable_swap_info at sys_swapoff needs to be updated to also explain why reading p->frontswap_map outside the lock is safe at that point, like it does for p->prio and p->swap_map.)
Signature · 10 lines
Cesar Eduardo Barros [email protected] [email protected] -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 9 lines · Cesar Eduardo Barros
I was looking at the
swapfile.cparts of the recently-merged frontswap, and noticed thatfrontswap_initcan be called from swapoff whentry_to_unusefails.This looks odd to me. Whether it is safe or not depends on what frontswap_ops.init does, but the comment for
__frontswap_init("Called when a swap device is swapon'd") and the function name itself seem to imply it should be called only for swapon, not when relinking theswap_infoafter a failed swapoff.
<nods>
Quoted 4 lines
In particular, if frontswap_ops.init assumes the swap map is empty, it would break, since as far as I know when
try_to_unusefails there are still pages in the swap.
Let me look at this - can't do it this week - but will get back to you shortly.
Quoted 10 lines
(By the way, the comment above
enable_swap_infoatsys_swapoffneeds to be updated to also explain why readingp->frontswap_mapoutside the lock is safe at that point, like it does forp->prioandp->swap_map.)Signature · 3 lines
Cesar Eduardo Barros [email protected] [email protected]
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Em 06-06-2012 21:37, Konrad Rzeszutek Wilk escreveu:
Quoted 11 lines · Cesar Eduardo Barros
Quoted 9 lines
I was looking at the
swapfile.cparts of the recently-merged frontswap, and noticed thatfrontswap_initcan be called from swapoff whentry_to_unusefails.This looks odd to me. Whether it is safe or not depends on what frontswap_ops.init does, but the comment for
__frontswap_init("Called when a swap device is swapon'd") and the function name itself seem to imply it should be called only for swapon, not when relinking theswap_infoafter a failed swapoff.
Quoted 8 lines
<nods>
Quoted 4 lines
In particular, if frontswap_ops.init assumes the swap map is empty, it would break, since as far as I know when
try_to_unusefails there are still pages in the swap.Let me look at this - can't do it this week - but will get back to you shortly.
Did you look at it already? (Just pinging in case you forgot.)
Quoted 5 lines
Quoted 5 lines
(By the way, the comment above
enable_swap_infoatsys_swapoffneeds to be updated to also explain why readingp->frontswap_mapoutside the lock is safe at that point, like it does forp->prioandp->swap_map.)
Signature · 10 lines
Cesar Eduardo Barros [email protected] [email protected] -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>