Page MenuHomeFreeBSD

Do not ignore arc_adjust() return value
ClosedPublic

Authored by mav on Nov 9 2018, 6:02 PM.
Tags
None
Referenced Files
F83282154: D17927.id50241.diff
Wed, May 8, 9:57 AM
Unknown Object (File)
Jan 5 2024, 7:50 AM
Unknown Object (File)
Dec 20 2023, 5:55 AM
Unknown Object (File)
Nov 13 2023, 11:05 PM
Unknown Object (File)
Nov 6 2023, 6:22 AM
Unknown Object (File)
Oct 5 2023, 5:08 AM
Unknown Object (File)
Sep 16 2023, 4:34 AM
Unknown Object (File)
Sep 12 2023, 2:39 AM
Subscribers

Details

Summary

Looking through the ARC back pressure code I see a scenario when I think ARC may not shrink as fast as it could:

  1. arc_size < arc_c and arc_adjust() does not evict anything, returning zero to arc_reclaim_thread();
  2. arc_available_memory() reports memory pressure, which can not be satisfied by arc_kmem_reap_now();
  3. arc_shrink() reduces arc_c and calls arc_adjust(), return of which is ignored;
  4. even if the last arc_adjust() could not satisfy arc_size < arc_c, arc_reclaim_thread() will still go to sleep, since the first one returned zero().

This patch supposed to cover that case.

Can anybody see any flaw in my logic?

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj added inline comments.
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
4921 ↗(On Diff #50220)

Should this be +=? If the first call returned a non-zero value, we may clobber it here (though I suspect that is quite unlikely in practice).

This revision is now accepted and ready to land.Nov 9 2018, 11:43 PM
allanjude added inline comments.
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
4921 ↗(On Diff #50220)

I agree

mav marked an inline comment as done.Nov 10 2018, 1:42 AM
mav added inline comments.
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
4921 ↗(On Diff #50220)

I thought about this for some time too. Specific value here is not important, only zero or non-zero. Zero here can be only in two cases: either there is nothing to evict, which is unlikely, or we couldn't evict anything at the last call. In either case I see no real reason why we would care what the first call returned. But I see no problem from += there, it will just do another try, not a dead loop, so I can add it if you like.

This revision was automatically updated to reflect the committed changes.