Re: [PATCH] scatterlist: Validate page before calling PageSlab()

From: Christoph Hellwig
Date: Tue Oct 15 2019 - 05:55:26 EST


On Mon, Oct 07, 2019 at 02:13:51PM -0700, Alan Mikhak wrote:
> > My goal is to not modify the Linux NVMe target code at all. The NVMe
> > endpoint function driver currently does the work that is required.

You will have to do some modifications, as for example in PCIe you can
have a n:1 relationship between SQs and CQs. And you need to handle
the Create/Delete SQ/CQ commands, but not the fabrics commands. And
modifying subsystems in Linux is perfectly acceptable, that is how they
improve.

Do you have a pointer to your code?

> > In my current platform, there are no page struct backing for the PCIe
> > memory address space.

In Linux there aren't struct pages for physical memory remapped using
ioremap(). But if you want to feed them to the I/O subsystem you have
to use devm_memremap_pages to create a page backing. Assuming you are
on a RISC-V platform given your affiliation you'll need to ensure your
kernel allows for ZONE_DEVICE pages, which Logan (added to Cc) has been
working on. I don't remember what the current status is.

> Please consider the following information and cost estimate in
> bytes for requiring page structs for PCI memory if used with
> scatterlists. For example, a 128GB PCI memory address space
> could require as much as 256MB of system memory just for
> page struct backing. In a 1GB 64-bit system with flat memory
> model, that consumes 25% of available memory. However,
> not all of the 128GB PCI memory may be mapped for use at
> a given time depending on the application. The cost of PCI
> page structs is an upfront cost to be paid at system start.

I know the pages are costly. But once you want to feed them through
subsystems that do expect pages you'll have to do that. And anything
using scatterlists currently does. A little hack here and there isn't
going to solve that.