lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJSP0QWrqb9m0jY00xvxz+Mfsi+UtE-D_Q5TE45RCKbS_ZkgZg@mail.gmail.com>
Date: Sun, 15 Jun 2025 09:28:40 -0400
From: Stefan Hajnoczi <stefanha@...il.com>
To: lirongqing <lirongqing@...du.com>
Cc: vgoyal@...hat.com, stefanha@...hat.com, miklos@...redi.hu, 
	eperezma@...hat.com, virtualization@...ts.linux.dev, 
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virtio_fs: Remove redundant spinlock in virtio_fs_request_complete()

On Fri, Jun 13, 2025 at 1:51 AM lirongqing <lirongqing@...du.com> wrote:
>
> From: Li RongQing <lirongqing@...du.com>
>
> Since clear_bit is an atomic operation, the spinlock is redundant and
> can be removed, reducing lock contention is good for performance.
>
> Signed-off-by: Li RongQing <lirongqing@...du.com>
> ---
>  fs/fuse/virtio_fs.c | 2 --
>  1 file changed, 2 deletions(-)

The spin lock originally protected req->list, so the lock has no use here.

The initial req->list access is still protected by fpq->lock in
virtio_fs_requests_done_work():
  while ((req = virtqueue_get_buf(vq, &len)) != NULL) {
      spin_lock(&fpq->lock);
      list_move_tail(&req->list, &reqs);
      spin_unlock(&fpq->lock);
  }

Looks safe, but please see the kernel test robot email about an unused
variable warning.

Reviewed-by: Stefan Hajnoczi <stefanha@...hat.com>

>
> diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
> index 8f2e2f3..de34179 100644
> --- a/fs/fuse/virtio_fs.c
> +++ b/fs/fuse/virtio_fs.c
> @@ -791,9 +791,7 @@ static void virtio_fs_request_complete(struct fuse_req *req,
>                 }
>         }
>
> -       spin_lock(&fpq->lock);
>         clear_bit(FR_SENT, &req->flags);
> -       spin_unlock(&fpq->lock);
>
>         fuse_request_end(req);
>         spin_lock(&fsvq->lock);
> --
> 2.9.4
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ