Page MenuHomeFreeBSD

Add possibility to disable or reduce amount of UMA debugging with INVARIANTS
ClosedPublic

Authored by glebius on Apr 25 2018, 5:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 14 2024, 11:53 AM
Unknown Object (File)
Dec 20 2023, 5:26 AM
Unknown Object (File)
Dec 3 2023, 10:08 AM
Unknown Object (File)
Nov 23 2023, 12:02 AM
Unknown Object (File)
Nov 13 2023, 6:23 PM
Unknown Object (File)
Nov 10 2023, 6:36 AM
Unknown Object (File)
Oct 30 2023, 7:59 PM
Unknown Object (File)
Oct 8 2023, 5:33 AM
Subscribers

Details

Summary

When running with INVARIANTS, two major things are done: KASSERTs are
checked and UMA performs memory debugging. The latter consist of two
things: trashing freed memory and checking that allocated memory is
properly trashed, and also of keeping a bitset of freed items.
Trashing/checking creates a lot of CPU cache poisoning, while keeping
debugging bitsets consistent creates a lot of contention on UMA zone
lock(s).

This change allows either to disable UMA debugging with INVARIANTS,
so that only KASSERTs are done. Or to reduce amount of debugging,
e.g. trash/check and track only every N-th item. The N is controled
by a loader tunable. It isn't possible to strictly follow the number,
but still amount of debugging is reduced roughly by (N-1)/N percent.

Diff Detail

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

Event Timeline

sys/vm/uma_core.c
307 ↗(On Diff #41864)

Why all debugging controls not hidden under the option ?

In fact, I think that it is better to split this out of INVARIANTS under some other option, like UMA_CHECKS.

3947 ↗(On Diff #41864)

... and this.

sys/vm/uma_core.c
2945 ↗(On Diff #41864)

Reading this is painful.. I'm not sure what the best way to fix it would be, though

sys/vm/uma_core.c
307 ↗(On Diff #41864)

Do we have any more debugging controls in VM?

I'm on a fence about introducing new kernel options to separate INVARIANTS and UMA debugging. But anyway, this is orthogonal to this change. Adding the kernel option before this change or after this change requires same effort.

sys/vm/uma_core.c
307 ↗(On Diff #41864)

E.g. DIAGNOSTICS turn on very costly checks in vmem. There is also separate sysctl to manage it, debug.vmem_check.

I think all of these inline ifdefs make the code a lot harder to read. Could we instead introduce wrapper functions for the ctor and dtor and hide the logic there?

I think all of these inline ifdefs make the code a lot harder to read. Could we instead introduce wrapper functions for the ctor and dtor and hide the logic there?

We are disabling not only trash_ctor/trash_dtor, but calls to uma_dbg_free/uma_dbg_alloc. I don't see any blocks of code that are identical and can be collapsed into one function.

sys/vm/uma_core.c
307 ↗(On Diff #41864)

UMA debugging won't fit into debug.vmem_check namespace. I can rename debug.vmem_check into vm.debug.vmem to gather all stuff into one sysctl branch. Or debug.vm if we prefer it to vm.debug.

Hey guys, I know that ifdefs suck, but still going to forward with checking this in. If you can suggest some change to ifdefs, I am open to that. E.g. keep them minimal, so there is no duplication between debug and !debug case. Or you may prefer to keep the maximal, so that code is more readable. I can do either, but I'd like to get forward with this change.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 8 2018, 12:15 AM
This revision was automatically updated to reflect the committed changes.