Commit af1c5150 authored by Maciej Szwed's avatar Maciej Szwed Committed by Tomasz Zawadzki
Browse files

scheduler: Move busy thread if its mask do not match current lcore



When using interrupt mode we can have a situation
when we create thread (which is always busy) with
a particular core mask, but this thread will be
scheduled for different core, because core
pointed by thread mask is in interrupt mode.

This thread will never be moved by scheduler
to correct core because currently scheduler
do not move busy threads.

This change makes scheduler to move busy threads
if their mask do not match core on which they
are executed currently.

Signed-off-by: default avatarMaciej Szwed <maciej.szwed@intel.com>
Change-Id: I35abdc91b197f1b9d40e491f964d31debad72fa5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6073


Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 20362e5b
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -205,8 +205,26 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
				main_core_busy += spdk_min(UINT64_MAX - main_core_busy, thread_busy);
				main_core_idle -= spdk_min(main_core_idle, thread_busy);
			} else {
				/* This thread should remain on the same core */
				/* Move busy thread only if cpumask does not match current core (except main core) */
				if (i != g_main_lcore) {
					if (!spdk_cpuset_get_cpu(cpumask, i)) {
						for (k = 0; k < spdk_env_get_core_count(); k++) {
							target_lcore = _get_next_target_core();

							if (spdk_cpuset_get_cpu(cpumask, target_lcore)) {
								lw_thread->new_lcore = target_lcore;
								cores_info[target_lcore].pending_threads_count++;
								core->pending_threads_count--;

								if (target_lcore == g_main_lcore) {
									main_core_busy += spdk_min(UINT64_MAX - main_core_busy, thread_busy);
									main_core_idle -= spdk_min(main_core_idle, thread_busy);
								}
								break;
							}
						}
					}

					busy_threads_present = true;
				}
			}