nvme bug?? -- clearing extra memory
Keith Busch
kbusch at kernel.org
Wed Mar 31 22:23:35 BST 2021
On Wed, Mar 31, 2021 at 12:39:42PM -0700, Kallol Biswas wrote:
> Hi,
> I have come across the following lines in the 5.8.0 nvme driver code.
>
> drivers/nvme/host/pci.c
>
> iod->sg = mempool_alloc(dev->iod_mempool, GFP_ATOMIC);
> if (!iod->sg)
> return BLK_STS_RESOURCE;
> sg_init_table(iod->sg, blk_nr_phys_segments(req));
>
> ----------------------------------
> void sg_init_table(struct scatterlist *sgl, unsigned int nents)
> {
> memset(sgl, 0, sizeof(*sgl) * nents);
> .........................................
>
> Question: mempool_alloc will allocate a single sg entry, and then if
> blk_nr_phys_segmets() is > 1, then we will clear more memory area than
> intended.
>
> Is my understanding correct?
The size from this mempool is set by nvme_pci_iod_alloc_size(), which is
larger than one sg entry.
More information about the Linux-nvme
mailing list