@@ -2140,25 +2140,32 @@ static int evlist__cmp(void *state, const struct list_head *l, const struct list
2140
2140
int * leader_idx = state ;
2141
2141
int lhs_leader_idx = * leader_idx , rhs_leader_idx = * leader_idx , ret ;
2142
2142
const char * lhs_pmu_name , * rhs_pmu_name ;
2143
+ bool lhs_has_group = false, rhs_has_group = false;
2143
2144
2144
2145
/*
2145
2146
* First sort by grouping/leader. Read the leader idx only if the evsel
2146
2147
* is part of a group, as -1 indicates no group.
2147
2148
*/
2148
- if (lhs_core -> leader != lhs_core || lhs_core -> nr_members > 1 )
2149
+ if (lhs_core -> leader != lhs_core || lhs_core -> nr_members > 1 ) {
2150
+ lhs_has_group = true;
2149
2151
lhs_leader_idx = lhs_core -> leader -> idx ;
2150
- if (rhs_core -> leader != rhs_core || rhs_core -> nr_members > 1 )
2152
+ }
2153
+ if (rhs_core -> leader != rhs_core || rhs_core -> nr_members > 1 ) {
2154
+ rhs_has_group = true;
2151
2155
rhs_leader_idx = rhs_core -> leader -> idx ;
2156
+ }
2152
2157
2153
2158
if (lhs_leader_idx != rhs_leader_idx )
2154
2159
return lhs_leader_idx - rhs_leader_idx ;
2155
2160
2156
- /* Group by PMU. Groups can't span PMUs. */
2157
- lhs_pmu_name = evsel__group_pmu_name (lhs );
2158
- rhs_pmu_name = evsel__group_pmu_name (rhs );
2159
- ret = strcmp (lhs_pmu_name , rhs_pmu_name );
2160
- if (ret )
2161
- return ret ;
2161
+ /* Group by PMU if there is a group. Groups can't span PMUs. */
2162
+ if (lhs_has_group && rhs_has_group ) {
2163
+ lhs_pmu_name = evsel__group_pmu_name (lhs );
2164
+ rhs_pmu_name = evsel__group_pmu_name (rhs );
2165
+ ret = strcmp (lhs_pmu_name , rhs_pmu_name );
2166
+ if (ret )
2167
+ return ret ;
2168
+ }
2162
2169
2163
2170
/* Architecture specific sorting. */
2164
2171
return arch_evlist__cmp (lhs , rhs );
0 commit comments