linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Cesar Eduardo Barros <cesarb@cesarb.net>
To: linux-kernel@vger.kernel.org
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Dan Magenheimer <dan.magenheimer@oracle.com>,
	linux-mm@kvack.org
Subject: frontswap: is frontswap_init called from swapoff safe?
Date: Tue, 05 Jun 2012 07:41:52 -0300	[thread overview]
Message-ID: <4FCDE270.1020906@cesarb.net> (raw)

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  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:"dont@kvack.org"> email@kvack.org </a>

             reply	other threads:[~2012-06-05 10:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-05 10:41 Cesar Eduardo Barros [this message]
2012-06-07  0:37 ` Konrad Rzeszutek Wilk
2012-07-17  0:41   ` Cesar Eduardo Barros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FCDE270.1020906@cesarb.net \
    --to=cesarb@cesarb.net \
    --cc=dan.magenheimer@oracle.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox