mm: userfaultfd: Use swap() in double_pt_lock()
Subsystems (2)
PATCH 1/1 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()
Reported-by Abaci Robot <[email protected]>
Signed-off-by Jiapeng Chong <[email protected]>
--- mm/userfaultfd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
mm/userfaultfd.c +2 -8
@@ -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)
Signature · 1 line
2.20.1.7.g153144c
Quoted 22 lines · Jiapeng Chong
Use existing
swap()function rather than duplicating its implementation../mm/userfaultfd.c:1006:13-14: WARNING opportunity for
swap()Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>--- mm/userfaultfd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)mm/userfaultfd.c +0
-3@@ -995,14 +995,8 @@ void double_pt_lock(spinlock_t *ptl1,__acquires (ptl1)__acquires (ptl2 ) { -spinlock_t *ptl_tmp; - -if (ptl1 > ptl2) {
mm/userfaultfd.c void double_pt_lock(spinlock_t *ptl1, · line 1002
Quoted 10 lines
mm/userfaultfd.c +2
-5-/* 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)
Reviewed-by David Hildenbrand <[email protected]>
Signature · 3 lines
Cheers, David / dhildenb
Quoted 7 lines · Jiapeng Chong
Use existing
swap()function rather than duplicating its implementation./mm/userfaultfd.c:1006:13-14: WARNING opportunity for
swap()Reported-by Abaci Robot <[email protected]>Signed-off-by Jiapeng Chong <[email protected]>
Reviewed-by Wei Yang <[email protected]>
Signature · 2 lines
Wei Yang Help you, Help me