tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: RFC: L2TPv3 interface



Hi,


On 2017/01/20 21:26, Kengo NAKAHARA wrote:
> On 2017/01/20 0:38, Taylor R Campbell wrote:
>>    Date: Thu, 19 Jan 2017 17:58:17 +0900
>>    From: Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
>>    +/*
>>    + * l2tp_variant update API.
>>    + *
>>    + * Assumption:
>>    + * reader side dereferences sc->l2tp_var in reader critical section only,
>>    + * that is, all of reader sides do not reader the sc->l2tp_var after
>>    + * pserialize_perform().
>>    + */
>>    +static void
>>    +l2tp_variant_update(struct l2tp_softc *sc, struct l2tp_variant *nvar)
>>    +{
>>    +       struct ifnet *ifp = &sc->l2tp_ec.ec_if;
>>    +       struct l2tp_variant *ovar = sc->l2tp_var;
>>    +
>>    +       KASSERT(mutex_owned(&sc->l2tp_lock));
>>    +
>>    +       membar_producer();
>>    +       atomic_swap_ptr(&sc->l2tp_var, nvar);
>>    +       pserialize_perform(l2tp_psz);
>>    +       psref_target_destroy(&ovar->lv_psref, lv_psref_class);
>>
>> No need for atomic_swap_ptr.  Just
>>
>>         sc->l2tp_var = nvar;
>>
>> is enough.  Nobody else can write to it because we hold the lock.
> 
> Between writer and writer, it is correct. However, between writer and
> reader, I think atomic_swap_ptr is required to prevent reader's load
> before writer's store done. Is this correct?

Sorry, I was wrong. Reader has nothing to do with atomic_ops. So,
As you said, atomic_swap_ptr is not required here. I will fix it.


Thanks,

-- 
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
IoT Platform Development Department,
Network Division,
Technology Unit

Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>


Home | Main Index | Thread Index | Old Index