[PATCH 2/2] nvme-pci: use dma_alloc_noncontigous if possible
Keith Busch
kbusch at kernel.org
Mon Dec 2 11:15:49 PST 2024
On Mon, Dec 02, 2024 at 09:05:41PM +0200, Leon Romanovsky wrote:
> I see at least two possible solutions, add GFP_NOWARN in nvme_alloc_host_mem_single()
> or the following patch:
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index 4c644bb7f069..baed4059d8a5 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -2172,7 +2172,8 @@ static int nvme_alloc_host_mem_multi(struct nvme_dev *dev, u64 preferred,
>
> static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
> {
> - u64 min_chunk = min_t(u64, preferred, PAGE_SIZE * MAX_ORDER_NR_PAGES);
> + u64 max_chunk = PAGE_SIZE * MAX_ORDER_NR_PAGES;
> + u64 min_chunk = min_t(u64, preferred, max_chunk);
> u64 hmminds = max_t(u32, dev->ctrl.hmminds * 4096, PAGE_SIZE * 2);
> u64 chunk_size;
>
> @@ -2180,7 +2181,7 @@ static int nvme_alloc_host_mem(struct nvme_dev *dev, u64 min, u64 preferred)
> * If there is an IOMMU that can merge pages, try a virtually
> * non-contiguous allocation for a single segment first.
> */
> - if (!(PAGE_SIZE & dma_get_merge_boundary(dev->dev))) {
> + if (!(PAGE_SIZE & dma_get_merge_boundary(dev->dev)) && preferred < max_chunk) {
> if (!nvme_alloc_host_mem_single(dev, preferred))
> return 0;
> }
> (END)
>
> What is the preferred way to overcome the warning?
I think your max_chunk check suggestion looks pretty good.
More information about the Linux-nvme
mailing list