Skip to contentSkip to conversation

swsusp: fix error handling in "not enough swap space"

DISCUSSION Grzegorz Piotr Jaskiewicz 4 participants 15 messages Apr 24, 2004 – Apr 26, 2004 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

Hi

I am unable to suspend to swap nowdays, getting message 'not enough swapspace'. My swap space is 1172704k in size (1GB).

nalesnik:~# fdisk -l /dev/hda

Disk /dev/hda: 40.0 GB, 40007761920 bytes
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/hda1               1         146     1172713+  82  Linux swap
/dev/hda2             147        1605    11719417+  83  Linux
/dev/hda3            1606        4864    26177917+  83  Linux

Here's the message I got after issuing 'echo "4" >/proc/acpi/sleep':

...

/critical section: counting pages to copy..[nosave pfn 0x463].................................................................
(pages needed: 10056+512=10568 free: 18599)
Alloc pagedir
..[nosave pfn 0x463]...............................critical section/: done (10056 pages copied)
blk: queue c6d40e00, I/O limit 4095Mb (mask 0xffffffff)
Writing data to swap (10056 pages): .<0> Kernel panic:
Not enough swapspace when writing data
_

this is PCG-C1VE sony vaio picture book, dmesg attached. Kernel version 2.6.6-rc2-bk2.

#1 lore raw

Hi.

Can we assume you've tried running mkswap again? Could you also show /proc/meminfo prior to suspending?

Regards,

Nigel

Signature · 4 lines
Nigel Cunningham
C/- Westminster Presbyterian Church Belconnen
61 Templeton Street, Cook, ACT 2614, Australia.
+61 (2) 6251 7727 (wk)
#2 lore raw
Quoted 3 lines · Nigel Cunningham

Hi.

Can we assume you've tried running mkswap again? Could you also show /proc/meminfo prior to suspending?

Looking into code, quite frankly I can assume that my computer would have to eat up 900MB of swap. Very unquite as whole thing hangs whem swap usage is twice memory. Simply due to slow HD, wait times are far too long for him to cope with it.

with swap redone (swapoff /dev/hda1 && mkswap -v1 /dev/hda1 && swapon /dev/hda1), still the same happends.

meminfo:

nalesnik:~# cat /proc/meminfo
MemTotal:       109568 kB
MemFree:         36544 kB
Buffers:         15576 kB
Cached:          30360 kB
SwapCached:          0 kB
Active:          36464 kB
Inactive:        19436 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:       109568 kB
LowFree:         36544 kB
SwapTotal:     1172704 kB
SwapFree:      1172704 kB
Dirty:              16 kB
Writeback:           0 kB
Mapped:          16632 kB
Slab:            10672 kB
Committed_AS:    22584 kB
PageTables:        512 kB
VmallocTotal:   925656 kB
VmallocUsed:      4784 kB
VmallocChunk:   920548 kB
HugePages_Total:     0
HugePages_Free:      0
Hugepagesize:     4096 kB
#3 lore raw

Hmm.

I agree with you; it does sound like the process of eating memory is grabbing all the swap. I can't see how it could be doing that, however. If you really want to use Pavel's version, I'd suggest adding some more debug statements. Perhaps print out the number of swap pages free at the start of that loop.

Regards,

Nigel

Signature · 4 lines
Nigel Cunningham
C/- Westminster Presbyterian Church Belconnen
61 Templeton Street, Cook, ACT 2614, Australia.
+61 (2) 6251 7727 (wk)
#4 lore raw
Quoted 4 lines · Nigel Cunningham

Hmm.

I agree with you; it does sound like the process of eating memory is grabbing all the swap. I can't see how it could be doing that, however. If you really want to use Pavel's version, I'd suggest adding some more debug statements. Perhaps print out the number of swap pages free at the start of that loop.

Ok, now funny bit happends. Simple program like that:
while(1){
char *a=malloc(1024*1024*16);
if (a==NULL)

      break;
}

can allocate only about 200MB, than exits. That's the fist thing.
Second one, starting KDE, and when swap usage != 0 (just to be sure there is no problem with any assumption), gives me loads of error messages (see attached file).

Very bizzare behavior.

#14 lore raw
In reply to Grzegorz Piotr Jaskiewicz

Hi!

Quoted 2 lines

this is PCG-C1VE sony vaio picture book, dmesg attached. Kernel version 2.6.6-rc2-bk2.

Did it work okay with 2.6.5?
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#5 lore raw
In reply to Grzegorz Piotr Jaskiewicz

Hi!

Quoted 6 lines
Quoted 6 lines

I agree with you; it does sound like the process of eating memory is grabbing all the swap. I can't see how it could be doing that, however. If you really want to use Pavel's version, I'd suggest adding some more debug statements. Perhaps print out the number of swap pages free at the start of that loop.

Quoted 8 lines

Ok, now funny bit happends. Simple program like that:

while(1){
   char *a=malloc(1024*1024*16);
   if (a==NULL)
      break;
}

can allocate only about 200MB, than exits. That's the fist thing.

That's bad. That's even without swsusp, right? Again, test on 2.6.5 and post test case. Something is probably wrong in 2.6.6-bk.

Quoted 3 lines

Second one, starting KDE, and when swap usage != 0 (just to be sure there is no problem with any assumption), gives me loads of error messages (see attached file).

Can you try CONFIG_PREEMPT=n?
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#15 lore raw
In reply to Pavel Machek
Quoted 11 lines · Pavel Machek

Hi!

Quoted 3 lines

this is PCG-C1VE sony vaio picture book, dmesg attached. Kernel version 2.6.6-rc2-bk2.

Did it work okay with 2.6.5?

I did not tried it at that point.
I can switch back to 2.6.5 and see in the minute.

--
GJ

#6 lore raw
In reply to Pavel Machek
Quoted 4 lines · Pavel Machek

That's bad. That's even without swsusp, right? Again, test on 2.6.5 and post test case. Something is probably wrong in 2.6.6-bk.

Yes, it is working fine on 2.6.5. I can investigate my self in spare time. If you have any ideas, hints, or test procedures I can follow, tell me. I know C very good.

--
GJ

#8 lore raw
In reply to Pavel Machek
Quoted 7 lines · Pavel Machek
Quoted 3 lines

Second one, starting KDE, and when swap usage != 0 (just to be sure there is no problem with any assumption), gives me loads of error messages (see attached file).

Can you try CONFIG_PREEMPT=n?

Funny, now it doesn't run BUG(), but, instead I have two way behavior. Either he is complaining that bash
will not stop !! or that there is not enough pages free. Both wrong and bizzareus. This really needs fixing before 2.6.6 is out (imo).

1:

Apr 25 09:47:58 nalesnik kernel: Stopping tasks: ========================================================================
Apr 25 09:47:58 nalesnik kernel:  stopping tasks failed (1 tasks remaining)
Apr 25 09:47:58 nalesnik kernel: Suspend failed: Not all processes stopped!
Apr 25 09:47:58 nalesnik kernel: Restarting tasks...<6> Strange, bash not stopped

2:

Apr 25 10:53:52 nalesnik kernel: Stopping tasks: =======================================================================|
Apr 25 10:53:52 nalesnik kernel: Freeing memory: ..........|
Apr 25 10:53:52 nalesnik kernel: /critical section: counting pages to copy..[nosave pfn 0x44d]........................... (pages needed: 24493+512=25005 free: 4162)
Apr 25 10:53:52 nalesnik kernel: Suspend Machine: Couldn't get enough free pages, on 20843 pages short
Apr 25 10:53:52 nalesnik kernel: Suspend Machine: Suspend failed, trying to recover...
Apr 25 10:53:52 nalesnik kernel: blk: queue c6d40e00, I/O limit 4095Mb (mask 0xffffffff)
Apr 25 10:53:52 nalesnik kernel: Fixing swap signatures... ok
Apr 25 10:53:52 nalesnik kernel: Restarting tasks... done

--
GJ

#9 lore raw

Hi!

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

Second one, starting KDE, and when swap usage != 0 (just to be sure there is no problem with any assumption), gives me loads of error messages (see attached file).

Quoted 7 lines
Quoted 3 lines

Can you try CONFIG_PREEMPT=n?

Funny, now it doesn't run BUG(), but, instead I have two way behavior. Either he is complaining that bash
will not stop !! or that there is not enough pages free. Both wrong and bizzareus. This really needs fixing before 2.6.6 is out (imo).

Dump stack at time when process refuses to stop, and see why it can't be stopped. Then fix that :-).
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#7 lore raw
In reply to Grzegorz Piotr Jaskiewicz

Hi!

Quoted 7 lines
Quoted 4 lines

That's bad. That's even without swsusp, right? Again, test on 2.6.5 and post test case. Something is probably wrong in 2.6.6-bk.

Yes, it is working fine on 2.6.5. I can investigate my self in spare time. If you have any ideas, hints, or test procedures I can follow, tell me. I know C very good.

Try get akpm's attetion, send him your test program. I'm not mm/ guru, he'll probably point you to a good starting place (or probably fix it himself quickly).
Pavel

Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#10 lore raw
In reply to Pavel Machek
Quoted 14 lines · Pavel Machek

Hi!

Quoted 10 lines
Quoted 10 lines
Quoted 5 lines

Second one, starting KDE, and when swap usage != 0 (just to be sure there is no problem with any assumption), gives me loads of error messages (see attached file).

Can you try CONFIG_PREEMPT=n?

Quoted 9 lines
Quoted 4 lines

Funny, now it doesn't run BUG(), but, instead I have two way behavior. Either he is complaining that bash
will not stop !! or that there is not enough pages free. Both wrong and bizzareus. This really needs fixing before 2.6.6 is out (imo).

Dump stack at time when process refuses to stop, and see why it can't be stopped. Then fix that :-).

Quite easy to say. I don't really understeand all changes that 've been done over mm between 2.6.6-rc2-bk2 and 2.6.5. But from my tests today, it looks like processes locked (?) in kernel are not getting freezed.

Simple example. Mount something over nfs, than disconnect your network cable, and inside that dir run ls.
Kernel will not be able to freeze bash !!, obvioulsy bug. I'll try to investigate it my self, but if someone can get with fast explanation, to enlight me problem, that would be nice. Nfs is maybe a tougth example. Try i.e. dd bs=1 (to make it slower) if=/proc/kmem of=/dev/null,
or even open mc, and press F3 on /proc/kmem, providing that your machines is slow. At that point, MC on my computer eats about 900MB of swap ! (I have only 128MB of ram, so it's quite strange). Anyways, echo "4" >/proc/acpi/sleep, and kernel will not be able to freeze it.

--
GJ

#11 lore raw

Hi!

Quoted 10 lines
Quoted 8 lines
Quoted 4 lines

Funny, now it doesn't run BUG(), but, instead I have two way behavior. Either he is complaining that bash
will not stop !! or that there is not enough pages free. Both wrong and bizzareus. This really needs fixing before 2.6.6 is out (imo).

Dump stack at time when process refuses to stop, and see why it can't be stopped. Then fix that :-).

Quite easy to say. I don't really understeand all changes that 've been done over mm between 2.6.6-rc2-bk2 and 2.6.5.

I know its easy to say ;-).

Quoted 5 lines

Simple example. Mount something over nfs, than disconnect your network cable, and inside that dir run ls.
Kernel will not be able to freeze bash !!, obvioulsy bug. I'll try to investigate it my self, but if someone can get with fast explanation, to enlight me problem, that would be nice.

Not obviously, and try to use less "!"s.

If you disconnect your /dev/hda, you'll not be able to suspend. Bug? I'd call it design decision that allows me to keep it reasonably simply. And I'd say that disconnected nfs is similar issue.

Anyway, feel free to submit a patch, and if it is simple enough, I'll probably take it.

Quoted 7 lines

Nfs is maybe a tougth example. Try i.e. dd bs=1 (to make it slower) if=/proc/kmem of=/dev/null,
or even open mc, and press F3 on /proc/kmem, providing that your machines is slow. At that point, MC on my computer eats about 900MB of swap ! (I have only 128MB of ram, so it's quite strange). Anyways, echo "4" >/proc/acpi/sleep, and kernel will not be able to freeze it.

If you do something stupid, its okay that kernel is not able to suspend. F3 on /dev/kmem counts as "something stupid". If you find out something normal user (not root) can do... we are more likely to fix that.

I'd say that /dev/kmem issue is not worth fixing. NFS issue may be worth fixing, but I do not use NFS that much. Any other problems?

Pavel

Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc
#13 lore raw
In reply to a message not in the archive

Hi!

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines

Quite easy to say. I don't really understeand all changes that 've been done over mm between 2.6.6-rc2-bk2 and 2.6.5.

Quoted 7 lines
Quoted 3 lines

I know its easy to say ;-).

I am looking forward to see someone explaining me what has changed there acctually. This time, I am sure, obviously, kernel is counting free pages wrong. At least it does it incorrectly when it's about to 'hibernate'.

I do not know what went wrong there. If I did, I'd just fix it.

*But* if your test program doing malloc() in loop broke, you probably want to post test program to l-k, get akpm's attetion, and make someone fix it.

Quoted 5 lines
Quoted 5 lines

If you do something stupid, its okay that kernel is not able to suspend. F3 on /dev/kmem counts as "something stupid". If you find out something normal user (not root) can do... we are more likely to fix that.

Quoted 7 lines
Quoted 4 lines

I'd say that /dev/kmem issue is not worth fixing. NFS issue may be worth fixing, but I do not use NFS that much. Any other problems?

Those were just ways of reproducing problem. I know they are not very likely to be the case in real life, but simmilar lock up may occur somewhere else.

Similar lock probably is there in few more places. Approach is "fix them one by one". Not the nicest one, but...

So yes, I'm aware there are probably more cases like that; I just don't know effective way to find them all.

Quoted 2 lines

Well, maybe all beside nfs case. It just happends sometimes that network is over congested, just the real life.

freeze_processes tries for 5 seconds. That should be enough to handle common network congestion.
Pavel

Signature · 1 line
934a471f20d6580d5aad759bf0d97ddc