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 6F023A0543; Thu, 7 Jul 2022 14:47:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2346E406B4; Thu, 7 Jul 2022 14:47:23 +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 3EB294069D for ; Thu, 7 Jul 2022 14:47:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657198041; 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=ZVh7S/Ql2E/MwFQlcis4nYqP7LDdk0XwWrZWwq7qx8U=; b=WN8qV1eJEqv0+cNo2u0S9iDfpe3QkLF8bEaNLA8gD2i5BYQRAh66YhcF0vz3uUyG5AMfEp 8QqdOcTSvBcItMevSr6InbDC/xwRqd9vELpxzjtJcAfu9+9cc9e1QditV3i+6bsFxYvPs2 Ob0xgpybEEDu+yXeSj6UK8X6XyfTXc0= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-qUE_na53PfeZgUwGKJB7gQ-1; Thu, 07 Jul 2022 08:47:20 -0400 X-MC-Unique: qUE_na53PfeZgUwGKJB7gQ-1 Received: by mail-qt1-f198.google.com with SMTP id m6-20020ac866c6000000b002f52f9fb4edso15351372qtp.19 for ; Thu, 07 Jul 2022 05:47:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ZVh7S/Ql2E/MwFQlcis4nYqP7LDdk0XwWrZWwq7qx8U=; b=nQbzxT/ANbjcqP5CXnQBExef0KgpLgm/Si1YBjzzPMeQAn/E4zJrDyFjz0MqVUyNdT uPEx6mEWvaPucuqSmJHHtPeT40IseL+sC/wpXwxJJWyOtexGiJJXvBFXO1qL9fCBNE7G 8fFEIRxfQhSOlk3IpOCk9P2xvNDpDGuTOMV34kz68qYmtq+AsXarhkUXLDfT255EHYAF N7nFkE5i2sqLz/tx5u0p+cwDRv48yqGMV4mPO8tcKxrXHwiczdwMX3/f77yWfYyd1JP1 UV+mc7Os3x9pnsvDDEIZsZwjBihut6hrZQre+U0LqBb/SS2+k4FJJuFmSI+12FUv8MEf Ek6g== X-Gm-Message-State: AJIora/RlXFXwtWh5YA6uka+DRFc9MEmFofv5HZKF1M7/XDA2XvQgjpK +zDSZCKWfx13iBap50XLDmDVvmqgmOtW2nP14yoNWMIuBPgquTw8OZ5RomEU+ukM+XHF64vZDvU lnfU= X-Received: by 2002:a05:6214:da6:b0:472:f007:81a3 with SMTP id h6-20020a0562140da600b00472f00781a3mr19488192qvh.65.1657198040303; Thu, 07 Jul 2022 05:47:20 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sJbZmfEqcPjiD32U0BK2OUdnAq8MBhU/wNQ4hX9C5FyFJVFHJjJId2Gnt9hhBxmoIQifxjVw== X-Received: by 2002:a05:6214:da6:b0:472:f007:81a3 with SMTP id h6-20020a0562140da600b00472f00781a3mr19488171qvh.65.1657198040082; Thu, 07 Jul 2022 05:47:20 -0700 (PDT) Received: from localhost.localdomain (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id a14-20020ae9e80e000000b006a77940be22sm30782377qkg.95.2022.07.07.05.47.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Jul 2022 05:47:19 -0700 (PDT) Subject: Re: [PATCH v4 7/7] bbdev: add a lock option for enqueue/dequeue operation To: "Chautru, Nicolas" , Stephen Hemminger Cc: "dev@dpdk.org" , "thomas@monjalon.net" , "gakhil@marvell.com" , "hemant.agrawal@nxp.com" , "maxime.coquelin@redhat.com" , "mdr@ashroe.eu" , "Richardson, Bruce" , "david.marchand@redhat.com" References: <1655491040-183649-6-git-send-email-nicolas.chautru@intel.com> <1657067022-54373-1-git-send-email-nicolas.chautru@intel.com> <1657067022-54373-8-git-send-email-nicolas.chautru@intel.com> <25b4ece1-8f67-f119-7a0e-5b133f4e571c@redhat.com> <20220706122048.46555c19@hermes.local> From: Tom Rix Message-ID: <798292b3-2b52-5393-0cf2-c9b4918f14c5@redhat.com> Date: Thu, 7 Jul 2022 05:47:16 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 7/6/22 1:21 PM, Chautru, Nicolas wrote: > Hi Stephen, Tom., > >> -----Original Message----- >> From: Stephen Hemminger >> >> On Wed, 6 Jul 2022 12:01:19 -0700 >> Tom Rix wrote: >> >>> On 7/5/22 5:23 PM, Nicolas Chautru wrote: >>>> Locking is not explicitly required but can be valuable in case the >>>> application cannot guarantee to be thread-safe, or specifically is >>>> at risk of using the same queue from multiple threads. >>>> This is an option for PMD to use this. >>>> >>>> Signed-off-by: Nicolas Chautru >>>> --- >>>> lib/bbdev/rte_bbdev.h | 2 ++ >>>> 1 file changed, 2 insertions(+) >>>> >>>> diff --git a/lib/bbdev/rte_bbdev.h b/lib/bbdev/rte_bbdev.h index >>>> b7ecf94..8e7ca86 100644 >>>> --- a/lib/bbdev/rte_bbdev.h >>>> +++ b/lib/bbdev/rte_bbdev.h >>>> @@ -407,6 +407,8 @@ struct rte_bbdev_queue_data { >>>> struct rte_bbdev_stats queue_stats; /**< Queue statistics */ >>>> enum rte_bbdev_enqueue_status enqueue_status; /**< Enqueue >> status when op is rejected */ >>>> bool started; /**< Queue state */ >>>> + rte_rwlock_t lock_enq; /**< lock protection for the Enqueue */ >>>> + rte_rwlock_t lock_deq; /**< lock protection for the Dequeue */ >>> No. >>> >>> This is a good idea but needs a use before introducing another >>> element, particularly a complicated one like locking >>> >>> Tom > The actual usage would be implemented within the PMD. Basically this to prevent the corner case when a queue is being accessed from multiple thread for which there is no protection in DPDK (but application does not necessarily behaves well). > In normal operation there would never be a case when there is a conflict on the lock. > This is not something which was considered for any other PMD? > From DPDK doc : "If multiple threads are to use the same hardware queue on the same NIC port, then locking, or some other form of mutual exclusion, is necessary." > Basically for AC100 we would purely enforce the lock for any enqueue/dequeue operation for a given queue (distinct lock for enqueue and dequeue, since these would run on different threads). I am fine with locking, just have to use them. For me, this would mean adding them to every public interface so the changes would be involved. This is a big change and if pressed to get this patchset into 22.11, then defer this patch to later. Tom > >> Having two locks on same cacheline will create lots of ping/pong false sharing. > You would recommend to purely spread them within the structure? Or something else? > >> Also, unless the reader is holding the lock for a significant fraction of the time a >> regular spin lock will be faster. > OK Thanks. It should in principle never have to wait for the lock for the usage above, only to catch misbehaving application risk. > > Nic > >