[PATCH v3 2/2] nfs: Add RPCd task affinity config option

Daniel Cederman cederman at gaisler.com
Fri Nov 14 07:58:03 UTC 2014


Similar to the task priority option, the new CPU affinity
option is first controlled by the RPCI specific rpciodCpuset
option. If that is not set, it uses the global network task config.
If that is also not set, it falls back to not setting the affinity
at all, using all CPUs.
---
 cpukit/libfs/src/nfsclient/src/librtemsNfs.h |  9 +++++++++
 cpukit/libfs/src/nfsclient/src/rpcio.c       | 14 ++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h
index 491c3da..530eee2 100644
--- a/cpukit/libfs/src/nfsclient/src/librtemsNfs.h
+++ b/cpukit/libfs/src/nfsclient/src/librtemsNfs.h
@@ -98,6 +98,15 @@ extern "C" {
  */
 extern rtems_task_priority rpciodPriority;
 
+#ifdef RTEMS_SMP
+/** CPU affinity of daemon; may be setup prior to calling rpcUdpInit();
+ * otherwise the network task CPU affinity from the rtems_bsdnet_config
+ * is used...
+ */
+extern const cpu_set_t *rpciodCpuset;
+extern size_t rpciodCpusetSize;
+#endif
+
 /**
  * @brief Sets the XIDs of the RPC transaction hash table.
  *
diff --git a/cpukit/libfs/src/nfsclient/src/rpcio.c b/cpukit/libfs/src/nfsclient/src/rpcio.c
index 7324e02..07bd9a3 100644
--- a/cpukit/libfs/src/nfsclient/src/rpcio.c
+++ b/cpukit/libfs/src/nfsclient/src/rpcio.c
@@ -84,6 +84,7 @@
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <sys/cpuset.h>
 
 #include "rpcio.h"
 
@@ -407,6 +408,10 @@ static rtems_interval	ticksPerSec;		/* cached system clock rate (WHO IS ASSUMED
 											 */
 
 rtems_task_priority		rpciodPriority = 0;
+#ifdef RTEMS_SMP
+const cpu_set_t			*rpciodCpuset = 0;
+size_t				rpciodCpusetSize = 0;
+#endif
 
 #if (DEBUG) & DEBUG_MALLOC
 /* malloc wrappers for debugging */
@@ -983,6 +988,15 @@ struct sockwakeup	wkup;
 											&rpciod);
 			assert( status == RTEMS_SUCCESSFUL );
 
+#ifdef RTEMS_SMP
+			if ( rpciodCpuset == 0 ) {
+				rpciodCpuset = rtems_bsdnet_config.network_task_cpuset;
+				rpciodCpusetSize = rtems_bsdnet_config.network_task_cpuset_size;
+			}
+			if ( rpciodCpuset != 0 )
+				rtems_task_set_affinity( rpciod, rpciodCpusetSize, rpciodCpuset );
+#endif
+
 			wkup.sw_pfn = rxWakeupCB;
 			wkup.sw_arg = &rpciod;
 			assert( 0==setsockopt(ourSock, SOL_SOCKET, SO_RCVWAKEUP, &wkup, sizeof(wkup)) );
-- 
2.1.3




More information about the devel mailing list