Page MenuHomeFreeBSD

Use enumeration to indicate swap almost full and full, instead of 2 variables.
Needs ReviewPublic

Authored by ota_j.email.ne.jp on Oct 12 2019, 2:07 AM.

Details

Reviewers
kib
markj
alc
dougm
Summary

Use enumeration to indicate usage level of swap space and simplify code.

Both high and low watermark are too low at today's hardware, like 1 ~ 10 GB
while it was large enough numbers 20 years ago 16 ~ 64 MB.
I'd like to propose to change 1/16 as high watermark and 1/32 as low one
to adjust at swapon time (as a separate and next changeset.)

Test Plan

Use all swap spaces to trigger "swap_pager: almost out of swap" print out.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 26995
Build 25291: arc lint + arc unit

Event Timeline

dougm added inline comments.Oct 12 2019, 2:56 AM
sys/vm/swap_pager.c
482–485

How about "== SWPG_LOW"?

489

Why is this line necessary?

768

Does this line really compile? It looks about 3 arguments short.

Use "== SWPG_LOW" comparison for almost full warning.
Drop swp_gauge > SWPG_LOW comparison for high watermark check.

dougm added inline comments.Oct 12 2019, 5:13 AM
sys/vm/swap_pager.c
488

How about if swap_pager_avail >= nswap_lowat and swap_pager_avail <= nswap_hiwat? You are changing that behavior.

ota_j.email.ne.jp marked 2 inline comments as done.Oct 13 2019, 2:42 AM
ota_j.email.ne.jp added inline comments.
sys/vm/swap_pager.c
488

That's a case when we reset SWPG_FULL status.

Page in/out doesn't happen over (512-128) size block and system will hit the other cases.
So, I think in order to hit this range with SWPG_FULL, one needs to swap on/off a couple of MB swap devices.
Given today's physical memory is in the unit of GB, a couple of MB swap won't save the system.

I think we are okay as is for now.

Or I can add else case to the top if-elseif like following:
else {

if(swp_gauge == SWPG_FULL)
    swp_gauge = SWPG_LOW;

}

What do you think?

ryan_freqlabs.com added inline comments.
sys/vm/swap_pager.c
326

Please add comments describing what each of these means.