From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com [209.85.217.180]) by dpdk.org (Postfix) with ESMTP id 9BDC968A8 for ; Mon, 12 May 2014 11:18:11 +0200 (CEST) Received: by mail-lb0-f180.google.com with SMTP id p9so7207848lbv.39 for ; Mon, 12 May 2014 02:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=cA6i855RR5vi3Nhe90ZIqkkxSBlk97g9fVhwyE8xoD4=; b=cN5lO5UoJJ38XZeeyc1SIhk5LY03aOM+sLfC5bY+oZOqkuQqKYtNS6UZrkjvAwm1J+ kXuOfiaVgmcf68rVbVUfiodnEuRkoDl0oQfwGK1Omvb0VN27qE/V14tQGEOdaQHG3E8u IGYdweBBdv9nZRQA05YtdBdvCBwFthI9z64PlBv5y1eQxOkUZycdTOVcnWxg8qdm+Ov4 I8Zc6PO6M/DCQQlXQx413N2uHLg3rT4loQ7cQKmpGIPpx0POkBhSSDlcsG/IUjI7Nrs3 xhcxW/+S8CYpGHFxBN4WrqTyjAtRUwGuOQC9Rj7dkMJkWcYSGTbw8g33B7Jbrfq85QMK 7mvw== MIME-Version: 1.0 X-Received: by 10.112.154.102 with SMTP id vn6mr700373lbb.55.1399886298454; Mon, 12 May 2014 02:18:18 -0700 (PDT) Received: by 10.114.174.73 with HTTP; Mon, 12 May 2014 02:18:18 -0700 (PDT) In-Reply-To: References: Date: Mon, 12 May 2014 13:18:18 +0400 Message-ID: From: Vladimir Medvedkin To: Tomas Vestelind Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] Question regarding concurrency and hash table X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 May 2014 09:18:12 -0000 Hi, Programmer's guide section 22.1: The hash and LPM libraries are, by design, thread unsafe in order to maintain performance. However, if required the developer can add layers on top of these libraries to provide thread safety. Locking is not needed in all situations, and in both the hash and LPM libraries, lookups of values can be performed in parallel in multiple threads. Adding, removing or modifying values, however, cannot be done in multiple threads without using locking when a single hash or LPM table is accessed. Another alternative to locking would be to create multiple instances of these tables allowing each thread its own copy. So, rte_hash_add_key() is not multi-thread safe unlike the rte_hash_lookup() which is multi-thread safe. You can call add and lookup func simultaneously if you make sure that rte_hash_add_key() call either from single dedicated thread or protect by lock hash table. 2014-05-12 12:29 GMT+04:00 Tomas Vestelind : > Hello all! > > I have a question regarding the possible concurrency issues in hash table. > My questions is: > Is it possible to call rte_hash_add() and rte_hash_lookup() at the same > time without data inconsistency? > > My guess is that I need to use a lock as protection. I see that you have a > couple of nice ones :) > > BR, > Tomas Vestelind >