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)
Sun, Nov 9, 7:39 PM
Unknown Object (File)
Sun, Nov 9, 1:53 AM
Unknown Object (File)
Mon, Nov 3, 1:11 AM
Unknown Object (File)
Sat, Nov 1, 8:36 PM
Unknown Object (File)
Thu, Oct 30, 5:06 AM
Unknown Object (File)
Tue, Oct 28, 6:26 AM
Unknown Object (File)
Mon, Oct 27, 9:23 AM
Unknown Object (File)
Sun, Oct 26, 11:01 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.