linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* frontswap: is frontswap_init called from swapoff safe?
@ 2012-06-05 10:41 Cesar Eduardo Barros
  2012-06-07  0:37 ` Konrad Rzeszutek Wilk
  0 siblings, 1 reply; 3+ messages in thread
From: Cesar Eduardo Barros @ 2012-06-05 10:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Konrad Rzeszutek Wilk, Dan Magenheimer, linux-mm

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.)

-- 
Cesar Eduardo Barros
cesarb@cesarb.net
cesar.barros@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: frontswap: is frontswap_init called from swapoff safe?
  2012-06-05 10:41 frontswap: is frontswap_init called from swapoff safe? Cesar Eduardo Barros
@ 2012-06-07  0:37 ` Konrad Rzeszutek Wilk
  2012-07-17  0:41   ` Cesar Eduardo Barros
  0 siblings, 1 reply; 3+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-06-07  0:37 UTC (permalink / raw)
  To: Cesar Eduardo Barros; +Cc: linux-kernel, Dan Magenheimer, linux-mm

On Tue, Jun 05, 2012 at 07:41:52AM -0300, Cesar Eduardo Barros wrote:
> 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.

<nods>
> 
> 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.

Let me look at this - can't do it this week - but will get back to you
shortly.
> 
> (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.)
> 
> -- 
> Cesar Eduardo Barros
> cesarb@cesarb.net
> cesar.barros@gmail.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: frontswap: is frontswap_init called from swapoff safe?
  2012-06-07  0:37 ` Konrad Rzeszutek Wilk
@ 2012-07-17  0:41   ` Cesar Eduardo Barros
  0 siblings, 0 replies; 3+ messages in thread
From: Cesar Eduardo Barros @ 2012-07-17  0:41 UTC (permalink / raw)
  To: Konrad Rzeszutek Wilk; +Cc: linux-kernel, Dan Magenheimer, linux-mm

Em 06-06-2012 21:37, Konrad Rzeszutek Wilk escreveu:
> On Tue, Jun 05, 2012 at 07:41:52AM -0300, Cesar Eduardo Barros wrote:
>> 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.
>
> <nods>
>>
>> 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.
>
> 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.)

>>
>> (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.)

-- 
Cesar Eduardo Barros
cesarb@cesarb.net
cesar.barros@gmail.com



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-07-17  0:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-05 10:41 frontswap: is frontswap_init called from swapoff safe? Cesar Eduardo Barros
2012-06-07  0:37 ` Konrad Rzeszutek Wilk
2012-07-17  0:41   ` Cesar Eduardo Barros

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).