diff options
| -rw-r--r-- | Documentation/kernel-parameters.txt | 11 | ||||
| -rw-r--r-- | kernel/workqueue.c | 23 | ||||
| -rw-r--r-- | lib/Kconfig.debug | 15 |
3 files changed, 47 insertions, 2 deletions
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index 87d40a72f6a1..cda2ead39093 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -4230,6 +4230,17 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 4230 | The default value of this parameter is determined by | 4230 | The default value of this parameter is determined by |
| 4231 | the config option CONFIG_WQ_POWER_EFFICIENT_DEFAULT. | 4231 | the config option CONFIG_WQ_POWER_EFFICIENT_DEFAULT. |
| 4232 | 4232 | ||
| 4233 | workqueue.debug_force_rr_cpu | ||
| 4234 | Workqueue used to implicitly guarantee that work | ||
| 4235 | items queued without explicit CPU specified are put | ||
| 4236 | on the local CPU. This guarantee is no longer true | ||
| 4237 | and while local CPU is still preferred work items | ||
| 4238 | may be put on foreign CPUs. This debug option | ||
| 4239 | forces round-robin CPU selection to flush out | ||
| 4240 | usages which depend on the now broken guarantee. | ||
| 4241 | When enabled, memory and cache locality will be | ||
| 4242 | impacted. | ||
| 4243 | |||
| 4233 | x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of | 4244 | x2apic_phys [X86-64,APIC] Use x2apic physical mode instead of |
| 4234 | default x2apic cluster mode on platforms | 4245 | default x2apic cluster mode on platforms |
| 4235 | supporting x2apic. | 4246 | supporting x2apic. |
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 054774605d2f..51d77e7c0989 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -307,6 +307,18 @@ static cpumask_var_t wq_unbound_cpumask; | |||
| 307 | /* CPU where unbound work was last round robin scheduled from this CPU */ | 307 | /* CPU where unbound work was last round robin scheduled from this CPU */ |
| 308 | static DEFINE_PER_CPU(int, wq_rr_cpu_last); | 308 | static DEFINE_PER_CPU(int, wq_rr_cpu_last); |
| 309 | 309 | ||
| 310 | /* | ||
| 311 | * Local execution of unbound work items is no longer guaranteed. The | ||
| 312 | * following always forces round-robin CPU selection on unbound work items | ||
| 313 | * to uncover usages which depend on it. | ||
| 314 | */ | ||
| 315 | #ifdef CONFIG_DEBUG_WQ_FORCE_RR_CPU | ||
| 316 | static bool wq_debug_force_rr_cpu = true; | ||
| 317 | #else | ||
| 318 | static bool wq_debug_force_rr_cpu = false; | ||
| 319 | #endif | ||
| 320 | module_param_named(debug_force_rr_cpu, wq_debug_force_rr_cpu, bool, 0644); | ||
| 321 | |||
| 310 | /* the per-cpu worker pools */ | 322 | /* the per-cpu worker pools */ |
| 311 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct worker_pool [NR_STD_WORKER_POOLS], | 323 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct worker_pool [NR_STD_WORKER_POOLS], |
| 312 | cpu_worker_pools); | 324 | cpu_worker_pools); |
| @@ -1309,10 +1321,17 @@ static bool is_chained_work(struct workqueue_struct *wq) | |||
| 1309 | */ | 1321 | */ |
| 1310 | static int wq_select_unbound_cpu(int cpu) | 1322 | static int wq_select_unbound_cpu(int cpu) |
| 1311 | { | 1323 | { |
| 1324 | static bool printed_dbg_warning; | ||
| 1312 | int new_cpu; | 1325 | int new_cpu; |
| 1313 | 1326 | ||
| 1314 | if (cpumask_test_cpu(cpu, wq_unbound_cpumask)) | 1327 | if (likely(!wq_debug_force_rr_cpu)) { |
| 1315 | return cpu; | 1328 | if (cpumask_test_cpu(cpu, wq_unbound_cpumask)) |
| 1329 | return cpu; | ||
| 1330 | } else if (!printed_dbg_warning) { | ||
| 1331 | pr_warn("workqueue: round-robin CPU selection forced, expect performance impact\n"); | ||
| 1332 | printed_dbg_warning = true; | ||
| 1333 | } | ||
| 1334 | |||
| 1316 | if (cpumask_empty(wq_unbound_cpumask)) | 1335 | if (cpumask_empty(wq_unbound_cpumask)) |
| 1317 | return cpu; | 1336 | return cpu; |
| 1318 | 1337 | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index ecb9e75614bf..8bfd1aca7a3d 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
| @@ -1400,6 +1400,21 @@ config RCU_EQS_DEBUG | |||
| 1400 | 1400 | ||
| 1401 | endmenu # "RCU Debugging" | 1401 | endmenu # "RCU Debugging" |
| 1402 | 1402 | ||
| 1403 | config DEBUG_WQ_FORCE_RR_CPU | ||
| 1404 | bool "Force round-robin CPU selection for unbound work items" | ||
| 1405 | depends on DEBUG_KERNEL | ||
| 1406 | default n | ||
| 1407 | help | ||
| 1408 | Workqueue used to implicitly guarantee that work items queued | ||
| 1409 | without explicit CPU specified are put on the local CPU. This | ||
| 1410 | guarantee is no longer true and while local CPU is still | ||
| 1411 | preferred work items may be put on foreign CPUs. Kernel | ||
| 1412 | parameter "workqueue.debug_force_rr_cpu" is added to force | ||
| 1413 | round-robin CPU selection to flush out usages which depend on the | ||
| 1414 | now broken guarantee. This config option enables the debug | ||
| 1415 | feature by default. When enabled, memory and cache locality will | ||
| 1416 | be impacted. | ||
| 1417 | |||
| 1403 | config DEBUG_BLOCK_EXT_DEVT | 1418 | config DEBUG_BLOCK_EXT_DEVT |
| 1404 | bool "Force extended block device numbers and spread them" | 1419 | bool "Force extended block device numbers and spread them" |
| 1405 | depends on DEBUG_KERNEL | 1420 | depends on DEBUG_KERNEL |
