Skip to content

Commit

Permalink
sched/topology: Check SDF_SHARED_CHILD in highest_flag_domain()
Browse files Browse the repository at this point in the history
Do not assume that all the children of a scheduling domain have a given
flag. Check whether it has the SDF_SHARED_CHILD meta flag.

Cc: Ben Segall <bsegall@google.com>
Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
Cc: Ionela Voinescu <ionela.voinescu@arm.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tim C. Chen <tim.c.chen@intel.com>
Cc: Valentin Schneider <vschneid@redhat.com>
Cc: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Suggested-by: Ionela Voinescu <ionela.voinescu@arm.com>
Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Signed-off-by: Alexandre Frade <kernel@xanmod.org>
  • Loading branch information
ricardon authored and xanmod committed Apr 26, 2023
1 parent eda1952 commit 3382a43
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions kernel/sched/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -1764,23 +1764,39 @@ queue_balance_callback(struct rq *rq,
for (__sd = rcu_dereference_check_sched_domain(cpu_rq(cpu)->sd); \
__sd; __sd = __sd->parent)

/* A mask of all the SD flags that have the SDF_SHARED_CHILD metaflag */
#define SD_FLAG(name, mflags) (name * !!((mflags) & SDF_SHARED_CHILD)) |
static const unsigned int SD_SHARED_CHILD_MASK =
#include <linux/sched/sd_flags.h>
0;
#undef SD_FLAG

/**
* highest_flag_domain - Return highest sched_domain containing flag.
* @cpu: The CPU whose highest level of sched domain is to
* be returned.
* @flag: The flag to check for the highest sched_domain
* for the given CPU.
*
* Returns the highest sched_domain of a CPU which contains the given flag.
* Returns the highest sched_domain of a CPU which contains @flag. If @flag has
* the SDF_SHARED_CHILD metaflag, all the children domains also have @flag.
*/
static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
{
struct sched_domain *sd, *hsd = NULL;

for_each_domain(cpu, sd) {
if (!(sd->flags & flag))
if (sd->flags & flag) {
hsd = sd;
continue;
}

/*
* Stop the search if @flag is known to be shared at lower
* levels. It will not be found further up.
*/
if (flag & SD_SHARED_CHILD_MASK)
break;
hsd = sd;
}

return hsd;
Expand Down

0 comments on commit 3382a43

Please sign in to comment.