From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2F656A0501; Mon, 28 Mar 2022 14:18:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C5DAD427EA; Mon, 28 Mar 2022 14:18:14 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 5293E41104 for ; Mon, 28 Mar 2022 14:18:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648469892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=+l1/bnJXFoTriKp5745kk/dpg7pUEsvhBY47ncN9ksg=; b=Lgxcnmm7hG3zwghXxrAD8EqHIR63P4FF+oL+xEUNbkNF/qmanspg+myctCxeE5yV0y8J+L aJ03EGEXA1Xdvc8cDyQOpAxXTUMBs0rDzwSYQWzAXZoIFOrSd7nhaxoz500sgUm8YEt+lp i1ZHeETnAmEW3ZmvP/e76fEji93fMPM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-632-MyrQU609N66GYtlqyfOeqw-1; Mon, 28 Mar 2022 08:18:09 -0400 X-MC-Unique: MyrQU609N66GYtlqyfOeqw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 469E4811E76; Mon, 28 Mar 2022 12:18:09 +0000 (UTC) Received: from dmarchan.remote.csb (unknown [10.40.195.27]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BDB0C15D58; Mon, 28 Mar 2022 12:18:06 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com Subject: [RFC PATCH 0/5] vhost lock annotations Date: Mon, 28 Mar 2022 14:17:53 +0200 Message-Id: <20220328121758.26632-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david.marchand@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org vhost internals involves multiple locks to protect data access by multiple threads. This series is a try at using clang thread safety checks [1] to catch issues during compilation: spinlock and rwlock are wrapped into vhost types and annotations are put all over the code. Patch 1 is a fix from Maxime that I had to take in the series so that the CI won't fail. Patch 2 annotates existing manipulations of the access_lock vq lock. It does the minimal stuff, more annotations are used/introduced later in the series. Patch 4 is an example of extending the work by annotating the async field. This patch raised the issues fixed in patch 3. Patch 5 further extends this by annotating rwlocks used in IOTLB. This raised two suspicious call sites (in vdpa and vhost_crypto code, see added FIXME). Because of a limitation in the check, the IOTLB lock is changed to be always taken. I don't expect a big impact, but this needs a confirmation. This is still a work in progress. Those annotations are quite heavy to maintain because the full path of code must be annotated, but I think it would be worth using. 1: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html -- David Marchand David Marchand (4): vhost: annotate virtqueue access lock vhost: fix async access vhost: annotate async locking requirement vhost: annotate IOTLB locks Maxime Coquelin (1): vhost: fix missing virtqueue lock protection lib/vhost/iotlb.c | 36 ++++----- lib/vhost/iotlb.h | 24 ------ lib/vhost/meson.build | 3 + lib/vhost/vdpa.c | 1 + lib/vhost/vhost.c | 85 ++++++++++---------- lib/vhost/vhost.h | 169 +++++++++++++++++++++++++++++++++++---- lib/vhost/vhost_crypto.c | 7 ++ lib/vhost/vhost_user.c | 32 +++++--- lib/vhost/virtio_net.c | 96 ++++++++++++++++------ 9 files changed, 320 insertions(+), 133 deletions(-) -- 2.23.0