the highest_flag_domain is to search the highest sched_domain
containing flag, but if the lower sched_domain didn't contain
the flag, but the higher sched_domain contains the flag, the
function will return NULL instead of the higher sched_domain.
For example:
In MC domain : no SD_ASYM_CPUCAPACITY flag;
In DIE domain : containing SD_ASYM_CPUCAPACITY flag;
the "highest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)" will return NULL.
Signed-off-by: Xuewen Yan <[email protected]>
---
kernel/sched/sched.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index 28709f6..2c7c566 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -1427,7 +1427,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
for_each_domain(cpu, sd) {
if (!(sd->flags & flag))
- break;
+ continue;
hsd = sd;
}
--
1.9.1
On 27/10/2020 04:32, Xuewen Yan wrote:
> the highest_flag_domain is to search the highest sched_domain
> containing flag, but if the lower sched_domain didn't contain
> the flag, but the higher sched_domain contains the flag, the
> function will return NULL instead of the higher sched_domain.
>
> For example:
> In MC domain : no SD_ASYM_CPUCAPACITY flag;
> In DIE domain : containing SD_ASYM_CPUCAPACITY flag;
> the "highest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)" will return NULL.
>
> Signed-off-by: Xuewen Yan <[email protected]>
> ---
> kernel/sched/sched.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
> index 28709f6..2c7c566 100644
> --- a/kernel/sched/sched.h
> +++ b/kernel/sched/sched.h
> @@ -1427,7 +1427,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
>
> for_each_domain(cpu, sd) {
> if (!(sd->flags & flag))
> - break;
> + continue;
> hsd = sd;
> }
We distinguish between SDF_SHARED_PARENT and SDF_SHARED_CHILD SD flags.
1 SD_FLAG(*SD_ASYM_CPUCAPACITY*, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
2 SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
3 SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
4 SD_FLAG(SD_NUMA, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
1 SD_FLAG(SD_BALANCE_NEWIDLE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
2 SD_FLAG(SD_BALANCE_EXEC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
3 SD_FLAG(SD_BALANCE_FORK, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
4 SD_FLAG(SD_BALANCE_WAKE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
5 82 SD_FLAG(SD_WAKE_AFFINE, SDF_SHARED_CHILD)
6 SD_FLAG(SD_SHARE_CPUCAPACITY, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
7 SD_FLAG(SD_SHARE_PKG_RESOURCES, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
8 SD_FLAG(SD_ASYM_PACKING, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
We call lowest_flag_domain() on SDF_SHARED_PARENT and
highest_flag_domain() on SDF_SHARED_CHILD SD flags.
1 sd = lowest_flag_domain(cpu, SD_NUMA);
2 sd = lowest_flag_domain(cpu, *SD_ASYM_CPUCAPACITY*);
1 sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
2 sd = highest_flag_domain(cpu, SD_ASYM_PACKING);
On 27/10/20 09:57, Dietmar Eggemann wrote:
> On 27/10/2020 04:32, Xuewen Yan wrote:
>> the highest_flag_domain is to search the highest sched_domain
>> containing flag, but if the lower sched_domain didn't contain
>> the flag, but the higher sched_domain contains the flag, the
>> function will return NULL instead of the higher sched_domain.
>>
>> For example:
>> In MC domain : no SD_ASYM_CPUCAPACITY flag;
>> In DIE domain : containing SD_ASYM_CPUCAPACITY flag;
>> the "highest_flag_domain(cpu, SD_ASYM_CPUCAPACITY)" will return NULL.
>>
>> Signed-off-by: Xuewen Yan <[email protected]>
>> ---
>> kernel/sched/sched.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
>> index 28709f6..2c7c566 100644
>> --- a/kernel/sched/sched.h
>> +++ b/kernel/sched/sched.h
>> @@ -1427,7 +1427,7 @@ static inline struct sched_domain *highest_flag_domain(int cpu, int flag)
>>
>> for_each_domain(cpu, sd) {
>> if (!(sd->flags & flag))
>> - break;
>> + continue;
>> hsd = sd;
>> }
>
> We distinguish between SDF_SHARED_PARENT and SDF_SHARED_CHILD SD flags.
>
> 1 SD_FLAG(*SD_ASYM_CPUCAPACITY*, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
> 2 SD_FLAG(SD_SERIALIZE, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
> 3 SD_FLAG(SD_OVERLAP, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
> 4 SD_FLAG(SD_NUMA, SDF_SHARED_PARENT | SDF_NEEDS_GROUPS)
>
> 1 SD_FLAG(SD_BALANCE_NEWIDLE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 2 SD_FLAG(SD_BALANCE_EXEC, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 3 SD_FLAG(SD_BALANCE_FORK, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 4 SD_FLAG(SD_BALANCE_WAKE, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 5 82 SD_FLAG(SD_WAKE_AFFINE, SDF_SHARED_CHILD)
> 6 SD_FLAG(SD_SHARE_CPUCAPACITY, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 7 SD_FLAG(SD_SHARE_PKG_RESOURCES, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
> 8 SD_FLAG(SD_ASYM_PACKING, SDF_SHARED_CHILD | SDF_NEEDS_GROUPS)
>
> We call lowest_flag_domain() on SDF_SHARED_PARENT and
> highest_flag_domain() on SDF_SHARED_CHILD SD flags.
>
> 1 sd = lowest_flag_domain(cpu, SD_NUMA);
> 2 sd = lowest_flag_domain(cpu, *SD_ASYM_CPUCAPACITY*);
>
> 1 sd = highest_flag_domain(cpu, SD_SHARE_PKG_RESOURCES);
> 2 sd = highest_flag_domain(cpu, SD_ASYM_PACKING);
Spot on!
In some of my earliest instrumentation patches I had a SCHED_WARN_ON() for
when highest_flag_domain() is passed an SDF_SHARED_PARENT flag (for some
reason I don't have the equivalent for lowest_flag_domain() in that
branch). I had ditched that as it didn't seem that useful, but perhaps that
wasn't so accurate :)