[RFC 10/16] padata: Helpers should respect main thread's CPU affinity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Helper threads should run only on the CPUs allowed by the main thread to
honor its CPU affinity.  Similarly, cap the number of helpers started to
the number of CPUs allowed by the main thread's cpumask to avoid
flooding that subset of CPUs.

Signed-off-by: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx>
---
 kernel/padata.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/padata.c b/kernel/padata.c
index 00509c83e356..0f4002ed1518 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -571,6 +571,7 @@ int padata_do_multithreaded_job(struct padata_mt_job *job,
 	/* Ensure at least one thread when size < min_chunk. */
 	nworks = max(job->size / job->min_chunk, 1ul);
 	nworks = min(nworks, job->max_threads);
+	nworks = min(nworks, current->nr_cpus_allowed);
 
 	if (nworks == 1) {
 		/* Single thread, no coordination needed, cut to the chase. */
@@ -607,10 +608,12 @@ int padata_do_multithreaded_job(struct padata_mt_job *job,
 
 		pw->pw_data = &ps;
 		task = kthread_create(padata_mt_helper, pw, "padata");
-		if (IS_ERR(task))
+		if (IS_ERR(task)) {
 			--ps.nworks;
-		else
+		} else {
+			kthread_bind_mask(task, current->cpus_ptr);
 			wake_up_process(task);
+		}
 	}
 
 	/* Use the current task, which saves starting a kthread. */
-- 
2.34.1






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux