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 AF015A0543; Tue, 6 Sep 2022 23:15:42 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FC6C400D6; Tue, 6 Sep 2022 23:15:42 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id B827A40042 for ; Tue, 6 Sep 2022 23:15:41 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id t11-20020a17090a510b00b001fac77e9d1fso16218198pjh.5 for ; Tue, 06 Sep 2022 14:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date; bh=gnLbVYjb62j96kjBXH4Mrzl/80fnk+Tiw4LdSFSs4VE=; b=UY3IQ08iZHHnWB5A7ux1+C/X6c4s4W+Vja9dtQoF7NPngJqoMFw51gKGfDvc+NvWE8 /4qXAzm5efbAb+nxuAPVvFfJP50vxbeALYFsVIZHGjDYup1WAheN9qoVOR9QXGC0BUka 9oO4iCRQuH9l70WH1HHv5btDSfH6rg1Q2jOqHqjcqOpJjJUE2LxB/aqyLjiVDtXxBxfB 4sQ+c58GyqHcx9i3xkI1J4GgUEdDmfNIGSnlAprSlaIq9OJ9ddPRhOmp+TnPjZ3R2PsJ iHFnmFfj+84Ep0GiI1ZUpV0iTOL8HPxvBJa4A6mXwmXzHIQa/kk/S1jMbAF0V4hjyhjM GuZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date; bh=gnLbVYjb62j96kjBXH4Mrzl/80fnk+Tiw4LdSFSs4VE=; b=QEY/Co0RtI9nqAm5UqdT3H34jC6Vchsfo4gzembijCYCOwGP/nF+ZWJzgQRReyRD10 ngGr8WEaUbgMnD2f7/Bvl7uuT7Qcqbq1k2xIUcmbXJJaxnxCSGJSeOdVgAlqfEEuNBGi Rks1hAXVqCPYA5np+is1KWC0pBISVYHgBVE/YUqKq22vUtAn/MqG138M4T0oCghQnXJ7 WrE+YqBMLhi9FtIcGsp/aUf9oLBWeY6nXR7CdOemZuw5PKcEBfgtPL/H/mPV8Rm9c+4t wZHH3uQUwF6ac+BK+63AzVmF6HYHuw9u1EJfxEBsoSppbkRSrmT5gnSA41wj8ot9iX57 Ko/Q== X-Gm-Message-State: ACgBeo09UKPNQVsIIwfh2PAYjTfyfBhqXmtnksrhLubct9XkJJxuLx+U D9vkIzwmK6kWtoZARGzhUH6myQ== X-Google-Smtp-Source: AA6agR4vOmzGuTzUCNx6n8M9nj0CME4G/lLzGyTM8fKYl8scg5o4BYyQc3E5co+NXNr/QtrcYFkPTg== X-Received: by 2002:a17:902:ec88:b0:175:d8f:44b with SMTP id x8-20020a170902ec8800b001750d8f044bmr423046plg.84.1662498940710; Tue, 06 Sep 2022 14:15:40 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id y14-20020a63b50e000000b0042bf6034b3fsm9166103pge.55.2022.09.06.14.15.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 14:15:40 -0700 (PDT) Date: Tue, 6 Sep 2022 14:15:38 -0700 From: Stephen Hemminger To: Changpeng Liu Cc: dev@dpdk.org, Maxime Coquelin , Chenbo Xia Subject: Re: [PATCH] vhost: use try_lock in rte_vhost_vring_call Message-ID: <20220906141538.7aa0876b@hermes.local> In-Reply-To: <20220906022225.17215-1-changpeng.liu@intel.com> References: <20220906022225.17215-1-changpeng.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Tue, 6 Sep 2022 10:22:25 +0800 Changpeng Liu wrote: > Note that this function is in data path, so the thread context > may not same as socket messages processing context, by using > try_lock here, users can have another try in case of VQ's access > lock is held by `vhost-events` thread. > > Signed-off-by: Changpeng Liu > --- > lib/vhost/vhost.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c > index 60cb05a0ff..072d2acb7b 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1329,7 +1329,11 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx) > if (!vq) > return -1; > > - rte_spinlock_lock(&vq->access_lock); > + if (!rte_spinlock_trylock(&vq->access_lock)) { > + VHOST_LOG_CONFIG(dev->ifname, DEBUG, > + "failed to kick guest, virtqueue busy.\n"); > + return -1; > + } > If it is a race, logging a message is not a good idea; the log will fill with this noise. Instead make it statistic that can be seen by xstats.