> -----Original Message-----
> From: Jerin Jacob Kollanukkaran <jer...@marvell.com>
> Sent: Wednesday, March 13, 2019 5:41 PM
> To: Joyce Kong (Arm Technology China) <joyce.k...@arm.com>;
> dev@dpdk.org
> Cc: step...@networkplumber.org; Honnappa Nagarahalli
> <honnappa.nagaraha...@arm.com>; tho...@monjalon.net; nd
> <n...@arm.com>; jerin.ja...@caviumnetworks.com; Gavin Hu (Arm
> Technology China) <gavin...@arm.com>
> Subject: Re: [dpdk-dev] [PATCH v5 1/2] eal/ticketlock: ticket based to improve
> fairness
> 
> On Mon, 2019-03-11 at 13:52 +0800, Joyce Kong wrote:
> > The spinlock implementation is unfair, some threads may take locks
> > aggressively while leaving the other threads starving for long time.
> >
> > This patch introduces ticketlock which gives each waiting thread a
> > ticket and they can take the lock one by one. First come, first
> > serviced.
> > This avoids starvation for too long time and is more predictable.
> >
> > Suggested-by: Jerin Jacob <jer...@marvell.com>
> > Signed-off-by: Joyce kong <joyce.k...@arm.com>
> > Reviewed-by: Gavin Hu <gavin...@arm.com>
> > Reviewed-by: Ola Liljedahl <ola.liljed...@arm.com>
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagaraha...@arm.com>
> > ---
> > +static inline __rte_experimental int
> > +rte_ticketlock_trylock(rte_ticketlock_t *tl) {
> > +   unsigned int next = __atomic_load_n(&tl->next,
> > __ATOMIC_RELAXED);
> > +   unsigned int cur = __atomic_load_n(&tl->current,
> > __ATOMIC_RELAXED);
> > +   if (next == cur) {
> > +           if (__atomic_compare_exchange_n(&tl->next, &next,
> > next+1,
> > +               0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
> 
> gcc 8.2 emits the following compilation error.
> 
> /export/dpdk.org/build/include/generic/rte_ticketlock.h:93:46: error:
> incompatible pointer types passing 'unsigned int *' to parameter of type
> 'uint16_t *' (aka 'unsigned short *') [-Werror,-Wincompatible- pointer-types]
>                 if (__atomic_compare_exchange_n(&tl->next, &next,
> next+1,
> 

Fix the error by changing next and cur from unsigned int to unint16_t in V6.


> 
> > +                   return 1;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >

Reply via email to