Page MenuHomeFreeBSD

fix build with LOCK_PROFILING but without KDTRACE_HOOKS
ClosedPublic

Authored by kp on Wed, Nov 27, 8:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 7, 8:53 PM
Unknown Object (File)
Thu, Dec 5, 12:10 PM
Unknown Object (File)
Mon, Dec 2, 6:57 AM
Unknown Object (File)
Wed, Nov 27, 8:41 PM
Subscribers

Details

Summary

Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kp requested review of this revision.Wed, Nov 27, 8:39 PM
kib added inline comments.
sys/kern/kern_rwlock.c
474

I do not understand this block. LOCK_PROFILING does not depend on KDTRACE_HOOK. While your patch puts LOCK_PROFILING control inside KDTRACE_HOOK block.

sys/kern/kern_rwlock.c
474

I think I misunderstood the intent behind doing_lockprof. It's to allow lock profiling to be enabled either unconditionally (with LOCK_PROFILING) or conditionally. (if KDTRACE_HOOKS and LOCKSTAT_PROFILE_ENABLED() returns true).

So the correct thing here would be:

#if defined(KDTRACE_HOOKS)
	uintptr_t state = 0;
#endif
#if defined(KDTRACE_HOOKS) || defined(LOCK_PROFILING)
	int doing_lockprof = 0;
#endif

(And then not have this #ifdef LOCK_PROFILING here, of course)

sys/kern/kern_rwlock.c
474

Yes, this sounds more correct.

sys/kern/kern_rwlock.c
466

Merge this block of ifdef with the previous one?

475–476

Remove the assignment?

956–957

Same?

sys/kern/kern_sx.c
587

Same, merge?

602–603

This line can be removed, the same assignment is happen right after the block.

1047–1048

Same

Review remarks

We now unconditionally assign 'state = v' (ifdef KDTRACE_HOOKS), but that should
be fine, because we only ever use 'state' if doing_lockprof is true, which is
when it was assigned prior to this change.
Updating D47822: fix build with LOCK_PROFILING but without KDTRACE_HOOKS

This revision is now accepted and ready to land.Fri, Nov 29, 4:09 PM
sys/kern/kern_rwlock.c
475–476

I don't see how this assignment can be removed. Without we'd always have state = 0.

sys/kern/kern_rwlock.c
475–476

It’ll be set if doing_lockprof == 1, which is the only case we actually use it.
Either because LOCKSTAT_PROFILE_ENABLED or LOCK_PROFILING.

markj added inline comments.
sys/kern/kern_rwlock.c
475–476

I think I misunderstood kib's comment because it applied to an old version of the file, so the comment appears in a misleading place.