On 2025-12-26 at 18:15 +1100, "Huang, FangSheng (Jerry)" <[email protected]> wrote... > [You don't often get email from [email protected]. Learn why this is > important at https://aka.ms/LearnAboutSenderIdentification ] > > Hi Jonathan, David, > > Thanks for the review and for pointing out the LPC discussion! > > On 12/23/2025 6:01 PM, David Hildenbrand (Red Hat) wrote: > > On 12/23/25 10:56, Jonathan Cameron via wrote: > > > On Tue, 9 Dec 2025 17:38:41 +0800 > > > fanhuang <[email protected]> wrote: > > > > > > > This patch adds support for Specific Purpose Memory (SPM) through the > > > > NUMA node configuration. When 'spm=on' is specified for a NUMA node, > > > > the memory region will be reported to the guest as soft reserved, > > > > allowing device drivers to manage it separately from normal system RAM. > > > > > > > > Note: This option is only supported on x86 platforms. Using spm=on > > > > on non-x86 machines will result in an error. > > > > > > > > Usage: > > > > -numa node,nodeid=0,memdev=m1,spm=on > > > > > > > > Signed-off-by: fanhuang <[email protected]> > > > > > > Given the discussions at LPC around how to present GPU/HBM memory and > > > suggestions that reserved might be a better choice. I wonder if this > > > patch should provide that option as well? Or maybe as a potential follow > > > up. The fun their is that you also need to arrange for DSDT entries to > > > tie the region to the driver that actually wants it. > > > > > > Anyhow that session reminded me of what SPM was designed for > > > (you don't want to know how long it took to come up with the name) > > > and it is a little more subtle than the description in here suggests. > > > > > > The x86 specific code looks fine to me but I'm more or less totally > > > unfamiliar with that, so need review from others. > > > > > > +CC a few folk from that discussion. I wasn't there in person and > > > it sounded like the discussion moved to the hallway so it may > > > have come to a totally different conclusion!
Indeed it did! We had an interesting discussion. I'm out of office for the next week or so though so don't have much to add for now but adding Gregory to this discussion as well. - Alistair > > > https://lpc.events/event/19/contributions/2064/ has links to slides > > > and youtube video. > > > > > I watched the slides. Actually we've been experimenting with > a combined approach: SBIOS > reports HBM as SPM, then driver dynamically partitions and hot-plugs it as > driver-managed memory to NUMA nodes. So SPM and driver-managed are > complementary rather than mutually exclusive. This patch focuses on the > first part - enabling QEMU to report memory as SPM to the guest. > > For the `reserved` option - agree it could be a potential follow-up, though > it needs more investigation. For now, let's focus on SPM and soft reserved. > > > > > diff --git a/qapi/machine.json b/qapi/machine.json > > > > index 907cb25f75..cbb19da35c 100644 > > > > --- a/qapi/machine.json > > > > +++ b/qapi/machine.json > > > > @@ -500,6 +500,12 @@ > > > > # @memdev: memory backend object. If specified for one node, it must > > > > # be specified for all nodes. > > > > # > > > > +# @spm: if true, mark the memory region of this node as Specific > > > > +# Purpose Memory (SPM). The memory will be reported to the > > > > +# guest as soft reserved, allowing device drivers to manage it > > > > +# separately from normal system RAM. Currently only supported > > > > +# on x86. (default: false, since 10.0) > > > > > > As below. This needs to say something about letting the guest know > > > that it might want to let a driver manage it separately from normal > > > system RAM. > > > > > > > +# > > > > # @initiator: defined in ACPI 6.3 Chapter 5.2.27.3 Table 5-145, points > > > > # to the nodeid which has the memory controller responsible for > > > > # this NUMA node. This field provides additional information as > > > > @@ -514,6 +520,7 @@ > > > > '*cpus': ['uint16'], > > > > '*mem': 'size', > > > > '*memdev': 'str', > > > > + '*spm': 'bool', > > > > '*initiator': 'uint16' }} > > > > ## > > > > diff --git a/qemu-options.hx b/qemu-options.hx > > > > index fca2b7bc74..ffcd1f47cf 100644 > > > > --- a/qemu-options.hx > > > > +++ b/qemu-options.hx > > > > @@ -431,7 +431,7 @@ ERST > > > > DEF("numa", HAS_ARG, QEMU_OPTION_numa, > > > > "-numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=node]\n" > > > > - "-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=node]\n" > > > > + "-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=node][,spm=on|off]\n" > > > > "-numa dist,src=source,dst=destination,val=distance\n" > > > > "-numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z]\n" > > > > "-numa hmat-lb,initiator=node,target=node,hierarchy=memory| > > > > first-level|second-level|third-level,data-type=access-latency|read- > > > > latency|write-latency[,latency=lat][,bandwidth=bw]\n" > > > > @@ -440,7 +440,7 @@ DEF("numa", HAS_ARG, QEMU_OPTION_numa, > > > > SRST > > > > ``-numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=initiator]`` > > > > \ > > > > -``-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=initiator]`` > > > > +``-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node] > > > > [,initiator=initiator][,spm=on|off]`` > > > > \ > > > > ``-numa dist,src=source,dst=destination,val=distance`` > > > > \ > > > > @@ -508,6 +508,13 @@ SRST > > > > largest bandwidth) to this NUMA node. Note that this option can be > > > > set only when the machine property 'hmat' is set to 'on'. > > > > + '\ ``spm``\ ' option marks the memory region of this NUMA node as > > > > + Specific Purpose Memory (SPM). When enabled, the memory will be > > > > + reported to the guest as soft reserved, allowing device drivers to > > > > + manage it separately from normal system RAM. This is useful for > > > > + device-specific memory that should not be used as general purpose > > > > + memory. This option is only supported on x86 platforms. > > > > > > This wants tweaking. As came up at the LPC discussion, SPM is for > > > memory that 'might' be used as general purpose memory if the policy of > > > the > > > guest is to do so - as Alistair pointed out at LPC, people don't actually > > > do that very often, but none the less that's why this type exists. It is > > > a strong hint to the guest that it needs to apply a policy choice to > > > what happens to this memory. > > Got it. To clarify - this patch only handles the "reporting" part, just > like how SBIOS reports HBM as SPM on real hardware. The guest kernel > then decides how to use this memory based on its own policy (kernel config, > boot parameters, etc.). Will update the docs to describe SPM as a > policy hint rather than a definitive restriction. > > > > > Just curious, it's the same on real hardware, right? > > > > Hi David, could you clarify what you're asking about? Whether the SPM > semantics are the same, or whether this QEMU implementation matches real > hardware behavior? > > Best Regards, > Jerry Huang
