OSDN Git Service

nvme-fc: improve memory usage in nvme_fc_rcv_ls_req()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 2 Oct 2022 09:59:45 +0000 (11:59 +0200)
committerChristoph Hellwig <hch@lst.de>
Tue, 15 Nov 2022 09:50:30 +0000 (10:50 +0100)
commitcf3d00840170ebf372bcacc5d5c27f5ed9c1b976
tree1e2f52d5331dd13bfad5f3435d320acfad5580aa
parentfa8f9ac42350edd3ce82d0d148a60f0fa088f995
nvme-fc: improve memory usage in nvme_fc_rcv_ls_req()

sizeof( struct nvmefc_ls_rcv_op ) = 64
sizeof( union nvmefc_ls_requests ) = 1024
sizeof( union nvmefc_ls_responses ) = 128

So, in nvme_fc_rcv_ls_req(), 1216 bytes of memory are requested when
kzalloc() is called.

Because of the way memory allocations are performed, 2048 bytes are
allocated. So about 800 bytes are wasted for each request.

Switch to 3 distinct memory allocations, in order to:
   - save these 800 bytes
   - avoid zeroing this extra memory
   - make sure that memory is properly aligned in case of DMA access
    ("fc_dma_map_single(lsop->rspbuf)" just a few lines below)

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fc.c