Commit 37a4b34a authored by Jiapeng Chong's avatar Jiapeng Chong Committed by Andrew Morton
Browse files

mm: userfaultfd: use swap() in double_pt_lock()

Use existing swap() function rather than duplicating its implementation.

./mm/userfaultfd.c:1006:13-14: WARNING opportunity for swap()

Link: https://lkml.kernel.org/r/20240531091643.67778-1-jiapeng.chong@linux.alibaba.com


Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9266


Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarWei Yang <richard.weiyang@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent fe91eca6
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -995,14 +995,8 @@ void double_pt_lock(spinlock_t *ptl1,
	__acquires(ptl1)
	__acquires(ptl2)
{
	spinlock_t *ptl_tmp;

	if (ptl1 > ptl2) {
		/* exchange ptl1 and ptl2 */
		ptl_tmp = ptl1;
		ptl1 = ptl2;
		ptl2 = ptl_tmp;
	}
	if (ptl1 > ptl2)
		swap(ptl1, ptl2);
	/* lock in virtual address order to avoid lock inversion */
	spin_lock(ptl1);
	if (ptl1 != ptl2)