Unverified Commit 99680a79 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7395 smart_grid: introducing rebuild_affinity_domain

parents 977ad51f 5803ffa8
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -9704,6 +9704,15 @@ static int cpu_affinity_stat_show(struct seq_file *sf, void *v)

	return 0;
}

static int cpu_rebuild_affinity_domain_u64(struct cgroup_subsys_state *css,
					   struct cftype *cftype,
					   u64 cpu)
{
	struct task_group *tg = css_tg(css);

	return tg_rebuild_affinity_domains(cpu, tg->auto_affinity);
}
#endif /* CONFIG_QOS_SCHED_SMART_GRID */

#ifdef CONFIG_QOS_SCHED
@@ -9887,6 +9896,10 @@ static struct cftype cpu_legacy_files[] = {
		.name = "affinity_stat",
		.seq_show = cpu_affinity_stat_show,
	},
	{
		.name = "rebuild_affinity_domain",
		.write_u64 = cpu_rebuild_affinity_domain_u64,
	},
#endif
#ifdef CONFIG_CFS_BANDWIDTH
	{
+43 −0
Original line number Diff line number Diff line
@@ -6385,6 +6385,49 @@ static void destroy_auto_affinity(struct task_group *tg)
	kfree(tg->auto_affinity);
	tg->auto_affinity = NULL;
}

int tg_rebuild_affinity_domains(int cpu, struct auto_affinity *auto_affi)
{
	int ret = 0;
	int level = 0;
	struct sched_domain *tmp;

	if (unlikely(!auto_affi))
		return -EPERM;

	mutex_lock(&smart_grid_used_mutex);
	raw_spin_lock_irq(&auto_affi->lock);
	/* Only build domain while auto mode disabled */
	if (auto_affi->mode) {
		ret = -EPERM;
		goto unlock_all;
	}

	/* Only build on active and housekeeping cpu */
	if (!cpu_active(cpu) || !housekeeping_cpu(cpu, HK_FLAG_DOMAIN)) {
		ret = -EINVAL;
		goto unlock_all;
	}

	for_each_domain(cpu, tmp) {
		if (!auto_affi->ad.domains[level] || !auto_affi->ad.domains_orig[level])
			continue;

		/* rebuild domain[,_orig] and reset schedstat counter */
		cpumask_copy(auto_affi->ad.domains[level], sched_domain_span(tmp));
		cpumask_copy(auto_affi->ad.domains_orig[level], auto_affi->ad.domains[level]);
		__schedstat_set(auto_affi->ad.stay_cnt[level], 0);
		level++;
	}

	/* trigger to update smart grid zone */
	sched_grid_zone_update(false);

unlock_all:
	raw_spin_unlock_irq(&auto_affi->lock);
	mutex_unlock(&smart_grid_used_mutex);
	return ret;
}
#else
static void __maybe_unused destroy_auto_affinity(struct task_group *tg) {}

+1 −0
Original line number Diff line number Diff line
@@ -582,6 +582,7 @@ extern void start_auto_affinity(struct auto_affinity *auto_affi);
extern void stop_auto_affinity(struct auto_affinity *auto_affi);
extern int init_auto_affinity(struct task_group *tg);
extern void tg_update_affinity_domains(int cpu, int online);
extern int tg_rebuild_affinity_domains(int cpu, struct auto_affinity *auto_affi);

#else
static inline int init_auto_affinity(struct task_group *tg)