Re: Best way to set kernel thread affinity for handling a socket?
From: Ben Hutchings <hidden>
Date: 2012-08-23 17:51:20
On Thu, 2012-08-23 at 10:04 -0700, Roland Dreier wrote:
On Wed, Aug 22, 2012 at 9:21 AM, Ben Hutchings [off-list ref] wrote:quoted
With RFS we try to do the reverse: move the packets to match the socket user. But it's not (yet) turned on by default. See Documentation/networking/scaling.txtFair enough. However I think at least in this case it sounds like extra overhead: it should be easy for us to do everything on the CPU where the packets are being received.quoted
quoted
I'm thinking about this in the context of the kernel's iSCSI target code (drivers/target/iscsi), which creates threads to handle each iSCSI connection and sets their CPU affinity pretty much randomly (well, based on some "thread id", cf iscsit_thread_get_cpumask()).Why set the affinity at all?It's quite possible that, like a lot of other drivers/target code, this doesn't actually make any sense and the right answer is to rip it out completely. Is the affinity due to waking up from a network receive event enough to keep the threads local to the right CPU?
I expect it to have some influence on where the receiving task is scheduled, but it doesn't necessarily outweigh other factors that the scheduler takes into account. So you would really have to test this yourself. Ben. -- Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.