Linux CXL
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Gregory Price <gregory.price@memverge.com>
Cc: Sajjan Rao <sajjanr@gmail.com>,
	Dimitrios Palyvos <dimitrios.palyvos@zptcorp.com>,
	<linux-cxl@vger.kernel.org>
Subject: Re: qemu cxl memory expander shows numa_node -1
Date: Fri, 26 Jan 2024 17:12:33 +0000	[thread overview]
Message-ID: <20240126171233.00002a2e@Huawei.com> (raw)
In-Reply-To: <ZbPTL00WOo7UC0e6@memverge.com>

On Fri, 26 Jan 2024 10:43:43 -0500
Gregory Price <gregory.price@memverge.com> wrote:

> On Fri, Jan 26, 2024 at 12:39:26PM +0000, Jonathan Cameron wrote:
> > On Thu, 25 Jan 2024 13:45:09 +0530
> > Sajjan Rao <sajjanr@gmail.com> wrote:
> >   
> > > Looks like something changed in QEMU 8.2 that broke running code out
> > > of CXL memory with KVM disabled.
> > > I used "numactl --membind 2 ls" as suggested by Dimitrios earlier,
> > > this worked for me until I updated to the latest QEMU.
> > > 
> > > Is this a known issue? Or am I missing something?  
> > 
> > I'm confused on how the description below ever worked.
> > Assigning the underlying memdev=cxl-mem1 to a numa node isn't going
> > to correctly build the connections the CFMWS PA range.
> >   
> 
> I've now seen 3-4 occasions where people have done this and run into
> trouble (for obvious reasons).  Is there anything we can do to disallow
> the double-registering of a single memdev to both a numa node and a cxl
> device?
> 
It would be novel for us to prevent people shooting themselves
in the foot ;) but I guess this should be fairly easy as the
numa node logic prevents the same one being used multiple times so can
copy how that is done.

This should do the trick (very lightly tested).
It's end of day Friday here so a formal patch can wait for next week.


diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c
index f29346fae7..d4194bb757 100644
--- a/hw/mem/cxl_type3.c
+++ b/hw/mem/cxl_type3.c
@@ -827,6 +827,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp)
             error_setg(errp, "volatile memdev must have backing device");
             return false;
         }
+        if (host_memory_backend_is_mapped(ct3d->hostvmem)) {
+            error_setg(errp, "memory backend %s can't be used multiple times.",
+               object_get_canonical_path_component(OBJECT(ct3d->hostvmem)));
+            return false;
+        }
         memory_region_set_nonvolatile(vmr, false);
         memory_region_set_enabled(vmr, true);
         host_memory_backend_set_mapped(ct3d->hostvmem, true);
@@ -850,6 +855,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp)
             error_setg(errp, "persistent memdev must have backing device");
             return false;
         }
+        if (host_memory_backend_is_mapped(ct3d->hostpmem)) {
+            error_setg(errp, "memory backend %s can't be used multiple times.",
+               object_get_canonical_path_component(OBJECT(ct3d->hostpmem)));
+            return false;
+        }
         memory_region_set_nonvolatile(pmr, true);
         memory_region_set_enabled(pmr, true);
         host_memory_backend_set_mapped(ct3d->hostpmem, true);
@@ -880,6 +890,11 @@ static bool cxl_setup_memory(CXLType3Dev *ct3d, Error **errp)
             error_setg(errp, "dynamic capacity must have backing device");
             return false;
         }
+        if (host_memory_backend_is_mapped(ct3d->dc.host_dc)) {
+            error_setg(errp, "memory backend %s can't be used multiple times.",
+               object_get_canonical_path_component(OBJECT(ct3d->dc.host_dc)));
+            return false;
+        }
         /* FIXME: set dc as nonvolatile for now */
         memory_region_set_nonvolatile(dc_mr, true);
         memory_region_set_enabled(dc_mr, true);





> ~Gregory


  reply	other threads:[~2024-01-26 17:12 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18  9:38 qemu cxl memory expander shows numa_node -1 Sajjan Rao
2023-08-18 15:01 ` Dimitrios Palyvos
2023-08-21 10:00   ` Sajjan Rao
2023-08-21 10:53     ` Dimitrios Palyvos
2023-08-23 11:13       ` Sajjan Rao
2023-08-23 16:50         ` Jonathan Cameron
2023-08-24  6:26           ` Sajjan Rao
2024-01-25  8:15             ` Sajjan Rao
2024-01-26 12:39               ` Jonathan Cameron
2024-01-26 15:43                 ` Gregory Price
2024-01-26 17:12                   ` Jonathan Cameron [this message]
2024-01-30  8:20                     ` Sajjan Rao
2024-02-01 13:04                       ` Crash with CXL + TCG on 8.2: Was " Jonathan Cameron
2024-02-01 13:12                         ` Peter Maydell
2024-02-01 14:01                           ` Jonathan Cameron
2024-02-01 14:35                             ` Peter Maydell
2024-02-01 15:17                               ` Alex Bennée
2024-02-01 15:29                                 ` Jonathan Cameron
2024-02-01 16:00                                 ` Peter Maydell
2024-02-01 16:21                                   ` Jonathan Cameron
2024-02-01 16:45                                     ` Alex Bennée
2024-02-01 17:04                                       ` Gregory Price
2024-02-01 17:07                                         ` Peter Maydell
2024-02-01 17:29                                           ` Gregory Price
2024-02-01 17:08                                       ` Jonathan Cameron
2024-02-01 17:21                                         ` Peter Maydell
2024-02-01 17:41                                           ` Jonathan Cameron
2024-02-01 17:25                                         ` Alex Bennée
2024-02-01 18:04                                           ` Peter Maydell
2024-02-01 18:56                                             ` Gregory Price
2024-02-02 16:26                                               ` Jonathan Cameron
2024-02-02 16:33                                                 ` Peter Maydell
2024-02-02 16:50                                                   ` Gregory Price
2024-02-02 16:56                                                     ` Peter Maydell
2024-02-07 17:34                                                       ` Jonathan Cameron
2024-02-08 14:50                                                         ` Jonathan Cameron
2024-02-15 15:29                                                           ` Jonathan Cameron
2024-02-15 15:04                                   ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240126171233.00002a2e@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=dimitrios.palyvos@zptcorp.com \
    --cc=gregory.price@memverge.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=sajjanr@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox