Skip to contentSkip to conversation

libceph: switch ceph-msgr workqueue from WQ_PERCPU to WQ_UNBOUND

PATCH In review Viacheslav Dubeyko 3 participants 5 messages Apr 9 – Apr 24

Subsystems (2)
lore
Share & tools
lore

Viacheslav Dubeyko

author maintainer
#0 lore raw

PATCH 1/1 libceph: switch ceph-msgr workqueue from WQ_PERCPU to WQ_UNBOUND

From: Viacheslav Dubeyko <[email protected]>

The ceph-msgr workqueue was changed to use WQ_PERCPU in commit 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users") as part of a tree-wide transition to make per-CPU workqueue binding explicit.

However, ceph_con_workfn contains a while(true) loop that retries on -EAGAIN from socket reads and writes, making it capable of hogging a bound CPU for extended periods. This manifests at runtime as:

workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND

Switch the workqueue to WQ_UNBOUND so the scheduler can freely place workers across CPUs, preventing starvation of other work items on the bound CPU. The loss of cache locality is acceptable for network I/O work.

Fixes 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users")
cc Alex Markuze <[email protected]>
cc Ilya Dryomov <[email protected]>
cc Patrick Donnelly <[email protected]>
cc Ceph Development <[email protected]>
---
 net/ceph/messenger.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/messenger.c +1 -1
index 108adb583744..dbca8bfaf5fc 100644
@@ -253,7 +253,7 @@ int __init ceph_msgr_init(void)
 	 * connections, so leave @max_active at default.
 	 */
 	ceph_msgr_wq = alloc_workqueue("ceph-msgr",
-				       WQ_MEM_RECLAIM | WQ_PERCPU, 0);
+				       WQ_MEM_RECLAIM | WQ_UNBOUND, 0);
 	if (ceph_msgr_wq)
 		return 0;
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 10 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The ceph-msgr workqueue was changed to use WQ_PERCPU in commit 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users") as part of a tree-wide transition to make per-CPU workqueue binding explicit.

However, ceph_con_workfn contains a while(true) loop that retries on -EAGAIN from socket reads and writes, making it capable of hogging a bound CPU for extended periods. This manifests at runtime as:

Hi Slava,

ceph_con_workfn() does have a loop, but it doesn't retry EAGAIN from the socket. Both msgr1 and msgr2 munge EAGAIN from the socket to 0 to indicate the "socket is empty/full, need to wait" condition. See do_recvmsg() and do_sendmsg() for msgr2 and ceph_tcp_*() for msgr1. For example:

    ret = sock_recvmsg(sock, &msg, msg.msg_flags);
    if (ret <= 0) {
            if (ret == -EAGAIN)
                    ret = 0;
            return ret;
    }

Ignoring opening, closing and a couple of other special cases, ceph_con_workfn() starts by trying to read. When the read side of the socket becomes empty, it proceeds to trying to write. When the write side of the socket becomes full, ceph_con_workfn() terminates. It doesn't even go back to trying to read, so I fail to see the potential for what you have described.

Quoted 8 lines

workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND

Switch the workqueue to WQ_UNBOUND so the scheduler can freely place workers across CPUs, preventing starvation of other work items on the bound CPU. The loss of cache locality is acceptable for network I/O work.

This might be true, but I'm not sure this conclusion can be made without at least some benchmarking.

Thanks,

Ilya

#2 lore raw
Quoted 38 lines · Ilya Dryomov
Quoted 10 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The ceph-msgr workqueue was changed to use WQ_PERCPU in commit 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users") as part of a tree-wide transition to make per-CPU workqueue binding explicit.

However, ceph_con_workfn contains a while(true) loop that retries on -EAGAIN from socket reads and writes, making it capable of hogging a bound CPU for extended periods. This manifests at runtime as:

Hi Slava,

ceph_con_workfn() does have a loop, but it doesn't retry EAGAIN from the socket. Both msgr1 and msgr2 munge EAGAIN from the socket to 0 to indicate the "socket is empty/full, need to wait" condition. See do_recvmsg() and do_sendmsg() for msgr2 and ceph_tcp_*() for msgr1. For example:

    ret = sock_recvmsg(sock, &msg, msg.msg_flags);
    if (ret <= 0) {
            if (ret == -EAGAIN)
                    ret = 0;
            return ret;
    }

Ignoring opening, closing and a couple of other special cases, ceph_con_workfn() starts by trying to read. When the read side of the socket becomes empty, it proceeds to trying to write. When the write side of the socket becomes full, ceph_con_workfn() terminates. It doesn't even go back to trying to read, so I fail to see the potential for what you have described.

Quoted 4 lines

workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND

Quoted 7 lines
Quoted 4 lines

Switch the workqueue to WQ_UNBOUND so the scheduler can freely place workers across CPUs, preventing starvation of other work items on the bound CPU. The loss of cache locality is acceptable for network I/O work.

This might be true, but I'm not sure this conclusion can be made without at least some benchmarking.

My system log is full of likewise messages "workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND" when I am testing the CephFS kernel client by means of xfstests. Which particular benchmarking would you like to see?

Thanks,
Slava.

maintainer
#3 lore raw
Quoted 45 lines · Viacheslav Dubeyko
Quoted 43 lines · Ilya Dryomov
Quoted 10 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The ceph-msgr workqueue was changed to use WQ_PERCPU in commit 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users") as part of a tree-wide transition to make per-CPU workqueue binding explicit.

However, ceph_con_workfn contains a while(true) loop that retries on -EAGAIN from socket reads and writes, making it capable of hogging a bound CPU for extended periods. This manifests at runtime as:

Hi Slava,

ceph_con_workfn() does have a loop, but it doesn't retry EAGAIN from the socket. Both msgr1 and msgr2 munge EAGAIN from the socket to 0 to indicate the "socket is empty/full, need to wait" condition. See do_recvmsg() and do_sendmsg() for msgr2 and ceph_tcp_*() for msgr1. For example:

    ret = sock_recvmsg(sock, &msg, msg.msg_flags);
    if (ret <= 0) {
            if (ret == -EAGAIN)
                    ret = 0;
            return ret;
    }

Ignoring opening, closing and a couple of other special cases, ceph_con_workfn() starts by trying to read. When the read side of the socket becomes empty, it proceeds to trying to write. When the write side of the socket becomes full, ceph_con_workfn() terminates. It doesn't even go back to trying to read, so I fail to see the potential for what you have described.

Quoted 8 lines

workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND

Switch the workqueue to WQ_UNBOUND so the scheduler can freely place workers across CPUs, preventing starvation of other work items on the bound CPU. The loss of cache locality is acceptable for network I/O work.

Quoted 7 lines
Quoted 2 lines

This might be true, but I'm not sure this conclusion can be made without at least some benchmarking.

My system log is full of likewise messages "workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND" when I am testing the CephFS kernel client by means of xfstests. Which particular benchmarking would you like to see?

Hi Slava,

What kind of a system is it? If it's a small VM, the backing Ceph cluster is a vstart-style deployment co-located on the same node and the node itself isn't beefy, the performance profile may be very different from real world setups.

The first step would be determining the source of the hogging. One thing to keep in mind is that OSD and MDS request callbacks are executed in-line (i.e. from ceph-msgr worker threads). If there is evidence of significant lock contention or any other activity that can potentially hog the CPU inside of e.g. MDS client's handle_reply() that would be the thing to look into and fix, not the messenger.

Thanks,

Ilya

#4 lore raw
Quoted 55 lines · Ilya Dryomov
Quoted 45 lines · Viacheslav Dubeyko
Quoted 43 lines · Ilya Dryomov
Quoted 10 lines · Viacheslav Dubeyko

From: Viacheslav Dubeyko <[email protected]>

The ceph-msgr workqueue was changed to use WQ_PERCPU in commit 27ce71e1ce81 ("net: WQ_PERCPU added to alloc_workqueue users") as part of a tree-wide transition to make per-CPU workqueue binding explicit.

However, ceph_con_workfn contains a while(true) loop that retries on -EAGAIN from socket reads and writes, making it capable of hogging a bound CPU for extended periods. This manifests at runtime as:

Hi Slava,

ceph_con_workfn() does have a loop, but it doesn't retry EAGAIN from the socket. Both msgr1 and msgr2 munge EAGAIN from the socket to 0 to indicate the "socket is empty/full, need to wait" condition. See do_recvmsg() and do_sendmsg() for msgr2 and ceph_tcp_*() for msgr1. For example:

    ret = sock_recvmsg(sock, &msg, msg.msg_flags);
    if (ret <= 0) {
            if (ret == -EAGAIN)
                    ret = 0;
            return ret;
    }

Ignoring opening, closing and a couple of other special cases, ceph_con_workfn() starts by trying to read. When the read side of the socket becomes empty, it proceeds to trying to write. When the write side of the socket becomes full, ceph_con_workfn() terminates. It doesn't even go back to trying to read, so I fail to see the potential for what you have described.

Quoted 8 lines

workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND

Switch the workqueue to WQ_UNBOUND so the scheduler can freely place workers across CPUs, preventing starvation of other work items on the bound CPU. The loss of cache locality is acceptable for network I/O work.

Quoted 7 lines
Quoted 2 lines

This might be true, but I'm not sure this conclusion can be made without at least some benchmarking.

My system log is full of likewise messages "workqueue: ceph_con_workfn hogged CPU for >10000us N times, consider switching to WQ_UNBOUND" when I am testing the CephFS kernel client by means of xfstests. Which particular benchmarking would you like to see?

Quoted 6 lines

Hi Slava,

What kind of a system is it? If it's a small VM, the backing Ceph cluster is a vstart-style deployment co-located on the same node and the node itself isn't beefy, the performance profile may be very different from real world setups.

I have three nodes cluster on physical machines and CephFS kernel client works inside of VM on another physical machine.

Thanks,
Slava.

Quoted 11 lines

The first step would be determining the source of the hogging. One thing to keep in mind is that OSD and MDS request callbacks are executed in-line (i.e. from ceph-msgr worker threads). If there is evidence of significant lock contention or any other activity that can potentially hog the CPU inside of e.g. MDS client's handle_reply() that would be the thing to look into and fix, not the messenger.

Thanks,

Ilya