Skip to contentSkip to conversation

How to find the correct corresponding relationship between mem devices and target postions?

DISCUSSION Xiao Yang 2 participants 3 messages Jul 20, 2023 – Jul 23, 2023

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

Hi Dan,

I tried to simulate four cxl memory devices by the following qemu options:
--------------------------------------------------------------------
-object memory-backend-ram,size=1048576k,id=m0 \
-object memory-backend-ram,size=1048576k,id=m1 \
-numa node,nodeid=0,cpus=0-1,memdev=m0 \
-numa node,nodeid=1,cpus=2-3,memdev=m1 \
...
-object memory-backend-ram,size=262144k,share=on,id=vmem0 \
-object memory-backend-ram,size=262144k,share=on,id=vmem1 \
-object memory-backend-ram,size=262144k,share=on,id=vmem2 \
-object memory-backend-ram,size=262144k,share=on,id=vmem3 \
-device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1 \
-device pxb-cxl,bus_nr=22,bus=pcie.0,id=cxl.2 \
-device cxl-rp,port=0,bus=cxl.1,id=root_port13,chassis=0,slot=2 \
-device cxl-type3,bus=root_port13,volatile-memdev=vmem0,id=cxl-vmem0 \
-device cxl-rp,port=1,bus=cxl.1,id=root_port14,chassis=0,slot=3 \
-device cxl-type3,bus=root_port14,volatile-memdev=vmem1,id=cxl-vmem1 \
-device cxl-rp,port=0,bus=cxl.2,id=root_port15,chassis=0,slot=5 \
-device cxl-type3,bus=root_port15,volatile-memdev=vmem2,id=cxl-vmem2 \
-device cxl-rp,port=1,bus=cxl.2,id=root_port16,chassis=0,slot=6 \
-device cxl-type3,bus=root_port16,volatile-memdev=vmem3,id=cxl-vmem3 \
-M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.targets.1=cxl.2,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=8k
--------------------------------------------------------------------

I failed to create the new region with four cxl memory devices:
--------------------------------------------------------------------

# cxl create-region -t ram -d decoder0.0 -m mem0 mem1 mem2 mem3
cxl region: create_region: region0: failed to set target1 to mem1
cxl region: cmd_create_region: created 0 regions
--------------------------------------------------------------------

The root cause is that all cxl memory devices find the wrong corresponding target postions(e.g. mem0 <-> target0 is wrong)

Is there any way to find the correct corresponding relationship in userspace?

Best Regards,
Xiao Yang

#1 lore raw
Quoted 33 lines · Xiao Yang

Hi Dan,

I tried to simulate four cxl memory devices by the following qemu options:
--------------------------------------------------------------------

(quoted diff) +0 -20
-object memory-backend-ram,size=1048576k,id=m0 \
-object memory-backend-ram,size=1048576k,id=m1 \
-numa node,nodeid=0,cpus=0-1,memdev=m0 \
-numa node,nodeid=1,cpus=2-3,memdev=m1 \
...
-object memory-backend-ram,size=262144k,share=on,id=vmem0 \
-object memory-backend-ram,size=262144k,share=on,id=vmem1 \
-object memory-backend-ram,size=262144k,share=on,id=vmem2 \
-object memory-backend-ram,size=262144k,share=on,id=vmem3 \
-device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1 \
-device pxb-cxl,bus_nr=22,bus=pcie.0,id=cxl.2 \
-device cxl-rp,port=0,bus=cxl.1,id=root_port13,chassis=0,slot=2 \
-device cxl-type3,bus=root_port13,volatile-memdev=vmem0,id=cxl-vmem0 \
-device cxl-rp,port=1,bus=cxl.1,id=root_port14,chassis=0,slot=3 \
-device cxl-type3,bus=root_port14,volatile-memdev=vmem1,id=cxl-vmem1 \
-device cxl-rp,port=0,bus=cxl.2,id=root_port15,chassis=0,slot=5 \
-device cxl-type3,bus=root_port15,volatile-memdev=vmem2,id=cxl-vmem2 \
-device cxl-rp,port=1,bus=cxl.2,id=root_port16,chassis=0,slot=6 \
-device cxl-type3,bus=root_port16,volatile-memdev=vmem3,id=cxl-vmem3 \
-M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.targets.1=cxl.2,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=8k
--------------------------------------------------------------------

I failed to create the new region with four cxl memory devices:
--------------------------------------------------------------------

# cxl create-region -t ram -d decoder0.0 -m mem0 mem1 mem2 mem3
cxl region: create_region: region0: failed to set target1 to mem1
cxl region: cmd_create_region: created 0 regions
--------------------------------------------------------------------
Quoted 5 lines

The root cause is that all cxl memory devices find the wrong corresponding target postions(e.g. mem0 <-> target0 is wrong)

Is there any way to find the correct corresponding relationship in userspace?

Hi Xiao,

You can use cxl-cli tool to find the order before doing the 'cxl create-region'. (Some folks may just know the order by looking at your qemu setup.)

Knowing you want to use decoder0.0
$cxl list -DT -d decoder0.0

That will get you the list of targets. nr_targets should be '4' and the targets will have a position #.

$cxl list -M -p <fill-in-a-target-name> | jq -r ".[0].memdev"

That gives you the memdev for that target.
Repeat for all 4 targets, by position, and use that order.

You can use the cxl unit tests for examples of how to find the memdevs for a region: https://github.com/pmem/ndctl/tree/main/test
Search for where we do 'create-region'

Hope that helps,
Alison

Quoted 3 lines

ch
Best Regards,
Xiao Yang

author
#2 lore raw
Quoted 46 lines · Alison Schofield
Quoted 33 lines · Xiao Yang

Hi Dan,

I tried to simulate four cxl memory devices by the following qemu options:
--------------------------------------------------------------------

(quoted diff) +0 -20
-object memory-backend-ram,size=1048576k,id=m0 \
-object memory-backend-ram,size=1048576k,id=m1 \
-numa node,nodeid=0,cpus=0-1,memdev=m0 \
-numa node,nodeid=1,cpus=2-3,memdev=m1 \
...
-object memory-backend-ram,size=262144k,share=on,id=vmem0 \
-object memory-backend-ram,size=262144k,share=on,id=vmem1 \
-object memory-backend-ram,size=262144k,share=on,id=vmem2 \
-object memory-backend-ram,size=262144k,share=on,id=vmem3 \
-device pxb-cxl,bus_nr=12,bus=pcie.0,id=cxl.1 \
-device pxb-cxl,bus_nr=22,bus=pcie.0,id=cxl.2 \
-device cxl-rp,port=0,bus=cxl.1,id=root_port13,chassis=0,slot=2 \
-device cxl-type3,bus=root_port13,volatile-memdev=vmem0,id=cxl-vmem0 \
-device cxl-rp,port=1,bus=cxl.1,id=root_port14,chassis=0,slot=3 \
-device cxl-type3,bus=root_port14,volatile-memdev=vmem1,id=cxl-vmem1 \
-device cxl-rp,port=0,bus=cxl.2,id=root_port15,chassis=0,slot=5 \
-device cxl-type3,bus=root_port15,volatile-memdev=vmem2,id=cxl-vmem2 \
-device cxl-rp,port=1,bus=cxl.2,id=root_port16,chassis=0,slot=6 \
-device cxl-type3,bus=root_port16,volatile-memdev=vmem3,id=cxl-vmem3 \
-M cxl-fmw.0.targets.0=cxl.1,cxl-fmw.0.targets.1=cxl.2,cxl-fmw.0.size=4G,cxl-fmw.0.interleave-granularity=8k
--------------------------------------------------------------------

I failed to create the new region with four cxl memory devices:
--------------------------------------------------------------------

# cxl create-region -t ram -d decoder0.0 -m mem0 mem1 mem2 mem3
cxl region: create_region: region0: failed to set target1 to mem1
cxl region: cmd_create_region: created 0 regions
--------------------------------------------------------------------
Quoted 5 lines

The root cause is that all cxl memory devices find the wrong corresponding target postions(e.g. mem0 <-> target0 is wrong)

Is there any way to find the correct corresponding relationship in userspace?

Hi Xiao,

You can use cxl-cli tool to find the order before doing the 'cxl create-region'. (Some folks may just know the order by looking at your qemu setup.)

Quoted 5 lines

Knowing you want to use decoder0.0
$cxl list -DT -d decoder0.0

That will get you the list of targets. nr_targets should be '4' and the targets will have a position #.

Hi Alison,

Thanks a lot for your detailed reply.

nr_targets is 2 on my enviroment:

$ cxl list -DT -d decoder0.0
[
  {
    "decoder":"decoder0.0",
    "resource":31406948352,
    "size":4294967296,
    "interleave_ways":2,
    "interleave_granularity":8192,
    "max_available_extent":4294967296,
    "pmem_capable":true,
    "volatile_capable":true,
    "accelmem_capable":true,
    "nr_targets":2,
    "targets":[
      {
        "target":"pci0000:16",
        "alias":"ACPI0016:00",
        "position":1,
        "id":22
      },
      {
        "target":"pci0000:0c",
        "alias":"ACPI0016:01",
        "position":0,
        "id":12
      }
    ]
  }
]
Quoted 5 lines

$cxl list -M -p <fill-in-a-target-name> | jq -r ".[0].memdev"

That gives you the memdev for that target.
Repeat for all 4 targets, by position, and use that order.

Each target links two CXL memory devices:

$ cxl list -M -p pci0000:0c
[
  {
    "memdev":"mem3",
    "ram_size":268435456,
    "serial":0,
    "host":"0000:0e:00.0"
  },
  {
    "memdev":"mem0",
    "ram_size":268435456,
    "serial":0,
    "host":"0000:0d:00.0"
  }
]
$ cxl list -M -p pci0000:16
[
  {
    "memdev":"mem2",
    "ram_size":268435456,
    "serial":0,
    "host":"0000:17:00.0"
  },
  {
    "memdev":"mem1",
    "ram_size":268435456,
    "serial":0,
    "host":"0000:18:00.0"
  }
]

Do you mean that I have to create a new region with four memdevs in the fixed order? For example:

$ cxl create-region -t ram -d decoder0.0 -m mem3 mem2 mem0 mem1

In other words, I cannot create a new region with four memdevs in the following normal/random order. Is it right?

$ cxl create-region -t ram -d decoder0.0 -m mem0 mem1 mem2 mem3
Quoted 4 lines

You can use the cxl unit tests for examples of how to find the memdevs for a region: https://github.com/pmem/ndctl/tree/main/test
Search for where we do 'create-region'

Thanks for your suggestion. I will look into these examples.

Best Regards,
Xiao Yang

Quoted 7 lines

Hope that helps,
Alison

Quoted 3 lines

ch
Best Regards,
Xiao Yang