* [PATCH][2.6] No swapping on memory backed swapfiles
@ 2003-10-13 7:57 Zwane Mwaikambo
2003-10-13 8:11 ` Andrew Morton
0 siblings, 1 reply; 8+ messages in thread
From: Zwane Mwaikambo @ 2003-10-13 7:57 UTC (permalink / raw)
To: Linux Kernel; +Cc: Andrew Morton
This fixes an oops when running LTP on a system with a tmpfs /tmp. The
oops is from the lack of a readpage a_op. This patch simply disables
enabling of swap for memory backed swapfiles.
Unable to handle kernel NULL pointer dereference at virtual address 00000000
printing eip:
00000000
*pde = 00000000
Oops: 0000 [#1]
CPU: 0
EIP: 0060:[<00000000>] Not tainted
EFLAGS: 00010246
EIP is at 0x0
eax: 00000000 ebx: c1076458 ecx: c1651660 edx: c1076458
esi: 00000000 edi: e2c38f68 ebp: dfd93f24 esp: e202bf4c
ds: 007b es: 007b ss: 0068
Process swapon02 (pid: 5718, threadinfo=e202a000 task=d6f769d0)
Stack: c0145c0c e2c38f68 c1076458 dfd93e88 dfd93e88 00000000 00000000 c01658c8
dfd93f24 00000000 00000000 e2c38f68 e3d7fe58 c07430d0 dfd93e88 dfd93e88
00000000 00000001 00000000 00000000 ffffffea dfd93f24 e2c38f68 00000000
Call Trace:
[<c0145c0c>] read_cache_page+0x5c/0x360
[<c01658c8>] sys_swapon+0x528/0xa30
[<c01096e9>] sysenter_past_esp+0x52/0x79
Code: Bad EIP value.
(gdb) list *read_cache_page+0x5c
0xc0145c0c is in read_cache_page (mm/filemap.c:1393).
1388 page_cache_release(cached_page);
1389 return ERR_PTR(err);
1390 }
1391 page = cached_page;
1392 cached_page = NULL;
1393 err = filler(data, page);
1394 if (err < 0) {
1395 page_cache_release(page);
1396 page = ERR_PTR(err);
1397 }
Index: linux-2.6.0-test7/mm/swapfile.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test7/mm/swapfile.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 swapfile.c
--- linux-2.6.0-test7/mm/swapfile.c 9 Oct 2003 05:56:12 -0000 1.1.1.1
+++ linux-2.6.0-test7/mm/swapfile.c 13 Oct 2003 07:27:28 -0000
@@ -1233,6 +1233,7 @@ asmlinkage long sys_swapon(const char __
struct page *page = NULL;
struct inode *inode;
struct inode *downed_inode = NULL;
+ struct backing_dev_info *bdi;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
@@ -1293,6 +1294,10 @@ asmlinkage long sys_swapon(const char __
}
error = -EINVAL;
+ bdi = mapping->backing_dev_info;
+ if (bdi->memory_backed)
+ goto bad_swap;
+
if (S_ISBLK(inode->i_mode)) {
bdev = inode->i_bdev;
error = bd_claim(bdev, sys_swapon);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 7:57 [PATCH][2.6] No swapping on memory backed swapfiles Zwane Mwaikambo
@ 2003-10-13 8:11 ` Andrew Morton
2003-10-13 8:32 ` John Bradford
2003-10-13 9:05 ` Zwane Mwaikambo
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2003-10-13 8:11 UTC (permalink / raw)
To: Zwane Mwaikambo; +Cc: linux-kernel
Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
>
> + bdi = mapping->backing_dev_info;
> + if (bdi->memory_backed)
> + goto bad_swap;
> +
I guess that makes sense, although someone might want to swap onto a
ramdisk-backed file just for some testing purpose.
Why not simply test for a null ->readpage()?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 8:11 ` Andrew Morton
@ 2003-10-13 8:32 ` John Bradford
2003-10-13 9:15 ` Zwane Mwaikambo
2003-10-16 21:31 ` bill davidsen
2003-10-13 9:05 ` Zwane Mwaikambo
1 sibling, 2 replies; 8+ messages in thread
From: John Bradford @ 2003-10-13 8:32 UTC (permalink / raw)
To: Andrew Morton, Zwane Mwaikambo; +Cc: linux-kernel
Quote from Andrew Morton <akpm@osdl.org>:
> Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
> >
> > + bdi = mapping->backing_dev_info;
> > + if (bdi->memory_backed)
> > + goto bad_swap;
> > +
>
> I guess that makes sense, although someone might want to swap onto a
> ramdisk-backed file just for some testing purpose.
Or because some RAM is slower than the rest. This came up a while ago
on the list.
John.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 8:11 ` Andrew Morton
2003-10-13 8:32 ` John Bradford
@ 2003-10-13 9:05 ` Zwane Mwaikambo
2003-10-13 9:24 ` Andrew Morton
1 sibling, 1 reply; 8+ messages in thread
From: Zwane Mwaikambo @ 2003-10-13 9:05 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-kernel
On Mon, 13 Oct 2003, Andrew Morton wrote:
> Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
> >
> > + bdi = mapping->backing_dev_info;
> > + if (bdi->memory_backed)
> > + goto bad_swap;
> > +
>
> I guess that makes sense, although someone might want to swap onto a
> ramdisk-backed file just for some testing purpose.
>
> Why not simply test for a null ->readpage()?
That was my initial intention, but then i wondered why someone would be
swapping to a memory backed filesystem in the first place. Also things
like ramfs have ->readpage().
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 8:32 ` John Bradford
@ 2003-10-13 9:15 ` Zwane Mwaikambo
2003-10-16 21:31 ` bill davidsen
1 sibling, 0 replies; 8+ messages in thread
From: Zwane Mwaikambo @ 2003-10-13 9:15 UTC (permalink / raw)
To: John Bradford; +Cc: Andrew Morton, linux-kernel
On Mon, 13 Oct 2003, John Bradford wrote:
> > I guess that makes sense, although someone might want to swap onto a
> > ramdisk-backed file just for some testing purpose.
>
> Or because some RAM is slower than the rest. This came up a while ago
> on the list.
Could you possibly be referring to something else? How would this slower
RAM be setup?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 9:05 ` Zwane Mwaikambo
@ 2003-10-13 9:24 ` Andrew Morton
2003-10-13 9:34 ` Zwane Mwaikambo
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Morton @ 2003-10-13 9:24 UTC (permalink / raw)
To: Zwane Mwaikambo; +Cc: linux-kernel
Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
>
> On Mon, 13 Oct 2003, Andrew Morton wrote:
>
> > Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
> > >
> > > + bdi = mapping->backing_dev_info;
> > > + if (bdi->memory_backed)
> > > + goto bad_swap;
> > > +
> >
> > I guess that makes sense, although someone might want to swap onto a
> > ramdisk-backed file just for some testing purpose.
> >
> > Why not simply test for a null ->readpage()?
>
> That was my initial intention, but then i wondered why someone would be
> swapping to a memory backed filesystem in the first place. Also things
> like ramfs have ->readpage().
A non-memory-backed fs may still have a NULL ->readpage though (ncpfs?).
I do think it best to just test for ->readpage, and give the user the extra
rope.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 9:24 ` Andrew Morton
@ 2003-10-13 9:34 ` Zwane Mwaikambo
0 siblings, 0 replies; 8+ messages in thread
From: Zwane Mwaikambo @ 2003-10-13 9:34 UTC (permalink / raw)
To: Andrew Morton; +Cc: Linux Kernel
On Mon, 13 Oct 2003, Andrew Morton wrote:
> A non-memory-backed fs may still have a NULL ->readpage though (ncpfs?).
>
> I do think it best to just test for ->readpage, and give the user the extra
> rope.
Ok, here we go;
Index: linux-2.6.0-test7/mm/swapfile.c
===================================================================
RCS file: /build/cvsroot/linux-2.6.0-test7/mm/swapfile.c,v
retrieving revision 1.1.1.1
diff -u -p -B -r1.1.1.1 swapfile.c
--- linux-2.6.0-test7/mm/swapfile.c 9 Oct 2003 05:56:12 -0000 1.1.1.1
+++ linux-2.6.0-test7/mm/swapfile.c 13 Oct 2003 09:23:31 -0000
@@ -1318,6 +1318,10 @@ asmlinkage long sys_swapon(const char __
/*
* Read the swap header.
*/
+ if (!mapping->a_ops->readpage) {
+ error = -EIO;
+ goto bad_swap;
+ }
page = read_cache_page(mapping, 0,
(filler_t *)mapping->a_ops->readpage, swap_file);
if (IS_ERR(page)) {
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH][2.6] No swapping on memory backed swapfiles
2003-10-13 8:32 ` John Bradford
2003-10-13 9:15 ` Zwane Mwaikambo
@ 2003-10-16 21:31 ` bill davidsen
1 sibling, 0 replies; 8+ messages in thread
From: bill davidsen @ 2003-10-16 21:31 UTC (permalink / raw)
To: linux-kernel
In article <200310130832.h9D8WJ4g000157@81-2-122-30.bradfords.org.uk>,
John Bradford <john@grabjohn.com> wrote:
| Quote from Andrew Morton <akpm@osdl.org>:
| > Zwane Mwaikambo <zwane@arm.linux.org.uk> wrote:
| > >
| > > + bdi = mapping->backing_dev_info;
| > > + if (bdi->memory_backed)
| > > + goto bad_swap;
| > > +
| >
| > I guess that makes sense, although someone might want to swap onto a
| > ramdisk-backed file just for some testing purpose.
|
| Or because some RAM is slower than the rest. This came up a while ago
| on the list.
Something on my "learn how to..." list, I have some systems which are
setup to cache only the first 64MB, and I bet they would run a lot
faster if the rest were used as swap. It is definitely faster with
mem=64 than letting the CPU beat the whole memory.
--
bill davidsen <davidsen@tmr.com>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-10-16 21:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-13 7:57 [PATCH][2.6] No swapping on memory backed swapfiles Zwane Mwaikambo
2003-10-13 8:11 ` Andrew Morton
2003-10-13 8:32 ` John Bradford
2003-10-13 9:15 ` Zwane Mwaikambo
2003-10-16 21:31 ` bill davidsen
2003-10-13 9:05 ` Zwane Mwaikambo
2003-10-13 9:24 ` Andrew Morton
2003-10-13 9:34 ` Zwane Mwaikambo
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.