Project

General

Profile

Actions

Bug #1356

open

I have a doubt about the urcu_bp_smp_mb_slave called in _urcu_bp_read_unlock.

Added by wenbin yao about 2 months ago. Updated about 2 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
06/16/2022
Due date:
% Done:

0%

Estimated time:

Description

I have a doubt about the urcu_bp_smp_mb_slave called in _urcu_bp_read_unlock.
What is its function and how it works.

_urcu_bp_read_lock_update function will be called by _urcu_bp_read_lock,
and _urcu_bp_read_lock_update is as follows:

static inline void _urcu_bp_read_lock_update(unsigned long tmp) {
if (caa_likely(!(tmp & URCU_BP_GP_CTR_NEST_MASK))) {
_CMM_STORE_SHARED(URCU_TLS(urcu_bp_reader)->ctr, _CMM_LOAD_SHARED(urcu_bp_gp.ctr));
urcu_bp_smp_mb_slave();
} else
_CMM_STORE_SHARED(URCU_TLS(urcu_bp_reader)->ctr, tmp + URCU_BP_GP_COUNT);
}

_urcu_bp_read_unlock is as follows:
static inline void _urcu_bp_read_unlock(void) {
unsigned long tmp;

tmp = URCU_TLS(urcu_bp_reader)->ctr;
urcu_assert(tmp & URCU_BP_GP_CTR_NEST_MASK);
/* Finish using rcu before decrementing the pointer. /
urcu_bp_smp_mb_slave();
_CMM_STORE_SHARED(URCU_TLS(urcu_bp_reader)->ctr, tmp - URCU_BP_GP_COUNT);
cmm_barrier(); /
Ensure the compiler does not reorder us with mutex */
}

I know the typical scenarios of using membarrier as follows:
fast path: slow path:
a=1 b=1
asm volatile ("" : : : "memory"); membarrier(MEMBARRIER_CMD_GLOBAL, 0, 0);
*read_b = b; *read_a = a

There is a model write-urcu_bp_smp_mb_slave-read in the use of urcu_bp_smp_mb_slave
called in _urcu_bp_read_lock.
I cannot find a similar model in the use of urcu_bp_smp_mb_slave
called in _urcu_bp_read_unlock. This model seems like read-urcu_bp_smp_mb_slave-write,
not write-urcu_bp_smp_mb_slave-read.

Actions #1

Updated by Mathieu Desnoyers about 2 months ago

"This model seems like read-urcu_bp_smp_mb_slave-write, not write-urcu_bp_smp_mb_slave-read."

Your statement above is correct. Why do you think it is an issue ? The membarrier/compiler barrier pair acts as a full memory barrier, so it should be fine for ordering writes before reads and reads before writes as well.

Actions

Also available in: Atom PDF