On 6/27/2024 9:17 PM, Christoph Hellwig wrote: > On Thu, Jun 27, 2024 at 09:06:56PM +0530, Kanchan Joshi wrote: >> The bi->csum_type is constant as far as this bio_for_each_segment loop >> is concerned. >> Seems wasteful processing, and can rather be moved out where we set a >> function pointer to point to either ext_pi_crc64_generate or >> t10_pi_generate once. > A function pointer is way more expensive than a few branches, especially > easily predictable ones. > In general yes. Maybe I can profile this particular case someday and get myself convinced. But regardless, I am unsure what the patch buys. During write: - bio_integrity_process(bio, &bio->bi_iter); + blk_integrity_generate(bio); During read: - bio->bi_status = bio_integrity_process(bio, &bip->bio_iter); + blk_integrity_verify(bio); One less argument is passed, but common code of bio_integrity_process got mostly duplicated into blk_integrity_generate/verify now.