[Bug 224975] shutdown(8) needs to wait longer for swapoff to avoid a “Cannot allocate memory” error

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Jan 7 18:27:32 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224975

            Bug ID: 224975
           Summary: shutdown(8) needs to wait longer for swapoff to avoid
                    a “Cannot allocate memory” error
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: wosch at FreeBSD.org

While analysing the bug #224479 I noticed that `shutdown -r now’ runs to fast
and failed to swapoff a swap device or swap file.

I see on the console the error message:

  swapoff: /dev/md99: Cannot allocate memory

and soon later a kernel panic. Not good.

This happens when more swap space is in use than free memory is available. E.g.
you have 2.5GB swap space, 69MB are in use and only 49MB Free memory is
available (according to the top(1) command).

How to repeat:

# start some processes, which need a little bit more RAM than available
for i in $(seq 1 20);do perl -e '$a=`man tcsh`; for(0..100) { $b.=$a}; sleep
100' & done

top(1) reports:

Mem: 611M Active, 51M Inact, 112M Laundry, 142M Wired, 103M Buf, 49M Free
Swap: 2500M Total, 69M Used, 2431M Free, 2% Inuse


# now reboot with shutdown
$ shutdown -r now


you will see the “swapoff: /dev/md99: Cannot allocate memory” error message
because 49M Free Mem is < than 69M used swap.

followed by a kernel swap_pager I/O error message

In case of low memory I think that shutdown/reboot needs to wait a little bit
(3..10 seconds) after we kill the processes. Then there will be enough free
memory available, and the swapoff call will run successfully.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list