NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/57231: event counters aren't dtraceable



>Number:         57231
>Category:       kern
>Synopsis:       event counters aren't dtraceable
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 14 15:55:00 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD Countation
>Environment:
creeping up in temperature
>Description:
The evcnt(9) API is designed for users to manually update the ev_count member of a struct evcnt object.  The caller is responsible for serializing access, whether with CPU-local data, atomics, or locks.  For example:

arch/aarch64/aarch64/fpu.c:             curcpu()->ci_vfp_use.ev_count++;
arch/arm/cortex/pl310.c:        atomic_inc_64(&arml2cc_sc->sc_ev_inv.ev_count);

The NetBSD kernel has multitudes of event counters.  For example, my laptop has 273 event counters.

These events can be read with `vmstat -e', but it would be useful if we could use them as dtrace probes, for example to get a histogram of stack traces for when the events happen.

Perhaps we could define an ev_count(&evcnt) function which (a) has a static dtrace probe, and (b) returns a pointer to the ev_count member for the caller to increment with ++ or atomic_inc_64 or whatever (perhaps with attribute((warn_unused_result)) to catch the mistake of a missing increment).

That way, the above examples could be written:

	(*ev_count(&curcpu()->ci_vfp_use))++;
	atomic_inc_64(ev_count(&arml2cc_sc->sc_ev_inv));

And maybe add an ev_count_inc function to make the non-atomic case a little less of a mouthful:

	ev_count_inc(&curcpu()->ci_vfp_use);
>How-To-Repeat:
dtraaaaaaaaaaaaaaaaaaace
>Fix:
Yes please!



Home | Main Index | Thread Index | Old Index