netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Synchronization between process context and softirq context on SMP machine
@ 2012-10-23 20:56 Cong Xu
  2012-10-24  2:47 ` Feng King
  0 siblings, 1 reply; 2+ messages in thread
From: Cong Xu @ 2012-10-23 20:56 UTC (permalink / raw)
  To: netdev

I met some problems when I did some research in improving the TCP/UDP 
performance of Virtual Machine(VM), if anybody can offer me some help or 
suggestion to handle my problem, I will be very appreciated.


On virtual machine platform, virtual CPU (vCPU) of each VM can not be always 
online when several vCPUs share one physical CPU (pCPU) (Here we can simply 
assume the vCPU scheduling is round-robin.). Therefore, the high delay of TCP 
receiving of VM hurts the TCP throughput significantly. In order to handle this 
problem I assign a virtual co-processor (co-vCPU) which is almost always online 
to each VM and pin NIC IRQ of the VM to this co-vCPU. ( If you are not familiar 
with VM, you can simply assume that in a common OS the user level application 
(e.g. iperf) runs on a cpu which will be offline every 30ms, and the bottom half
 or softirq context runs on another cpu which is always online. )

In my experiment, this method works well for UDP but does not work for TCP. I 
doubt that it is due to the synchronization between process context and softirq 
context. Because when I read some source code of TCP layer in linux, I found 
that both softirq context (e.g. tcp_v4_rcv() in net/ipv4/tcp_ipv4.c) and process 
context (e.g. tcp_recvmsg() in net/ipv4/tcp.c) call lock_sock()/unlock_sock() 
when they access the buffers in kernel(receive_queue, backlog_queue or p
requeue). Therefore, sometimes softirq context can not access the receiving 
buffers locked by another vCPU which runs the user level receiving process 
(iperf server) and this vCPU holding the spinlock has been descheduled by VM 
monitor(VMM) or hypervisor.


I am not sure I described my problem clearly. Anyway, welcome any suggestion on 
it.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Synchronization between process context and softirq context on SMP machine
  2012-10-23 20:56 Synchronization between process context and softirq context on SMP machine Cong Xu
@ 2012-10-24  2:47 ` Feng King
  0 siblings, 0 replies; 2+ messages in thread
From: Feng King @ 2012-10-24  2:47 UTC (permalink / raw)
  To: Cong Xu; +Cc: netdev

2012/10/24 Cong Xu <davidxu06@gmail.com>
>
> I met some problems when I did some research in improving the TCP/UDP
> performance of Virtual Machine(VM), if anybody can offer me some help or
> suggestion to handle my problem, I will be very appreciated.
>
>
> On virtual machine platform, virtual CPU (vCPU) of each VM can not be always
> online when several vCPUs share one physical CPU (pCPU) (Here we can simply
> assume the vCPU scheduling is round-robin.). Therefore, the high delay of TCP
> receiving of VM hurts the TCP throughput significantly. In order to handle this
> problem I assign a virtual co-processor (co-vCPU) which is almost always online
> to each VM and pin NIC IRQ of the VM to this co-vCPU. ( If you are not familiar
> with VM, you can simply assume that in a common OS the user level application
> (e.g. iperf) runs on a cpu which will be offline every 30ms, and the bottom half
>  or softirq context runs on another cpu which is always online. )
>
> In my experiment, this method works well for UDP but does not work for TCP. I
> doubt that it is due to the synchronization between process context and softirq
> context. Because when I read some source code of TCP layer in linux, I found
> that both softirq context (e.g. tcp_v4_rcv() in net/ipv4/tcp_ipv4.c) and process
> context (e.g. tcp_recvmsg() in net/ipv4/tcp.c) call lock_sock()/unlock_sock()
> when they access the buffers in kernel(receive_queue, backlog_queue or p
> requeue). Therefore, sometimes softirq context can not access the receiving
> buffers locked by another vCPU which runs the user level receiving process
> (iperf server) and this vCPU holding the spinlock has been descheduled by VM
> monitor(VMM) or hypervisor.

 if socket is held by process(sock_owned_by_user), softirq will just
add skb to socket's backlog
and then return. when process called release_sock, skbs in backlog
will be handled in process context,
to finish their tcp handling.
  so if softirq enqueues skb more quickly than process consume speed,
the skbs held in sock recvqueue, prequeue
and backlog will grow, if sum of skb truesize beyond per socket
receive buffer limit, skb will be dropped. through
'ss -oemi' you can see per socket receive buffer consumed,
>
>
>
> I am not sure I described my problem clearly. Anyway, welcome any suggestion on
> it.
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html




--

Best Regards
king

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-24  2:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-23 20:56 Synchronization between process context and softirq context on SMP machine Cong Xu
2012-10-24  2:47 ` Feng King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).