lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 01 Dec 2020 16:04:04 +0000
From:   Valentin Schneider <valentin.schneider@....com>
To:     Barry Song <song.bao.hua@...ilicon.com>
Cc:     catalin.marinas@....com, will@...nel.org, rjw@...ysocki.net,
        lenb@...nel.org, gregkh@...uxfoundation.org,
        Jonathan.Cameron@...wei.com, mingo@...hat.com,
        peterz@...radead.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        mark.rutland@....com, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
        linuxarm@...wei.com, xuwei5@...wei.com, prime.zeng@...ilicon.com
Subject: Re: [RFC PATCH v2 2/2] scheduler: add scheduler level for clusters


On 01/12/20 02:59, Barry Song wrote:
> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> index 1a68a05..ae8ec910 100644
> --- a/kernel/sched/fair.c
> +++ b/kernel/sched/fair.c
> @@ -6106,6 +6106,37 @@ static inline int select_idle_smt(struct task_struct *p, int target)
>  
>  #endif /* CONFIG_SCHED_SMT */
>  
> +#ifdef CONFIG_SCHED_CLUSTER
> +/*
> + * Scan the local CLUSTER mask for idle CPUs.
> + */
> +static int select_idle_cluster(struct task_struct *p, int target)
> +{
> +	int cpu;
> +
> +	/* right now, no hardware with both cluster and smt to run */
> +	if (sched_smt_active())
> +		return -1;
> +
> +	for_each_cpu_wrap(cpu, cpu_cluster_mask(target), target) {

Gating this behind this new config only leveraged by arm64 doesn't make it
very generic. Note that powerpc also has this newish "CACHE" level which
seems to overlap in function with your "CLUSTER" one (both are arch
specific, though).

I think what you are after here is an SD_SHARE_PKG_RESOURCES domain walk,
i.e. scan CPUs by increasing cache "distance". We already have it in some
form, as we scan SMT & LLC domains; AFAICT LLC always maps to MC, except
for said powerpc's CACHE thingie.

*If* we are to generally support more levels with SD_SHARE_PKG_RESOURCES,
we could say frob something into select_idle_cpu(). I'm thinking of
something like the incomplete, untested below: 

---
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ae7ceba8fd4f..70692888db00 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6120,7 +6120,7 @@ static inline int select_idle_smt(struct task_struct *p, struct sched_domain *sd
 static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int target)
 {
 	struct cpumask *cpus = this_cpu_cpumask_var_ptr(select_idle_mask);
-	struct sched_domain *this_sd;
+	struct sched_domain *this_sd, *child = NULL;
 	u64 avg_cost, avg_idle;
 	u64 time;
 	int this = smp_processor_id();
@@ -6150,14 +6150,22 @@ static int select_idle_cpu(struct task_struct *p, struct sched_domain *sd, int t
 
 	time = cpu_clock(this);
 
-	cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
+	do {
+		/* XXX: sd should start as SMT's parent */
+		cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr);
+		if (child)
+			cpumask_andnot(cpus, cpus, sched_domain_span(child));
+
+		for_each_cpu_wrap(cpu, cpus, target) {
+			if (!--nr)
+				return -1;
+			if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
+				break;
+		}
 
-	for_each_cpu_wrap(cpu, cpus, target) {
-		if (!--nr)
-			return -1;
-		if (available_idle_cpu(cpu) || sched_idle_cpu(cpu))
-			break;
-	}
+		child = sd;
+		sd = sd->parent;
+	} while (sd && sd->flags & SD_SHARE_PKG_RESOURCES);
 
 	time = cpu_clock(this) - time;
 	update_avg(&this_sd->avg_scan_cost, time);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ