libceph: switch ceph-msgr workqueue from WQ_PERCPU to WQ_UNBOUND
Subsystems (2)
Viacheslav Dubeyko
maintainerPATCH 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.
--- net/ceph/messenger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ceph/messenger.c +1 -1
@@ -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
Ilya Dryomov
maintainerQuoted 10 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
The ceph-msgr workqueue was changed to use
WQ_PERCPUin commit27ce71e1ce81("net:WQ_PERCPUadded toalloc_workqueueusers") as part of a tree-wide transition to make per-CPU workqueue binding explicit.However,
ceph_con_workfncontains a while(true) loop that retries on-EAGAINfrom 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_workfnhogged CPU for >10000us N times, consider switching toWQ_UNBOUNDSwitch the workqueue to
WQ_UNBOUNDso 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
Quoted 38 lines · Ilya Dryomov
Quoted 10 lines · Viacheslav Dubeyko
From: Viacheslav Dubeyko <[email protected]>
The ceph-msgr workqueue was changed to use
WQ_PERCPUin commit27ce71e1ce81("net:WQ_PERCPUadded toalloc_workqueueusers") as part of a tree-wide transition to make per-CPU workqueue binding explicit.However,
ceph_con_workfncontains a while(true) loop that retries on-EAGAINfrom 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. Seedo_recvmsg()anddo_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_workfnhogged CPU for >10000us N times, consider switching toWQ_UNBOUND
Quoted 7 lines
Quoted 4 lines
Switch the workqueue to
WQ_UNBOUNDso 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.
Ilya Dryomov
maintainerQuoted 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_PERCPUin commit27ce71e1ce81("net:WQ_PERCPUadded toalloc_workqueueusers") as part of a tree-wide transition to make per-CPU workqueue binding explicit.However,
ceph_con_workfncontains a while(true) loop that retries on-EAGAINfrom 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. Seedo_recvmsg()anddo_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_workfnhogged CPU for >10000us N times, consider switching toWQ_UNBOUNDSwitch the workqueue to
WQ_UNBOUNDso 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_workfnhogged CPU for >10000us N times, consider switching toWQ_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
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_PERCPUin commit27ce71e1ce81("net:WQ_PERCPUadded toalloc_workqueueusers") as part of a tree-wide transition to make per-CPU workqueue binding explicit.However,
ceph_con_workfncontains a while(true) loop that retries on-EAGAINfrom 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. Seedo_recvmsg()anddo_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_workfnhogged CPU for >10000us N times, consider switching toWQ_UNBOUNDSwitch the workqueue to
WQ_UNBOUNDso 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_workfnhogged CPU for >10000us N times, consider switching toWQ_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