Re: [PATCH 1/2] 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/24/21 5:52 AM, Pankaj Raghav wrote:
> Hi Jens,
> 
> On Tue, Nov 23, 2021 at 12:15:18PM -0700, Jens Axboe wrote:
>> +bool blk_stats_alloc_enable(struct request_queue *q)
>> +{
>> +	struct blk_rq_stat *poll_stat;
>> +
>> +	poll_stat = kcalloc(BLK_MQ_POLL_STATS_BKTS, sizeof(*poll_stat),
>> +				GFP_ATOMIC);
>> +	if (!poll_stat)
>> +		return false;
>> +
>> +	if (cmpxchg(&q->poll_stat, poll_stat, NULL) != poll_stat) {
> Isn't the logic inverted here? As we already check for non-NULL
> q->poll_stat at the caller side, shouldn't it be:
> 
> if (cmpxchg(&q->poll_stat, NULL, poll_stat) != NULL) {

Yes, I did fix that one up right after sending this out, here's the
patch:

https://git.kernel.dk/cgit/linux-block/commit/?h=for-5.17/block&id=987567fece249eabb14406e4e52f427e679d8461

-- 
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