Page MenuHomeFreeBSD

Do not ignore arc_adjust() return value
ClosedPublic

Authored by mav on Nov 9 2018, 6:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 5 2024, 4:48 AM
Unknown Object (File)
Oct 1 2024, 2:52 PM
Unknown Object (File)
Sep 15 2024, 8:09 PM
Unknown Object (File)
Sep 9 2024, 1:01 PM
Unknown Object (File)
Sep 9 2024, 2:19 AM
Unknown Object (File)
Sep 8 2024, 7:05 AM
Unknown Object (File)
Sep 4 2024, 1:23 PM
Unknown Object (File)
Aug 15 2024, 6:31 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.