Skip to content

Commit

Permalink
mm: remove misleading 'unlikely' hint in vms_gather_munmap_vmas()
Browse files Browse the repository at this point in the history
Performance analysis using branch annotation on a fleet of 200 hosts
running web servers revealed that the 'unlikely' hint in
vms_gather_munmap_vmas() was 100% consistently incorrect.  In all observed
cases, the branch behavior contradicted the hint.

Remove the 'unlikely' qualifier from the condition checking 'vms->uf'.  By
doing so, we allow the compiler to make optimization decisions based on
its own heuristics and profiling data, rather than relying on a static
hint that has proven to be inaccurate in real-world scenarios.

Link: https://lkml.kernel.org/r/20241004164832.218681-1-leitao@debian.org
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Breno Leitao authored and Andrew Morton committed Nov 7, 2024
1 parent b314e21 commit 04f315a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ int vms_gather_munmap_vmas(struct vma_munmap_struct *vms,
else if (is_data_mapping(next->vm_flags))
vms->data_vm += nrpages;

if (unlikely(vms->uf)) {
if (vms->uf) {
/*
* If userfaultfd_unmap_prep returns an error the vmas
* will remain split, but userland will get a
Expand Down

0 comments on commit 04f315a

Please sign in to comment.