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, Mar 29, 5:18 PM
Unknown Object (File)
Sat, Mar 21, 4:57 AM
Unknown Object (File)
Fri, Mar 20, 7:38 PM
Unknown Object (File)
Fri, Mar 20, 12:22 PM
Unknown Object (File)
Fri, Mar 20, 9:10 AM
Unknown Object (File)
Wed, Mar 18, 1:34 PM
Unknown Object (File)
Mon, Mar 16, 11:38 AM
Unknown Object (File)
Sun, Mar 15, 2:08 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.