Adding memory

7.1 LPAR mode z/VM guest

You can add memory to your Linux® instance by setting unused memory blocks online. You can chose a memory zone for certain memory blocks.

About this task

Hotplug memory blocks are not pre-added at boot time. They must be configured before they can be set online.

The memmap-on-memory setting can be specified during configuration and defaults to the global setting if not specified. Linux core memory is initially configured without memmap-on-memory.

Procedure

  • Use the chmem command with the -e parameter to set memory online and the -b parameter to specify the target memory block.
    Issue a command of the form:
    # chmem -e -b <blockno>
    You can specify the amount of memory you want to add with the command without specifying particular memory blocks. If there are enough eligible memory blocks to satisfy your request, the tool finds them for you and sets the most suitable blocks online.

    A deconfigured memory block is implicitly configured (if supported by the architecture) before being set online. A configured block is set online directly.

    For example, to configure memory block 16 and set it online:
    # chmem -e -b 16 -v
    Memory Block 16 (0x0000000080000000-0x0000000087ffffff) configured
    Memory Block 16 (0x0000000080000000-0x0000000087ffffff) enabled
    
    # lsmem -o RANGE,SIZE,STATE,BLOCK,CONFIGURED,MEMMAP-ON-MEMORY
    RANGE                  SIZE   STATE BLOCK CONFIGURED MEMMAP-ON-MEMORY
    0x00000000-0x7fffffff    2G  online  0-15        yes               no
    0x80000000-0x87ffffff  128M  online    16        yes              yes
    0x88000000-0xbfffffff  896M offline 17-23         no              yes
    
    Memory block size:                128M
    Total online memory:              2.1G
    Total offline memory:             896M
    Memmap on memory parameter:        yes
    You can explicitly configure memory blocks before setting them online by issuing a command of the form:
    # chmem -c -b <blockno> -m {0|1}
    # chmem -e -b <blockno>
    where:
    • -c configures the memory block
    • -m specifies the memmap-on-memory setting.

      Configure the new memory block with memmap-on-memory enabled when the system is under memory pressure. This places the struct page metadata within the same memory block, making it self-contained and reducing the pressure on existing system memory.

      Configure the new memory block with memmap-on-memory disabled when contiguous physical memory is required.

    This two-step operation is useful when explicit control over memmap-on-memory is required.
    Alternatively, if supported by the architecture, you can configure memory blocks using the sysfs interface:
    # echo 1 > /sys/firmware/memory/memory<n>/config
    The memory block must be in a deconfigured state before configuration.
  • After a memory block is configured, you can set it online using the state sysfs attribute.
    Issue a command of the form:
    # echo online_value > /sys/devices/system/memory/memory<n>/state
    where online_value is one of:
    online
    sets the memory block online to the default zone. The default zone is the first zone listed in the valid_zones sysfs attribute.
    online_movable
    sets the memory block online to the Movable zone. Setting the block online fails if the Movable zone is not listed in the valid_zones sysfs attribute.
    online_kernel
    sets the memory block online to the first non-Movable zone listed in the valid_zones directory. Setting the block online fails if the Movable zone is the only zone listed in the valid_zones sysfs attribute.
    <n> is an integer that identifies the memory unit.

Results

Adding the memory block fails if the memory block is already in use. The state attribute changes to online when the memory block has been set online successfully.