aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiapeng Chong <[email protected]>2024-05-31 17:16:43 +0800
committerAndrew Morton <[email protected]>2024-07-03 19:30:03 -0700
commit37a4b34ac92aae258a08c23f255356746ded0571 (patch)
treec3c7cec7075beddf848f543e1a540a0ff2ce3e1e
parentfe91eca6802c139367ee4e4a09907fe929bb552f (diff)
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/[email protected] Signed-off-by: Jiapeng Chong <[email protected]> Reported-by: Abaci Robot <[email protected]> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9266 Reviewed-by: David Hildenbrand <[email protected]> Reviewed-by: Wei Yang <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/userfaultfd.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index defa5109cc62..5e7f2801698a 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -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)