From: Andrew Morton <akpm@zip.com.au>
To: Hugh Dickins <hugh@veritas.com>
Cc: j-nomura@ce.jp.nec.com, linux-kernel@vger.kernel.org
Subject: Re: 2.4.18(19) swapcache oops
Date: Thu, 15 Aug 2002 13:05:41 -0700 [thread overview]
Message-ID: <3D5C0995.CEE36FC8@zip.com.au> (raw)
In-Reply-To: Pine.LNX.4.44.0208151515420.1610-100000@localhost.localdomain
Hugh Dickins wrote:
>
> On Thu, 15 Aug 2002 j-nomura@ce.jp.nec.com wrote:
> >
> > I'm using 2.4.18 kernel and suspect there are swapcache race.
> > I looked into 2.4.19 patch but could not find the fix to it.
>
> I see a benign race but no oops.
>
But look at lru_cache_add():
void lru_cache_add(struct page * page)
{
if (!TestSetPageLRU(page)) {
/* window here */
spin_lock(&pagemap_lru_lock);
add_page_to_inactive_list(page);
spin_unlock(&pagemap_lru_lock);
}
}
It sets PG_lru before adding the page to the LRU.
static inline void activate_page_nolock(struct page * page)
{
if (PageLRU(page) && !PageActive(page)) {
del_page_from_inactive_list(page);
add_page_to_active_list(page);
}
}
void activate_page(struct page * page)
{
spin_lock(&pagemap_lru_lock);
activate_page_nolock(page);
spin_unlock(&pagemap_lru_lock);
}
So if activate_page gets the lock inside that window, it will
delete a page from the LRU which isn't on it (memory corruption).
Then activate_page will set PG_active and will drop the lock.
lru_cache_add gets the lock, runs add_page_to_inactive_list which
BUGs over PG_active.
--- 2.4.19/mm/swap.c~lru-race Thu Aug 15 13:03:48 2002
+++ 2.4.19-akpm/mm/swap.c Thu Aug 15 13:04:19 2002
@@ -57,9 +57,10 @@ void activate_page(struct page * page)
*/
void lru_cache_add(struct page * page)
{
- if (!TestSetPageLRU(page)) {
+ if (!PageLRU(page)) {
spin_lock(&pagemap_lru_lock);
- add_page_to_inactive_list(page);
+ if (!TestSetPageLRU(page))
+ add_page_to_inactive_list(page);
spin_unlock(&pagemap_lru_lock);
}
}
.
next prev parent reply other threads:[~2002-08-15 20:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-15 12:39 2.4.18(19) swapcache oops j-nomura
2002-08-15 14:32 ` Hugh Dickins
2002-08-15 20:05 ` Andrew Morton [this message]
2002-08-15 20:21 ` Andrew Morton
2002-08-16 4:19 ` j-nomura
2002-08-16 4:40 ` Andrew Morton
2002-08-16 8:07 ` j-nomura
2002-08-15 22:59 ` Hugh Dickins
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=3D5C0995.CEE36FC8@zip.com.au \
--to=akpm@zip.com.au \
--cc=hugh@veritas.com \
--cc=j-nomura@ce.jp.nec.com \
--cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.