Page MenuHomeFreeBSD

Add interrupts_enabled() to cpufunc.h
AbandonedPublic

Authored by mhorne063_gmail.com on Mar 6 2018, 9:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, May 7, 3:16 PM
Unknown Object (File)
Mon, May 6, 2:06 AM
Unknown Object (File)
Mon, Apr 22, 3:28 AM
Unknown Object (File)
Apr 6 2024, 7:23 AM
Unknown Object (File)
Mar 30 2024, 9:49 AM
Unknown Object (File)
Dec 20 2023, 5:56 AM
Unknown Object (File)
Dec 12 2023, 11:45 PM
Unknown Object (File)
Nov 28 2023, 3:03 PM

Details

Reviewers
manu
Summary

Prerequisite patch to D14599.

interrupts_enabled() simply returns a bool value of whether or not
the interrupt enable flag is currently set for a cpu.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

I have the global question about this function. Am I right that you use it to avoid collecting coverage data under inappropriate context ? Who did suggested to use this technique ?

It is perhaps correct for x86 (i.e. i386 and amd64): we have interrupts disabled under spin locks, during kernel entry/exit, and during interrupt handling on x86. Note that while the spinlock property of disabling interrupts is MI, as much as interrupts are MI concept, the property of having interrupts disabled in interrupts handlers is MD for x86. I have no idea what other architectures do there.

sys/amd64/include/cpufunc.h
48 ↗(On Diff #40565)

This is not going to fly, bde will be disappointed. cpufunc.h should not pollute namespace with random machine header.

842 ↗(On Diff #40565)

I suspect that more proper location for such helper is machine/cpu.h

@kib Yes, you are correct about the purpose of this function. This particular technique came from the brief discussion about it between yourself and @emaste, however, the (perhaps naive) assumption that it would apply equally to all architectures was mine. The coverage function also checks td->intr_nesting_level which I presume is a more MI way of avoiding some of the code in unwanted contexts, but is less effective (on x86) than checking this interrupts_enabled() function.

That being said, it is not crucial that this works immediately on all platforms as we only really need it for x86 at the moment. The others would just be nice to have.

Moved function from machine/cpufunc.h to machine/cpu.h