Message ID | 20201002222514.1159492-1-weiwan@google.com |
---|---|
Headers | show |
Series | implement kthread based napi poll | expand |
From: Wei Wang > Sent: 02 October 2020 23:25 > > The idea of moving the napi poll process out of softirq context to a > kernel thread based context is not new. > Paolo Abeni and Hannes Frederic Sowa have proposed patches to move napi > poll to kthread back in 2016. And Felix Fietkau has also proposed > patches of similar ideas to use workqueue to process napi poll just a > few weeks ago. What default scheduler priority are you planning to use? The current 'softint' is (effectively) slightly higher priority than the highest RT priority. I think you need to use a 'middle' priority RT process so that applications can decide whether they need to be higher/lower priority than the network code. But then you hit the problem that the scheduler gives RT processes a very 'sticky' cpu affinity. IIRC they don't ever get 'stolen' by an idle cpu, so only migrate when the scheduler for the cpu they last ran on decides to run something of a higher priority. This is problematic if a low priority process in looping in kernel space somewhere (without a cond_resched()). (I've been running ftrace...) Given that the napi cpu cycles have to happen sometime, the biggest problem I found with the current softint implementation is that a hardware interrupt can happen while an application is holding a (user space) mutex. This will block other application threads from acquiring the mutex until not only the hardware interrupt completes, but also all the associated softint (typically napi and rcu) processing has completed. This can take a while! Moving the 'softint' processing to a separate thread will allow the interrupted process to release the mutex and all the application threads continue. I guess the downside of using a thread is that the data needed is likely to be in the wrong cache. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
From: Wei Wang > Sent: 02 October 2020 23:25 > > The idea of moving the napi poll process out of softirq context to a > kernel thread based context is not new. > Paolo Abeni and Hannes Frederic Sowa have proposed patches to move napi > poll to kthread back in 2016. And Felix Fietkau has also proposed > patches of similar ideas to use workqueue to process napi poll just a > few weeks ago. I didn't spot anything that makes this continue to work? static inline bool netdev_xmit_more(void) { return __this_cpu_read(softnet_data.xmit.more); } I assume it normally relies on the softint code running with pre-emption disabled. (It also needs a level of indirection. xmit.more is only set if more packets are queued when the tx call is done. I've seen a workload that manages to repeatedly add an extra packet while the tx setup is in progress.) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)