Re: [PATCH V2 for-4.21 2/2] blk-mq: alloc q->queue_ctx as normal array

Greg Kroah-Hartman
2018-11-19T10:17:52Z

On Mon, Nov 19, 2018 at 10:04:27AM +0800, Ming Lei wrote:
> On Sat, Nov 17, 2018 at 11:03:42AM +0100, Greg Kroah-Hartman wrote:
> > On Sat, Nov 17, 2018 at 10:34:18AM +0800, Ming Lei wrote:
> > > On Fri, Nov 16, 2018 at 06:06:23AM -0800, Greg Kroah-Hartman wrote:
> > > > On Fri, Nov 16, 2018 at 07:23:11PM +0800, Ming Lei wrote:
> > > > > Now q->queue_ctx is just one read-mostly table for query the
> > > > > 'blk_mq_ctx' instance from one cpu index, it isn't necessary
> > > > > to allocate it as percpu variable. One simple array may be
> > > > > more efficient.
> > > >
> > > > "may be", have you run benchmarks to be sure? If so, can you add the
> > > > results of them to this changelog? If there is no measurable
> > > > difference, then why make this change at all?
> > >
> > > __blk_mq_get_ctx() is used in fast path, what do you think about which
> > > one is more efficient?
> > >
> > > - *per_cpu_ptr(q->queue_ctx, cpu);
> > >
> > > - q->queue_ctx[cpu]
> >
> > You need to actually test to see which one is faster, you might be
> > surprised :)
> >
> > In other words, do not just guess.
>
> No performance difference is observed wrt. this patchset when I
> run the following fio test on null_blk(modprobe null_blk) in my VM:
>
> fio --direct=1 --size=128G --bsrange=4k-4k --runtime=40 --numjobs=32 \
> --ioengine=libaio --iodepth=64 --group_reporting=1 --filename=/dev/nullb0 \
> --name=null_blk-ttest-randread --rw=randread
>
> Running test is important, but IMO it is more important to understand
> the idea behind is correct, or the approach can be proved as correct.
>
> Given the count of test cases can be increased exponentially when the related
> factors or settings are covered, obviously we can't run all the test cases.

And what happens when you start to scale the number of queues and cpus
in the system? Does both options work the same? Why did the original
code have per-cpu variables?

Anyway, this isn't my subsystem, and it has nothing to do with kobjects,
so I really do not care. My point is, do not make core changes like
this without really knowing the reason behind the original choice and at
least testing that your change does not break that reasoning.

good luck!

greg k-h