[SRU] Fix the session workqueue thread priority setting issue for newer Linux kernels (>=6.x)
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
open-iscsi (Ubuntu) | Status tracked in Oracular | |||||
Noble |
In Progress
|
Medium
|
Mustafa Kemal Gilor | |||
Oracular |
Fix Released
|
Medium
|
Mustafa Kemal Gilor |
Bug Description
[ Impact ]
The Linux SCSI driver uses `alloc_workqueue()` to create a kernel workqueue for session transmit work. This call would cause the kernel < 6.x to create a dedicated worker thread for the workqueue. The userspace library open-iscsi version < 2.1.10 then adjusts the workqueue thread's nice value for performance reasons when a new iSCSI session is initiated. The algorithm for that is roughly as follows (https:/
- Check if the driver in use has a write work queue. If not, abort.
- Open the /proc dir, and iterate over all dir entries:
- Run "stat" over /proc/<n>/stat
- Read the contents of "stat" file, which looks like the following:
898582 (kworker/
- Try to locate "(" with strchr, starting from the beginning. Skip the process if not found.
- Try to locate ")" with strchr, starting from the position of "(". Skip the process if not found.
- Check whether the string between "(" and ")" contains the following pattern "iscsi_q_%d"
- Check the number %d matches with the host ID of the session.
- If %d matches the session id, grab the PID of the current proc entry and call `setpriority()`
So the algorithm assumes the following about the kernel workqueue thread:
- It would be present in the /proc list
- Its name would match the iscsi_q_%d pattern
Due to the changes in how Linux workqueue threads work in v6.x, the priority setting approach won't work for the following reasons:
- The `alloc_workqueue()` no longer creates a dedicated thread for the workqueue. The workqueue thread is shared between different workqueues.
- The workqueue thread is dynamically renamed to the name of the workqueue that's actively running
- The workqueue thread disappears from the /proc list when it's inactive
The algorithm as-is does the following right now:
- If the kernel workqueue thread *by luck* happens to be running the iscsi task, the name matches, and the priority is set. But that's not what the code wants to do since it also increases the priority for all the other tasks that are scheduled to the workqueue thread as well.
- If not, the open-iscsi prints the following log message, and proceeds to operate as normal:
```
iscsistart: Could not set session1 priority. READ/WRITE throughout and latency could be affected.
```
The upstream has fixed this issue with the patch (https:/
This SRU proposes to backport this patch to the Ubuntu releases that use Linux kernel 6.8 and above by default, and have an open-iscsi version of less than (2.1.10).
[ Test Plan ]
# Launch a test VM:
$> lxc launch ubuntu:noble --vm iscsi-test-noble
# Obtain a shell from the VM:
$> lxc shell iscsi-test-noble
# Install 'tgt' and 'open-iscsi':
$> sudo apt -y update && sudo apt -y install tgt open-iscsi
# Configure 'tgt':
## Step 1: Configure a LUN
Add the following to '/etc/tgt/
<target iqn.2020-
backing-store /dev/sda
initiator-
incominguser iscsi-user password
outgoinguser iscsi-target secretpass
</target>
(change /dev/sda to an existing device's name if it's not present)
## Step 2: Restart 'tgt' to make changes effective:
$> systemctl restart tgt
## Step 3: Check if 'tgt' has started serving the LUN:
$> tgtadm --mode target --op show
(output should be similar to below)
Target 1: iqn.2020-
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Prevent removal: No
SWP: No
Backing store type: null
Backing store path: None
Backing store flags:
Account information:
iscsi-user
ACL information:
127.0.0.1
# Configure 'open-iscsi':
## Step 1: Check whether the LUN being served by 'tgt' is discoverable:
$> iscsiadm -m discovery -t st -p 127.0.0.1
(should output the text below)
127.0.0.1:3260,1 iqn.2020-
## Step 2: Configure open-iscsi to consume the target LUN:
Add the following line to '/etc/iscsi/
```
InitiatorName=
```
## Step 3: Modify the following file '/etc/iscsi/
# (the file must already exist, it should've been automatically created after the discovery)
Append the following lines to the end of the file, and save:
```
node.session.
node.session.
node.session.
node.session.
node.session.
node.startup = automatic
```
## Step 4: Restart open-iscsi to make changes effective:
$> systemctl restart open-iscsi.service iscsid
## Step 5: Check the outcome
(the service status should indicate that login to 'iqn.2020-
$> systemctl status open-iscsi.service
● open-iscsi.service - Login to default iSCSI targets
Loaded: loaded (/usr/lib/
Active: active (exited) since Mon 2024-07-22 13:36:15 UTC; 4s ago
Docs: man:iscsiadm(8)
Process: 3049 ExecStart=
Process: 3065 ExecStart=
Main PID: 3065 (code=exited, status=0/SUCCESS)
CPU: 4ms
Jul 22 13:36:15 welcomed-bluebird systemd[1]: Starting open-iscsi.service - Login to default iSCSI targets...
Jul 22 13:36:15 welcomed-bluebird iscsiadm[3049]: Logging in to [iface: default, target: iqn.2020-
Jul 22 13:36:15 welcomed-bluebird iscsiadm[3049]: Login to [iface: default, target: iqn.2020-
Jul 22 13:36:15 welcomed-bluebird systemd[1]: Finished open-iscsi.service - Login to default iSCSI targets
# (the command should list an active connection to the 'iqn.2020-
$> iscsiadm -m session -o show
tcp: [1] 127.0.0.1:3260,1 iqn.2020-
# Observe iscsid is complaining about priority:
$> cat /var/log/syslog | grep "Could not set"
2024-07-
2024-07-
## VERIFICATION OF THE FIX ##
# Add the PPA that includes the fix, and update the open-iscsi package:
$> add-apt-repository ppa:mustafakema
$> apt update
$> apt -y install open-iscsi
# Edit the '/etc/iscsi/
(this is needed because we've created it before the update so the priority is explicitly set to "-20". The new ones should have the "node.session.
$> sed -E -i 's/^(node.
# Verify that "node.session.
$> grep "node.session.
(should output the following):
node.session.
# Truncate the syslog
$> truncate -s 0 /var/log/syslog
# Restart the service
$> systemctl restart open-iscsi.service
# Observe that the priority warning has disappeared:
$> grep "iscsi\
# Remove the node altogether:
$> rm -rf /etc/iscsi/
# Re-discover the node:
$> iscsiadm -m discovery -t st -p 127.0.0.1
# Confirm that the priority is set to "0":
$> grep "node.session.
(should output the following):
node.session.
# Confirm that the /etc/iscsi/
$> grep "node.session.
(should output the following):
node.session.
[ Where problems could occur ]
The change prevents a priority change that shouldn't happen in the first place. That might affect some workloads unknowingly depending on it. On the other hand, the nice setting happens intermittently (i.e. by luck) so the behavior right now can't be depended on anyway. The patch only touches the priority setting code so I wouldn't expect any serious breakage.
[ Other Info ]
The other releases that is running a 6.x kernel installed with other means (e.g. hw-enablement, availability) may set the `node.session.
node.session.
which is the default priority for the workqueue threads.
Also, the existing configuration for the nodes under `/etc/iscsi/nodes` path will not be altered, so they must be manually set to "0".
Related branches
- Heitor Alves de Siqueira (community): Needs Fixing
- Canonical Server Core Reviewers: Pending requested
-
Diff: 171 lines (+149/-0)3 files modifieddebian/changelog (+7/-0)
debian/patches/lp2073846-setpriority-fix-for-linux-6x-kernel.patch (+141/-0)
debian/patches/series (+1/-0)
Changed in open-iscsi (Ubuntu Noble): | |
assignee: | nobody → Mustafa Kemal Gilor (mustafakemalgilor) |
status: | New → In Progress |
Changed in open-iscsi (Ubuntu Oracular): | |
status: | New → In Progress |
description: | updated |
description: | updated |
tags: | added: seg sts-sponsor |
Removed 'oracular' from targets as it seems to be updated to 2.1.10 already.