Page MenuHomeFreeBSD

try to free blocks by upgrading object locks
Needs ReviewPublic

Authored by dougm on Nov 12 2019, 3:56 AM.

Details

Reviewers
alc
kib
Summary

In swap_pager_unswapped, include an attempt to temporarily upgrade a read lock to an exclusive lock in order to edit the pctrie. Allow this to be invoked without the write lock held.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

Adapt to recent swap_pager.c change.

sys/vm/swap_pager.c
2167–2168

Is this check still needed after the rest of the changes ?

sys/vm/vm_fault.c
276

Can you split this change and tryupgrade in swap_pager_unswapped into separate review ? I think that introduction of lookup() and removal of SWM_POP is obviously good change, but it should not be mixed with locking logic.

It looks we better drop swp_pager_meta_ctl() changes from this, D22324, and let D22409 take over the lookup implementation while dropping SWM_POP for simpler diff.
D22409 change is to optimize swap_pager_haspage() with additional searches after successful pindex lookup.

sys/vm/swap_pager.c
1122–1144

Given swp_pager_meta_ctl() with SWM_POP calls VM_OBJECT_ASSERT_WLOCKED, I expected VM_OBJECT_ASSERT_WLOCKED.
Is VM_OBJECT_ASSERT_LOCKED call because of vm_falut.c change?

1139

We need
We also need
swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES, 1);
before SWAPBLK_NONE assignment.

swp_pager_freeswapspace calls blist_free while swp_pager_free_empty_swblk calls uma_zfree.

dougm edited the summary of this revision. (Show Details)

Update after overlapping change.

I am somewhat curious how much does the upgrade succeed. Did you measured it ? E.g. the counters of total vm_pager_page_unswapped calls during buildworld vs. the number of times the lock needs to be upgraded vs. the number of successfull upgrades.

In D22324#490910, @kib wrote:

I am somewhat curious how much does the upgrade succeed. Did you measured it ? E.g. the counters of total vm_pager_page_unswapped calls during buildworld vs. the number of times the lock needs to be upgraded vs. the number of successfull upgrades.

I measured it, and learned nothing. How should I test so that I might learn something.


World build completed on Mon Dec 9 04:03:03 CST 2019
World built in 6609 seconds, ncpu: 6, make -j6


vm.domain.0.stats.unswappable: 0
debug.counters.num_unswapped_upgrades: 0
debug.counters.num_unswapped_upgrade_tries: 0
debug.counters.num_unswapped_calls: 0