Page MenuHomeFreeBSD

First cut at cleaning up MP_RING_NO_64BIT_ATOMICS code
AbandonedPublic

Authored by shurd on May 8 2019, 10:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 18, 6:49 PM
Unknown Object (File)
Mon, Nov 18, 6:24 PM
Unknown Object (File)
Thu, Nov 7, 2:07 PM
Unknown Object (File)
Thu, Nov 7, 7:58 AM
Unknown Object (File)
Oct 21 2024, 2:25 AM
Unknown Object (File)
Oct 4 2024, 5:52 PM
Unknown Object (File)
Oct 4 2024, 11:53 AM
Unknown Object (File)
Sep 26 2024, 12:00 PM

Details

Reviewers
None
Group Reviewers
iflib
Summary

Clean up code used when MP_RING_NO_64BIT_ATOMICS is defined.
ie: defined(powerpc) || defined(mips) || defined(i386)

Highlights:
Unlock ring during drain() callback to allow filling while draining
Grab ring mutex (if present) before reading ring state
Remove dead code from enqueue

Test Plan

I'm going to build amd64 with MP_RING_NO_64BIT_ATOMICS and
try it out, but it would be nice to have a native platform tested.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 24163
Build 23010: arc lint + arc unit

Event Timeline

marius added inline comments.
sys/net/mp_ring.c
103

I'd suggest to move this to mp_ring.h as a static inline (maybe even static __always_inline) function to increase the likelihood of the compiler actually inlining the thing.

sys/net/mp_ring.h
51

Hrm, I think something like the following would be somewhat clearer and more readable:
#ifndef MP_RING_NO_64BIT_ATOMICS
typedef uint64_t state_t
#else
typedef volatile uint64_t state_t
#endif

struct ifmp_ring {
state_t state __aligned(CACHE_LINE_SIZE);

sys/net/mp_ring.c
103

On a closer look, I don't think it actually makes sense to grab the lock for reading the ring state in the places ifmp_ring_get_state() currently is used.