Skip to contentSkip to conversation

Question about forcing 'disable-memdev'

DISCUSSION Cao, Quanquan/曹 全全 4 participants 6 messages Feb 27, 2024 – Mar 7, 2024 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

Test environment:
KERNEL 6.8.0-rc1
QEMU 8.2.0-rc4

Test steps:
step1: set memory auto_online to movable zones.
echo online_movable >
/sys/devices/system/memory/auto_online_blocks
step2: create region
cxl create-region -t ram -d decoder0.0 -m mem0
step3: disable memdev
cxl disable-memdev mem0 -f
step4: consum CXL memory
./consumemem <------kernel panic

numactl node status:

      step1: numactl -H

	available: 2 nodes (0-1)
	node 0 cpus: 0 1
	node 0 size: 968 MB
	node 0 free: 664 MB
	node 1 cpus: 2 3
	node 1 size: 683 MB
	node 1 free: 333 MB
	node distances:
	node   0   1
	  0:  10  20

    step2: numactl -H

	available: 3 nodes (0-2)
	node 0 cpus: 0 1
	node 0 size: 968 MB
	node 0 free: 677 MB
	node 1 cpus: 2 3
	node 1 size: 683 MB
	node 1 free: 333 MB
	node 2 cpus:
	node 2 size: 256 MB
	node 2 free: 256 MB
	node distances:
	node   0   1   2
	  0:  10  20  20
	  1:  20  10  20
	  2:  20  20  10

    step3: numactl -H

	available: 3 nodes (0-2)
	node 0 cpus: 0 1
	node 0 size: 968 MB
	node 0 free: 686 MB
	node 1 cpus: 2 3
	node 1 size: 683 MB
	node 1 free: 336 MB
	node 2 cpus:
	node 2 size: 256 MB
	node 2 free: 256 MB
	node distances:
	node   0   1   2
	  0:  10  20  20
	  1:  20  10  20
	  2:  20  20  10
maintainer
#1 lore raw
Quoted 8 lines · Quanquan/曹 全全

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

If you are forcing memory disable when the memory cannot be offlined, then this behavior is expected. You are ripping the memory away from underneath kernel mm. The reason the check was added is to prevent the users from doing exactly that.

Quoted 65 lines

Test environment:
KERNEL    6.8.0-rc1
QEMU    8.2.0-rc4

Test steps:
      step1: set memory auto_online to movable zones.
           echo online_movable > /sys/devices/system/memory/auto_online_blocks
      step2: create region
           cxl create-region -t ram -d decoder0.0 -m mem0
      step3: disable memdev
           cxl disable-memdev mem0 -f
      step4: consum CXL memory
           ./consumemem   <------kernel panic

numactl node status:
      step1: numactl -H

    available: 2 nodes (0-1)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 664 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 333 MB
    node distances:
    node   0   1
      0:  10  20

    step2: numactl -H

    available: 3 nodes (0-2)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 677 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 333 MB
    node 2 cpus:
    node 2 size: 256 MB
    node 2 free: 256 MB
    node distances:
    node   0   1   2
      0:  10  20  20
      1:  20  10  20
      2:  20  20  10

    step3: numactl -H

    available: 3 nodes (0-2)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 686 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 336 MB
    node 2 cpus:
    node 2 size: 256 MB
    node 2 free: 256 MB
    node distances:
    node   0   1   2
      0:  10  20  20
      1:  20  10  20
      2:  20  20  10

#2 lore raw
Quoted 11 lines · Dave Jiang
Quoted 8 lines · Quanquan/曹 全全

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

If you are forcing memory disable when the memory cannot be offlined, then this behavior is expected. You are ripping the memory away from underneath kernel mm. The reason the check was added is to prevent the users from doing exactly that.

Since user is doing the illegal thing, shouldn't that lead to SIGBUS or SIGKILL ?

thanks,

-jane

Quoted 65 lines
Quoted 65 lines

Test environment:
KERNEL    6.8.0-rc1
QEMU    8.2.0-rc4

Test steps:
      step1: set memory auto_online to movable zones.
           echo online_movable > /sys/devices/system/memory/auto_online_blocks
      step2: create region
           cxl create-region -t ram -d decoder0.0 -m mem0
      step3: disable memdev
           cxl disable-memdev mem0 -f
      step4: consum CXL memory
           ./consumemem   <------kernel panic

numactl node status:
      step1: numactl -H

    available: 2 nodes (0-1)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 664 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 333 MB
    node distances:
    node   0   1
      0:  10  20

    step2: numactl -H

    available: 3 nodes (0-2)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 677 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 333 MB
    node 2 cpus:
    node 2 size: 256 MB
    node 2 free: 256 MB
    node distances:
    node   0   1   2
      0:  10  20  20
      1:  20  10  20
      2:  20  20  10

    step3: numactl -H

    available: 3 nodes (0-2)
    node 0 cpus: 0 1
    node 0 size: 968 MB
    node 0 free: 686 MB
    node 1 cpus: 2 3
    node 1 size: 683 MB
    node 1 free: 336 MB
    node 2 cpus:
    node 2 size: 256 MB
    node 2 free: 256 MB
    node distances:
    node   0   1   2
      0:  10  20  20
      1:  20  10  20
      2:  20  20  10

maintainer
#3 lore raw
Quoted 8 lines · Jane Chu
Quoted 6 lines · Dave Jiang
Quoted 4 lines · Quanquan/曹 全全

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

If you are forcing memory disable when the memory cannot be offlined, then this behavior is expected. You are ripping the memory away from underneath kernel mm. The reason the check was added is to prevent the users from doing exactly that.

Since user is doing the illegal thing, shouldn't that lead to SIGBUS or SIGKILL ?

The behavior is unpredictable once the CXL memory is ripped away. If the memory only backed user memory then you may see SIGBUS. But if the memory backed kernel data then kernel OOPs is not out of question.

Quoted 70 lines

thanks,

-jane

Quoted 65 lines
Quoted 65 lines

Test environment:
KERNEL    6.8.0-rc1
QEMU    8.2.0-rc4

Test steps:
       step1: set memory auto_online to movable zones.
            echo online_movable > /sys/devices/system/memory/auto_online_blocks
       step2: create region
            cxl create-region -t ram -d decoder0.0 -m mem0
       step3: disable memdev
            cxl disable-memdev mem0 -f
       step4: consum CXL memory
            ./consumemem   <------kernel panic

numactl node status:
       step1: numactl -H

     available: 2 nodes (0-1)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 664 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 333 MB
     node distances:
     node   0   1
       0:  10  20

     step2: numactl -H

     available: 3 nodes (0-2)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 677 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 333 MB
     node 2 cpus:
     node 2 size: 256 MB
     node 2 free: 256 MB
     node distances:
     node   0   1   2
       0:  10  20  20
       1:  20  10  20
       2:  20  20  10

     step3: numactl -H

     available: 3 nodes (0-2)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 686 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 336 MB
     node 2 cpus:
     node 2 size: 256 MB
     node 2 free: 256 MB
     node distances:
     node   0   1   2
       0:  10  20  20
       1:  20  10  20
       2:  20  20  10

#4 lore raw
Quoted 9 lines · Dave Jiang
Quoted 7 lines · Jane Chu
Quoted 5 lines · Dave Jiang
Quoted 4 lines · Quanquan/曹 全全

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines
Quoted 4 lines

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

If you are forcing memory disable when the memory cannot be offlined, then this behavior is expected. You are ripping the memory away from underneath kernel mm. The reason the check was added is to prevent the users from doing exactly that.

Since user is doing the illegal thing, shouldn't that lead to SIGBUS or SIGKILL ?

The behavior is unpredictable once the CXL memory is ripped away. If the memory only backed user memory then you may see SIGBUS. But if the memory backed kernel data then kernel OOPs is not out of question.

Make sense, thanks for the clarification.

-jane

Quoted 68 lines
Quoted 68 lines

thanks,

-jane

Quoted 63 lines
Quoted 63 lines

Test environment:
KERNEL    6.8.0-rc1
QEMU    8.2.0-rc4

Test steps:
       step1: set memory auto_online to movable zones.
            echo online_movable > /sys/devices/system/memory/auto_online_blocks
       step2: create region
            cxl create-region -t ram -d decoder0.0 -m mem0
       step3: disable memdev
            cxl disable-memdev mem0 -f
       step4: consum CXL memory
            ./consumemem   <------kernel panic

numactl node status:
       step1: numactl -H

     available: 2 nodes (0-1)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 664 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 333 MB
     node distances:
     node   0   1
       0:  10  20

     step2: numactl -H

     available: 3 nodes (0-2)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 677 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 333 MB
     node 2 cpus:
     node 2 size: 256 MB
     node 2 free: 256 MB
     node distances:
     node   0   1   2
       0:  10  20  20
       1:  20  10  20
       2:  20  20  10

     step3: numactl -H

     available: 3 nodes (0-2)
     node 0 cpus: 0 1
     node 0 size: 968 MB
     node 0 free: 686 MB
     node 1 cpus: 2 3
     node 1 size: 683 MB
     node 1 free: 336 MB
     node 2 cpus:
     node 2 size: 256 MB
     node 2 free: 256 MB
     node distances:
     node   0   1   2
       0:  10  20  20
       1:  20  10  20
       2:  20  20  10

#5 lore raw
Quoted 19 lines · Jane Chu
Quoted 17 lines · Dave Jiang
Quoted 15 lines · Jane Chu
Quoted 13 lines · Dave Jiang
Quoted 8 lines · Quanquan/曹 全全

Hi, Dave

On the basis of this patch, I conducted some tests and encountered unexpected errors. I would like to inquire whether the design here is reasonable? Below are the steps of my testing:

Problem description: after creating a region, directly forcing 'disable-memdev' and then consuming memory leads to a kernel panic.

If you are forcing memory disable when the memory cannot be offlined, then this behavior is expected. You are ripping the memory away from underneath kernel mm. The reason the check was added is to prevent the users from doing exactly that.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Since user is doing the illegal thing, shouldn't that lead to SIGBUS or SIGKILL ?

The behavior is unpredictable once the CXL memory is ripped away. If the memory only backed user memory then you may see SIGBUS. But if the memory backed kernel data then kernel OOPs is not out of question.

Make sense, thanks for the clarification.

I will just add consider the case of a technician physically removing a card without shutting down the kernel's usage of it. That event is indistinguishable from "cxl disable-memdev --force" at the driver level since the driver just gets the same ->remove() callback with no opportunity to return an error.

So this is a case of trusting the system administrator to know best, and is why --force is documented as:

-f, --force
DANGEROUS: Override the safety measure that blocks attempts to disable a device if the tool determines the memdev is in active usage. Recall that CXL memory ranges might have been established by platform firmware and disabling an active device is akin to force removing memory from a running system.