Page MenuHomeFreeBSD

Micro optimise _callout_stop_safe() by removing dead code.
ClosedPublic

Authored by hselasky on Sep 1 2020, 7:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 24, 6:36 PM
Unknown Object (File)
Tue, Jan 21, 6:00 AM
Unknown Object (File)
Sun, Jan 19, 12:26 AM
Unknown Object (File)
Sat, Jan 11, 10:21 PM
Unknown Object (File)
Dec 31 2024, 7:27 AM
Unknown Object (File)
Dec 14 2024, 6:29 AM
Unknown Object (File)
Dec 13 2024, 6:41 AM
Unknown Object (File)
Nov 13 2024, 9:30 PM
Subscribers
None

Details

Summary

The CS_DRAIN flag cannot be set at the same time like the async-drain function
pointer is set. These are orthogonal features. Assert this at the beginning
of the function.

Before:

if (flags & CS_DRAIN) {
        /* FALLTHROUGH */
} else if (xxx) {
        return yyy;
}
if (drain) {
        zzz = drain;
}

After:

if (flags & CS_DRAIN) {
        /* FALLTHROUGH */
} else if (xxx) {
        return yyy;
} else {
        if (drain) {
                zzz = drain;
        }
}

MFC after: 1 week
Sponsored by: Mellanox Technologies // Nvidia

Diff Detail

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

Event Timeline

hselasky created this revision.
markj added inline comments.
sys/kern/kern_timeout.c
1278 ↗(On Diff #76509)

I guess this KTR message was wrong before, in the case where CS_DRAIN is specified.

This revision is now accepted and ready to land.Sep 1 2020, 8:00 PM
sys/kern/kern_timeout.c
1280 ↗(On Diff #76509)

What happens if a drain function for this CPU is already set by a previous call?

sys/kern/kern_timeout.c
1280 ↗(On Diff #76509)

Setting drain is like the last thing a callout does before being freed, though we could KASSERT() that in a separate patch, that the cc_exec_drain() is NULL.

hselasky added inline comments.
sys/kern/kern_timeout.c
1278 ↗(On Diff #76509)

Yes, in the other case the callout is synchronously drained.