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.