Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp637660pxu; Tue, 6 Oct 2020 15:25:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHzo3qwPA0vlY+SkI3PGhZRgftp8eJdZXJt50vXHLaVk1wk8d6DTtzAd+9aWj+rMwveFhL X-Received: by 2002:a17:906:f106:: with SMTP id gv6mr208500ejb.411.1602023157760; Tue, 06 Oct 2020 15:25:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602023157; cv=none; d=google.com; s=arc-20160816; b=ozk/9egvKLNDmFgphr5+V90Z6vFAWUXNASqU/iJPliVELSmXjdplK9PLcQm9oulY1H kJ5QrBJDOvjwGkYFR7ziKaKTsSHLoQPQxshn9VVTeTVB+sg5ippaMm8g29u6XQwaPv/T lFYFoLX4+555TfWkyaSGtTj1YIw4VXnbDmR43JWISXVQldGbCRc6eeZ+kpvcl0qcB1cg oeyjsDqvjY22fYltR+O4B7Xwrox/fOV6oyK4/EIKWaDtl36pu0jpaPlc+XJX5BKkE6nJ DmlS3Zdo57nMjkd2JgnP6rwgAZ+dVm5hzNt7YHLXpqGEPHZd0YRXSH9+I7WmdYflCarS AqLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=YtSRwzMs/DU75jsdFmdNaaDhmJIRnHlxUbgbKMKk33U=; b=0yJkVLpsoJu8DeWo63t4qyToWjFqYEo6qzAZNrdMNkDcqVMEfbBX1P2v36Wmxy+e7i ZWlJ4pxj6g3VvlVf7zbXuJd/IXzijjsQsCZ3tannw9z7PDrYzDxMNWtALKA0hjpCm7dt hH1kld9YAGu5qWmQvM5oBfoD98n26nYRtcAcBIg8GlLp3zb/vP5qtVubY5hXSlLgvZAM +WDiq1IEmn5QrWxQQGdQtOIC/YBAt/S81OkNo2MJ9Hl86rWeqTXMmWpQHXwTKQLBKA8S kS8uWh/RedgbCC8F7/DR1J4HZwQAwiA/Dq9+a9C5lIbnQ6efWdM+ct+PxrzPUvmWlcfu NJ1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s12si3325973edy.583.2020.10.06.15.25.22; Tue, 06 Oct 2020 15:25:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbgJFTef (ORCPT + 99 others); Tue, 6 Oct 2020 15:34:35 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:46470 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727013AbgJFTef (ORCPT ); Tue, 6 Oct 2020 15:34:35 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 8A4F71C0B8C; Tue, 6 Oct 2020 21:34:32 +0200 (CEST) Date: Tue, 6 Oct 2020 21:34:32 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Stefan Hajnoczi , "Michael S. Tsirkin" , Stefano Garzarella , "David S. Miller" , Sasha Levin Subject: Re: [PATCH 4.19 07/38] vsock/virtio: stop workers during the .remove() Message-ID: <20201006193432.GA8771@duo.ucw.cz> References: <20201005142108.650363140@linuxfoundation.org> <20201005142109.015282314@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0OAP2g/MAC+5xKAE" Content-Disposition: inline In-Reply-To: <20201005142109.015282314@linuxfoundation.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0OAP2g/MAC+5xKAE Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit 17dd1367389cfe7f150790c83247b68e0c19d106 ] >=20 > Before to call vdev->config->reset(vdev) we need to be sure that > no one is accessing the device, for this reason, we add new variables > in the struct virtio_vsock to stop the workers during the .remove(). >=20 > This patch also add few comments before vdev->config->reset(vdev) > and vdev->config->del_vqs(vdev). > @@ -621,12 +645,18 @@ static int virtio_vsock_probe(struct virtio_device = *vdev) > INIT_WORK(&vsock->send_pkt_work, virtio_transport_send_pkt_work); > INIT_WORK(&vsock->loopback_work, virtio_transport_loopback_work); > =20 > + mutex_lock(&vsock->tx_lock); > + vsock->tx_run =3D true; > + mutex_unlock(&vsock->tx_lock); > + > mutex_lock(&vsock->rx_lock); > virtio_vsock_rx_fill(vsock); > + vsock->rx_run =3D true; > mutex_unlock(&vsock->rx_lock); > =20 > mutex_lock(&vsock->event_lock); > virtio_vsock_event_fill(vsock); > + vsock->event_run =3D true; > mutex_unlock(&vsock->event_lock); > This looks like some kind of voodoo code. Locks are just being allocated few lines above, so there are no other threads accessing *vsock. That means we don't need to take the locks... right? At least taking the tx_lock is unneccessary, but probably the others, too... Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --0OAP2g/MAC+5xKAE Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCX3zGyAAKCRAw5/Bqldv6 8jNjAJ0RTOmJL0/XsF4TzsN7iRY3oV27BgCfWmZs7mVTfHnYOW/ctdkYm62Rv1I= =1+CH -----END PGP SIGNATURE----- --0OAP2g/MAC+5xKAE--