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 7598042B12 for ; Mon, 15 May 2023 13:23:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 705B641101; Mon, 15 May 2023 13:23:10 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 522A140395 for ; Mon, 15 May 2023 13:23:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684149788; 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: in-reply-to:in-reply-to:references:references; bh=fiY8dHdK88r9XZwl1r5QLqMICj1o2JR90EP//nybtzg=; b=dgBZ1wX1A78II4trB1NWn+V4sNQWLu9Cm9e0yUQ/I0C3DXu++Xy4KZ3aNQP8iA4Lkm+OBi NwEYDsJV8uCBb5fAS1/xSVpHkHuFiz+vK2KXp5St0NO9pOswgzzPVhWh30UvcWCXo/tohW A9W8QiFCFskivLUtBWKVITz17lV8sLQ= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-87kBFehJPFSz_nuCDnZ50w-1; Mon, 15 May 2023 07:23:05 -0400 X-MC-Unique: 87kBFehJPFSz_nuCDnZ50w-1 Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-24e0d569a01so6707547a91.2 for ; Mon, 15 May 2023 04:23:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684149784; x=1686741784; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fiY8dHdK88r9XZwl1r5QLqMICj1o2JR90EP//nybtzg=; b=bTCeMqbs/r6uJHfpgQEJJp5jNZsqyZRDLBuQP+RiJraZloP+34FNEf/VQNRr1ckDIL hmoz5jFQspuZuPxhOlCMO9TAy3TqgiW7Ia1LfSo26ykL4v8Nnz7r4Ya9AVbbl+Zkz3K/ QPCX/1xZcraOq5IckdMkhA8VWwHggdcWfWDeKK8gmP090fIZ4DtK+PAQ5J5A8zsCAZW/ oHBXv35/Tap1Vzgi+416XqID+ZdPJB52wrJ5UWp70/lkLuLKoKPR1C5TaUwBYqkNm3sb LdkXMnIDDNq1e8t26WQLOJwQRcZhRQLVZFWL2sGfcJT/KqgfmvtxSsIVoLAcORmBKKRS Ob9g== X-Gm-Message-State: AC+VfDxSDzkal486tEQyyTaze389XvBqUutVNmteVKemOmViNj9Tyop9 fV/b3gTEWuPQyQvRjtu9zlCgljKaq9usxp7Hk/1iqDEK78Aj5o6x5ZNN8823EDhjTrJDkcDy/0o sHX01JPHbWybl2GBqhSijMDw= X-Received: by 2002:a17:90a:f2c7:b0:246:5968:43f0 with SMTP id gt7-20020a17090af2c700b00246596843f0mr33789305pjb.10.1684149784704; Mon, 15 May 2023 04:23:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qpFysQxvxbYwQlXpddTDQ9vsj5jLPcgsFGihkEwB8FWU6m83RIgA4vbGBEx06zgfPVca8mpvnXrmyPBAIfro= X-Received: by 2002:a17:90a:f2c7:b0:246:5968:43f0 with SMTP id gt7-20020a17090af2c700b00246596843f0mr33789290pjb.10.1684149784425; Mon, 15 May 2023 04:23:04 -0700 (PDT) MIME-Version: 1.0 References: <20230322170524.2314715-1-david.marchand@redhat.com> In-Reply-To: From: David Marchand Date: Mon, 15 May 2023 13:22:53 +0200 Message-ID: Subject: Re: [PATCH] vhost: avoid sleeping under mutex To: "Xia, Chenbo" Cc: "dev@dpdk.org" , "stable@dpdk.org" , Maxime Coquelin , Yuanhan Liu X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Thu, May 11, 2023 at 10:10=E2=80=AFAM Xia, Chenbo = wrote: > > Covscan reported: > > > > 2. dpdk-21.11/lib/vhost/socket.c:852: lock_acquire: Calling function > > "pthread_mutex_lock" acquires lock "vhost_user.mutex". > > 23. dpdk-21.11/lib/vhost/socket.c:955: sleep: Call to > > "vhost_user_reconnect_init" might sleep while holding lock > > "vhost_user.mutex". > > # 953| vsocket->reconnect =3D > > !(flags & RTE_VHOST_USER_NO_RECONNECT); > > # 954| if (vsocket->reconnect && reconn_tid =3D=3D 0) { > > # 955|-> if (vhost_user_reconnect_init() !=3D 0) > > # 956| goto out_mutex; > > # 957| } > > > > The reason for this warning is that vhost_user_reconnect_init() creates= a > > ctrl thread and calls nanosleep waiting for this thread to be ready, > > while vhost_user.mutex is taken. > > > > Move the call to vhost_user_reconnect_init() out of this mutex. > > > > While at it, a pthread_t value should be considered opaque. > > Instead of relying reconn_tid =3D=3D 0, use an internal flag in > > vhost_user_reconnect_init(). > > Should we make reconn_tid not a global variable anymore then? > Maybe a static pthread_t in vhost_user_reconnect_init? Yep, I just sent a v2. Thanks Chenbo. --=20 David Marchand