Skip to content

Commit 41f3ab2

Browse files
committed
Merge tag 'driver-core-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here are two small driver core cacheinfo fixes for 6.4-rc5 that resolve a number of reported issues with that file. These changes have been in linux-next this past week with no reported problems" * tag 'driver-core-6.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: drivers: base: cacheinfo: Update cpu_map_populated during CPU Hotplug drivers: base: cacheinfo: Fix shared_cpu_map changes in event of CPU hotplug
2 parents 12c2f77 + c26fabe commit 41f3ab2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

drivers/base/cacheinfo.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,16 @@ static int cache_shared_cpu_map_setup(unsigned int cpu)
388388
continue;/* skip if itself or no cacheinfo */
389389
for (sib_index = 0; sib_index < cache_leaves(i); sib_index++) {
390390
sib_leaf = per_cpu_cacheinfo_idx(i, sib_index);
391+
392+
/*
393+
* Comparing cache IDs only makes sense if the leaves
394+
* belong to the same cache level of same type. Skip
395+
* the check if level and type do not match.
396+
*/
397+
if (sib_leaf->level != this_leaf->level ||
398+
sib_leaf->type != this_leaf->type)
399+
continue;
400+
391401
if (cache_leaves_are_shared(this_leaf, sib_leaf)) {
392402
cpumask_set_cpu(cpu, &sib_leaf->shared_cpu_map);
393403
cpumask_set_cpu(i, &this_leaf->shared_cpu_map);
@@ -400,11 +410,14 @@ static int cache_shared_cpu_map_setup(unsigned int cpu)
400410
coherency_max_size = this_leaf->coherency_line_size;
401411
}
402412

413+
/* shared_cpu_map is now populated for the cpu */
414+
this_cpu_ci->cpu_map_populated = true;
403415
return 0;
404416
}
405417

406418
static void cache_shared_cpu_map_remove(unsigned int cpu)
407419
{
420+
struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu);
408421
struct cacheinfo *this_leaf, *sib_leaf;
409422
unsigned int sibling, index, sib_index;
410423

@@ -419,6 +432,16 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
419432

420433
for (sib_index = 0; sib_index < cache_leaves(sibling); sib_index++) {
421434
sib_leaf = per_cpu_cacheinfo_idx(sibling, sib_index);
435+
436+
/*
437+
* Comparing cache IDs only makes sense if the leaves
438+
* belong to the same cache level of same type. Skip
439+
* the check if level and type do not match.
440+
*/
441+
if (sib_leaf->level != this_leaf->level ||
442+
sib_leaf->type != this_leaf->type)
443+
continue;
444+
422445
if (cache_leaves_are_shared(this_leaf, sib_leaf)) {
423446
cpumask_clear_cpu(cpu, &sib_leaf->shared_cpu_map);
424447
cpumask_clear_cpu(sibling, &this_leaf->shared_cpu_map);
@@ -427,6 +450,9 @@ static void cache_shared_cpu_map_remove(unsigned int cpu)
427450
}
428451
}
429452
}
453+
454+
/* cpu is no longer populated in the shared map */
455+
this_cpu_ci->cpu_map_populated = false;
430456
}
431457

432458
static void free_cache_attributes(unsigned int cpu)

0 commit comments

Comments
 (0)