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 7E1A142B12; Mon, 15 May 2023 13:23:09 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B74B40A80; Mon, 15 May 2023 13:23:09 +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 78B7140395 for ; Mon, 15 May 2023 13:23:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684149786; 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=QyG0mYWHd6eXqgiqCHr6DFyYuW7NJ6MHEoVMyJbtTJV5NaHfRCLjgj0LPnKMawiIGd1tU3 1RSNOI3VEh0NsfTpVWC6dKwEr+ysEcoEmuGd9IowUR30A7MKrf+vpBAKvHtd8Khi0yHt/w DSOuSJ7Xr4CCbDaQ5irE+VGeNDwWpfc= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-311-nIhzwHnAMdiGRozyYrJtgQ-1; Mon, 15 May 2023 07:23:05 -0400 X-MC-Unique: nIhzwHnAMdiGRozyYrJtgQ-1 Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-24e40246bb6so6713016a91.0 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=ggLnWTvOcBoZicX/Y2GOkeatUpKwEyWgsfCSDwN/KLPRX4gmfAJT40z45ichqVMSvf Pn1ttUiBiTH27KY17oQt3rpxb9Y+zlfGD3R03xOI8H22aGpnfExriOdGnuQEK/BXfTqG Y93SNRNvydlkSMa5Q4Iqc91GEAuBiWS/0fCnQxYcLPqidIsQAKeav18t3pVPicGWutdX X4EEC7bMX4Z02LoM96Qec+FCRdceueIKGmWV3QT7fFUcPqVF/Ha7cPJi/11LPwt/9Eky 1x1GpNoQlZI5gtM6YXD0VJ+3kJVuZ95EbDfV0v4J6fGl3toow/NhT6eSIh9VCRyQpMNK CxLw== X-Gm-Message-State: AC+VfDxNRVIugQNBtSllqU/N8AzyhyBO2XEdNOH4cktsRtxc5ri6VfG7 l58Fu+eNnPUrFNhmKi9QovIkDTKS92JaoHSzF6Vvm01mVbyugArlYGCqkwgxYM0fde3VA6ICijA AT25g4NU1+emsPNr677M= X-Received: by 2002:a17:90a:f2c7:b0:246:5968:43f0 with SMTP id gt7-20020a17090af2c700b00246596843f0mr33789303pjb.10.1684149784703; 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: 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 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