On Sun, 2019-04-28 at 15:39 +0800, Ming Lei wrote: > Now scsi_mq_setup_tags() pre-allocates a big buffer for protection > sg entries, and the buffer size is scsi_mq_sgl_size(). > > This way isn't correct, scsi_mq_sgl_size() is used to pre-allocate > sg entries for IO data. And the protection data buffer is much less, > for example, one 512byte sector needs 8byte protection data, and > the max sector number for one request is 2560(BLK_DEF_MAX_SECTORS), > so the max protection data size is just 20k. > > The usual case is that one bio builds one single bip segment. Attribute > to bio split, bio merge is seldom done for big IO, and it is only done > in case of small bios. And protection data segment number is usually > same with bio count in the request, so the number won't be very big, > and allocating from slab is fast enough. > > Reduce to pre-allocate one sg entry for protection data, and switch > to runtime allocation in case that the protection data segment number > is bigger than 1. Then we can save huge pre-alocation, for example, > 500
Reviewed-by: Bart Van Assche <bvanass...@acm.org>