- if (td->o.cpumask_set && fio_setaffinity(td->pid, td->o.cpumask) == -1) {
- td_verror(td, errno, "cpu_set_affinity");
- goto err;
+ if (o->cpumask_set) {
+ ret = fio_setaffinity(td->pid, o->cpumask);
+ if (ret == -1) {
+ td_verror(td, errno, "cpu_set_affinity");
+ goto err;
+ }
+ }
+
+#ifdef CONFIG_LIBNUMA
+ /* numa node setup */
+ if (o->numa_cpumask_set || o->numa_memmask_set) {
+ int ret;
+
+ if (numa_available() < 0) {
+ td_verror(td, errno, "Does not support NUMA API\n");
+ goto err;
+ }
+
+ if (o->numa_cpumask_set) {
+ ret = numa_run_on_node_mask(o->numa_cpunodesmask);
+ if (ret == -1) {
+ td_verror(td, errno, \
+ "numa_run_on_node_mask failed\n");
+ goto err;
+ }
+ }
+
+ if (o->numa_memmask_set) {
+
+ switch (o->numa_mem_mode) {
+ case MPOL_INTERLEAVE:
+ numa_set_interleave_mask(o->numa_memnodesmask);
+ break;
+ case MPOL_BIND:
+ numa_set_membind(o->numa_memnodesmask);
+ break;
+ case MPOL_LOCAL:
+ numa_set_localalloc();
+ break;
+ case MPOL_PREFERRED:
+ numa_set_preferred(o->numa_mem_prefer_node);
+ break;
+ case MPOL_DEFAULT:
+ default:
+ break;
+ }
+
+ }