Re: [PATCH 3/3] block: only allocate poll_stats if there's a user of them

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

 



On 11/23/21 11:59 AM, Christoph Hellwig wrote:
> On Tue, Nov 23, 2021 at 11:58:42AM -0700, Jens Axboe wrote:
>> On 11/23/21 11:50 AM, Christoph Hellwig wrote:
>>>> +	spin_lock_irq(&q->stats->lock);
>>>> +	if (q->poll_stat) {
>>>> +		spin_unlock_irq(&q->stats->lock);
>>>> +		kfree(poll_stat);
>>>> +		return true;
>>>> +	}
>>>> +	q->poll_stat = poll_stat;
>>>> +	spin_unlock_irq(&q->stats->lock);
>>>
>>> If we'd use a cmpxchg to install the pointer we could keep the
>>> blk_queue_stats definition private.
>>
>> How about we just move this alloc+enable logic into blk-stat.c instead?
> 
> That's a good idea either way.  But I think cmpxchg is much better
> for installing a pointer than an unrelated lock.

True, I'll do that while moving it.

-- 
Jens Axboe




[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