summaryrefslogtreecommitdiff
path: root/scripts/const_structs.checkpatch
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2026-05-28 15:40:43 +0300
committerSean Christopherson <seanjc@google.com>2026-05-28 16:09:24 +0300
commitc3647e582e1563d27896c62686d88db76c6cd3a6 (patch)
treebc70f99bd13d2e1579f22cbaee4dfb0d798ca4f5 /scripts/const_structs.checkpatch
parentf92d4f74de4fd6b233929a47f6bb89536c6274c8 (diff)
downloadlinux-c3647e582e1563d27896c62686d88db76c6cd3a6.tar.xz
KVM: x86: Use fls() instead of ffs() for rmaps histogram bucketing
The kvm_mmu_rmaps_stat_show() function implements a logarithmic histogram to collect statistics on the distribution of pte_list_count sizes. However, it currently uses ffs() (Find First Set), which looks for the least significant set bit. Using ffs() leads to severe statistical distortion for any count that is not a power of two. For example, if a rmap has a pte_list_count of 6 (binary 0110), ffs(6) returns 2, forcing this entry to be erroneously counted towards the bucket representing a count of 2. In contrast, it conceptually belongs to the bucket spanning the 4 to 7 range. Replace ffs() with fls() (Find Last Set) to correctly identify the most significant set bit (effectively computing floor(log2(count)) + 1). This Ensure that intermediate counts are correctly categorized into their appropriate power-of-two order-of-magnitude buckets rather than being severely under-reported. Fixes: 3bcd0662d66f ("KVM: X86: Introduce mmu_rmaps_stat per-vm debugfs file") Signed-off-by: Li RongQing <lirongqing@baidu.com> Link: https://patch.msgid.link/20260528124043.2153-1-lirongqing@baidu.com Signed-off-by: Sean Christopherson <seanjc@google.com>
Diffstat (limited to 'scripts/const_structs.checkpatch')
0 files changed, 0 insertions, 0 deletions