History

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

Linus Torvalds committed 3 years ago

Commit 41f3ab22 parents 12c2f77 c26fabe1 file · +26 −0Browse files

Unified · Split

drivers/base/cacheinfo.c+26−0
@@ -388,6 +388,16 @@ static int cache_shared_cpu_map_setup(unsigned int cpu) · 387 unmodified lines
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) · 6 unmodified lines
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) · 8 unmodified lines
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) · 2 unmodified lines
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)