linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
	akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Abaci Robot <abaci@linux.alibaba.com>
Subject: Re: [PATCH] mm: userfaultfd: Use swap() in double_pt_lock()
Date: Fri, 31 May 2024 12:02:12 +0200	[thread overview]
Message-ID: <f073e363-f6b2-41df-84b3-4b2cfa2267a8@redhat.com> (raw)
In-Reply-To: <20240531091643.67778-1-jiapeng.chong@linux.alibaba.com>

On 31.05.24 11:16, Jiapeng Chong wrote:
> Use existing swap() function rather than duplicating its implementation.
> 
> ./mm/userfaultfd.c:1006:13-14: WARNING opportunity for swap()
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9266
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>   mm/userfaultfd.c | 10 ++--------
>   1 file 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)

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2024-05-31 10:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-31  9:16 Jiapeng Chong
2024-05-31 10:02 ` David Hildenbrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f073e363-f6b2-41df-84b3-4b2cfa2267a8@redhat.com \
    --to=david@redhat.com \
    --cc=abaci@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox