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