fix: 修复处理器缓存显示与 lscpu 不一致 (#373521) - #734
Conversation
1. 修复处理器头部缓存按实例数累加导致与 lscpu 显示不一致的问题; 2. 将 calAndSetCpuHeaderInfo 中 L1d/L1i/L2/L3 缓存改为展示单实例大小; 3. 新增 Common::formatCacheSize 用于单实例缓存大小单位归一化(KiB/MiB/GiB); 4. 移除不再使用的 Common::formatTotalCache 与 Common::parseSharedCpuCount; ===================================== 1. fix processor header cache being multiplied by instance count, which mismatched lscpu output; 2. show single-instance cache size for L1d/L1i/L2/L3 in calAndSetCpuHeaderInfo; 3. add Common::formatCacheSize to normalize single-instance cache size (KiB/MiB/GiB); 4. remove unused Common::formatTotalCache and Common::parseSharedCpuCount; Log: 修复设备管理器处理器页面顶部缓存显示与终端 lscpu 不一致的问题,改为显示单实例缓存大小,与 lscpu 口径对齐 Bug: https://pms.uniontech.com/bug-view-373521.html
There was a problem hiding this comment.
Sorry @GongHeng2017, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideCPU header cache display is changed to show per-instance cache sizes aligned with lscpu, by replacing the previous total-cache calculation utility with a new unit-normalization helper and removing unused shared-CPU parsing logic. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,以下为针对重复代码的进一步优化建议示例(非必须)
// DeviceGenerator.cpp 中的优化方向
void DeviceGenerator::appendCacheInfo(const QMap<QString, QString> &info,
const QString &key,
QList<QPair<QString, QString>> &outList)
{
if (info.contains(key)) {
QString formattedSize = Common::formatCacheSize(info.value(key));
if (!formattedSize.isEmpty()) {
outList.push_back(qMakePair(tr(key.toUtf8().constData()), formattedSize));
}
}
}
// 调用处简化为:
// appendCacheInfo(firstProcessorInfo, "L1d cache", singleCpuHeaderInfo);
// appendCacheInfo(firstProcessorInfo, "L1i cache", singleCpuHeaderInfo);
// appendCacheInfo(firstProcessorInfo, "L2 cache", singleCpuHeaderInfo);
// appendCacheInfo(firstProcessorInfo, "L3 cache", singleCpuHeaderInfo); |
修复:设备管理器-处理器缓存与 lscpu 显示不一致(PMS Bug 373521)
问题
设备管理器「处理器」页面顶部头部的 L1d/L1i/L2/L3 缓存显示与终端
lscpu不一致:头部把单实例缓存按实例数累加成总量展示,而lscpu展示单实例大小。多核机型上每核私有缓存(L1d/L1i/L2)相差 N 倍(N=核数),L3 因被全部逻辑核共享(实例数=1)恰好一致。实测(Loongson-3A6000,4 核/8 逻辑):头部显示
L1d=256 KiB / L1i=256 KiB / L2=1 MiB / L3=16 MiB,lscpu 显示单实例64 KiB / 64 KiB / 256 KiB / 16 MiB,L1d/L1i/L2 差 4 倍。根因
DeviceGenerator::calAndSetCpuHeaderInfo(DeviceGenerator.cpp)对 L1d/L1i/L2/L3 调用Common::formatTotalCache(单实例值, groupCount),groupCount = logicalNum / sharedCount,把单实例大小 ×实例数累加后展示。Common::formatTotalCache(commonfunction.cpp)关键乘法totalKiB = perCoreKiB * coreCount。修复
× groupCount累加。Common::formatCacheSize(cacheSize):单实例缓存大小单位归一化(KiB/MiB/GiB),复用原解析/归一化逻辑但去掉乘法。Common::formatTotalCache与Common::parseSharedCpuCount(全仓仅此 4 处调用,已确认无其它引用/测试依赖)。改动文件
deepin-devicemanager/src/GenerateDevice/DeviceGenerator.cpp— 4 个缓存块改用formatCacheSize,移除 sharedCount/groupCount 计算deepin-devicemanager/src/commonfunction.cpp—formatTotalCache→formatCacheSize(去乘法),移除parseSharedCpuCountdeepin-devicemanager/src/commonfunction.h— 声明同步验证
-Wall,0 error / 0 warning)。nm符号校验:formatCacheSize已定义并被引用,无formatTotalCache/parseSharedCpuCount残留符号。private/qzipreader_p.h,与本次改动无关)未完成链接,但改动 TU 编译验证通过。行为对比
Bug: https://pms.uniontech.com/bug-view-373521.html
Summary by Sourcery
Align processor cache information in the device manager header with single-instance cache sizes reported by lscpu.
Bug Fixes:
Enhancements: