Re: [PATCHv2] sbitmap: fix batched wait_cnt accounting

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

 



On Thu, Aug 25, 2022 at 08:09:50AM +0200, Hannes Reinecke wrote:
> > +static bool __sbq_wake_up(struct sbitmap_queue *sbq, int *nr)
> 
> Why is '*nr' a pointer? It's always used as a value, so what does promoting
> it to a point buys you?

Not quite, see below:
 
> >   {
> >   	struct sbq_wait_state *ws;
> > -	unsigned int wake_batch;
> > -	int wait_cnt;
> > +	int wake_batch, wait_cnt, sub, cur;
> >   	ws = sbq_wake_ptr(sbq);
> >   	if (!ws)
> >   		return false;
> > -	wait_cnt = atomic_dec_return(&ws->wait_cnt);
> > +	wake_batch = READ_ONCE(sbq->wake_batch);
> > +	do {
> > +		cur = atomic_read(&ws->wait_cnt);
> > +		sub = min3(wake_batch, *nr, cur);
> > +		wait_cnt = cur - sub;
> > +	} while (!atomic_try_cmpxchg(&ws->wait_cnt, &cur, wait_cnt));
> > +
> > +	*nr -= sub;

Dereferenced here to account for how many bits were considered for this wake
cycle.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux