Page MenuHomeFreeBSD

Introduce nhop_ref_locked_object().
ClosedPublic

Authored by markj on Jul 1 2020, 3:29 PM.

Details

Summary

Use it when we know that the object must have a positive reference
count. This provides two benefits:

  • We can assert that the refcount is positive.
  • We can use a cheaper operation to acquire the reference count.

I am open to alternate name suggestions.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

markj requested review of this revision.Jul 1 2020, 3:29 PM

Thank you for raising this diff! Was going to do the same, but you managed to do it faster :-)
LGTM, please see the naming comment :-)

sys/net/route/nhop_ctl.c
609 ↗(On Diff #73969)

Naming is hard :-)
Maybe we can do it slightly differently, like leave this function as nhop_ref_object and the original one as nhop_try_ref_object ?

I'd prefer not to mention locked in the name, as nhop objects have their locks, but we don't use them in refcounting.

What do you think?

sys/net/route/nhop_ctl.c
609 ↗(On Diff #73969)

I think that's much better than my name, will fix.

Introduce nhop_try_ref_object() instead.

I note that we also have nhop_ref_any() and nhop_free_any() as well,
but they are unused.

Introduce nhop_try_ref_object() instead.

I note that we also have nhop_ref_any() and nhop_free_any() as well,
but they are unused.

That's the route multipath part, which will be introduced soon.

This revision is now accepted and ready to land.Jul 6 2020, 8:48 PM
This revision was automatically updated to reflect the committed changes.