When you use the Target Core Module in Userspace (TCMU) framework to implement userspace Internet Small Computer Systems Interface (iSCSI) targets, the default tcm_loop module parameters may not deliver optimal I/O performance for your workload. This document explains how to view and configure tcm_loop device parameters in Alibaba Cloud Linux 3 to tune I/O throughput in collaboration with the userspace backend.
Prerequisites
Before you begin, make sure that you have:
Alibaba Cloud Linux 3 as the operating system
Kernel version
5.10.134-17or later
View tcm_loop device parameters
Load the tcm_loop module.
sudo modprobe tcm_loopRead the current parameter values from sysfs.
cat /sys/module/tcm_loop/parameters/nr_hw_queues cat /sys/module/tcm_loop/parameters/can_queue cat /sys/module/tcm_loop/parameters/cmd_per_lun cat /sys/module/tcm_loop/parameters/sg_tablesize
Configure tcm_loop device parameters
There are two ways to configure tcm_loop device parameters:
Method 1: Pass parameters when loading the module
Method 2: Use a configuration file
Method 1: Pass parameters when loading the module
If the tcm_loop module is already loaded, remove it first.
sudo modprobe -r tcm_loopLoad the module with the parameter values you want.
Replace the placeholders with the values you want to set.
sudo modprobe tcm_loop nr_hw_queues=<nr_hw_queues> can_queue=<can_queue> cmd_per_lun=<cmd_per_lun> sg_tablesize=<sg_tablesize>Example — set
nr_hw_queuesto 4,can_queueto 2048,cmd_per_lunto 2048, andsg_tablesizeto 512:sudo modprobe tcm_loop nr_hw_queues=4 can_queue=2048 cmd_per_lun=2048 sg_tablesize=512
Verify
Confirm that the parameter values have taken effect.
cat /sys/module/tcm_loop/parameters/nr_hw_queues
cat /sys/module/tcm_loop/parameters/can_queue
cat /sys/module/tcm_loop/parameters/cmd_per_lun
cat /sys/module/tcm_loop/parameters/sg_tablesizeMethod 2: Use a configuration file
If the tcm_loop module is already loaded, remove it first.
sudo modprobe -r tcm_loopCreate a configuration file in
/etc/modprobe.d/.Replace the placeholders with the values you want to set. The file must have a
.confextension.sudo bash -c "cat > /etc/modprobe.d/<tcm_loop.conf> << EOF options tcm_loop nr_hw_queues=<nr_hw_queues> can_queue=<can_queue> cmd_per_lun=<cmd_per_lun> sg_tablesize=<sg_tablesize> EOF"Example — create
/etc/modprobe.d/tcm_loop.confwithnr_hw_queues=4,can_queue=2048,cmd_per_lun=2048, andsg_tablesize=512:sudo bash -c "cat > /etc/modprobe.d/tcm_loop.conf << EOF options tcm_loop nr_hw_queues=4 can_queue=2048 cmd_per_lun=2048 sg_tablesize=512 EOF"Load the tcm_loop module.
sudo modprobe tcm_loop
Verify
Confirm that the parameter values have taken effect.
cat /sys/module/tcm_loop/parameters/nr_hw_queues
cat /sys/module/tcm_loop/parameters/can_queue
cat /sys/module/tcm_loop/parameters/cmd_per_lun
cat /sys/module/tcm_loop/parameters/sg_tablesize