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)
Dec 22 2023, 10:24 PM
Unknown Object (File)
Dec 21 2023, 3:23 PM
Unknown Object (File)
Aug 4 2023, 5:48 AM
Unknown Object (File)
Aug 4 2023, 5:47 AM
Unknown Object (File)
Aug 4 2023, 5:47 AM
Unknown Object (File)
Aug 4 2023, 5:46 AM
Unknown Object (File)
Aug 4 2023, 5:45 AM
Unknown Object (File)
Aug 4 2023, 5:36 AM
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.