Page MenuHomeFreeBSD

swapoff(8): add -f
ClosedPublic

Authored by kib on Nov 29 2021, 4:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Unknown Object (File)
Fri, Mar 22, 9:33 PM
Subscribers

Details

Summary
swapoff(2): replace special device name argument with a structure

For compatibility, add a placeholder pointer to the start of the
added struct swapoff_new_args, and use it to distinguish old vs. new
style of syscall invocation.
swapoff(2): add a SW_OFF_FORCE flag

The flag requests skipping the heuristic which tries to avoid leaving system
with more allocated memory than available from RAM and remanining swap.
swapoff: add -f flag

to force swapout by ignoring the heuristic that calculates amount of
allocated memory against total of RAM plus remaining swap.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Nov 29 2021, 4:44 PM
sbin/swapon/swapon.8
133

The heuristic is inexact, but without it swapoff can easily hang the system, I believe. This should be noted.

sbin/swapon/swapon.c
797–803

Doesn't it need to be swapoff(&sa)?

sys/vm/swap_pager.c
2542

Perhaps pass the flag through directly.

sys/vm/swap_pager.h
80

SWAPOFF_FORCE is only one character longer, I would just call it that.

kib marked 4 inline comments as done.

Handle notes.
Check for known flags.

This seems ok to me, thank you. To be honest I still do not really understand why this approach is preferable to adding a new system call.

sbin/swapon/swapon.8
128–129

I think "very inexact" will just use confuse users. Rather, it is very conservative.

134

Maybe, "if there is unsufficient swap space remaining."

sys/vm/swap_pager.c
2501

IMO it is worth explaining why we do this.

This revision is now accepted and ready to land.Dec 1 2021, 5:10 PM
kib marked 3 inline comments as done.Dec 2 2021, 3:20 AM

This seems ok to me, thank you. To be honest I still do not really understand why this approach is preferable to adding a new system call.

Essentially, we add a whole new syscall just for 'force' flag. IMO it is too much. Our syscalls interface is not logical of course, but such interface expansion is outlawed IMO.

Handle Mark' notes.
Update swapoff(2) man page.

This revision now requires review to proceed.Dec 2 2021, 3:21 AM
lib/libc/sys/swapon.2
71–72
85
86
sbin/swapon/swapon.8
134
kib marked 4 inline comments as done.

Fix grammar in comments.
Remove MPSAFE and ARGUSED annotations.

This revision is now accepted and ready to land.Dec 3 2021, 3:05 PM

I think that's all I have to say.

lib/libc/sys/swapon.2
80
85
86
97
98
99
sbin/swapon/swapon.8
128
129
133
kib marked 9 inline comments as done.Dec 4 2021, 9:09 PM

Man pages fixes by alc.

This revision now requires review to proceed.Dec 4 2021, 9:12 PM