linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* nvme bug?? -- clearing extra memory
@ 2021-03-31 19:39 Kallol Biswas
  2021-03-31 21:23 ` Keith Busch
  0 siblings, 1 reply; 2+ messages in thread
From: Kallol Biswas @ 2021-03-31 19:39 UTC (permalink / raw)
  To: Linux-nvme

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?

-- 
------
Kallol Biswas
Phone: 408-718-8164 (c)
Phone: 408-725-7527 (o)
NucleoDyne Systems, Inc.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: nvme bug?? -- clearing extra memory
  2021-03-31 19:39 nvme bug?? -- clearing extra memory Kallol Biswas
@ 2021-03-31 21:23 ` Keith Busch
  0 siblings, 0 replies; 2+ messages in thread
From: Keith Busch @ 2021-03-31 21:23 UTC (permalink / raw)
  To: Kallol Biswas; +Cc: Linux-nvme

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.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-31 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 19:39 nvme bug?? -- clearing extra memory Kallol Biswas
2021-03-31 21:23 ` Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).