From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk0-f52.google.com (mail-vk0-f52.google.com [209.85.213.52]) by dpdk.org (Postfix) with ESMTP id 1799FAA38 for ; Tue, 1 Mar 2016 19:56:56 +0100 (CET) Received: by mail-vk0-f52.google.com with SMTP id k196so178675912vka.0 for ; Tue, 01 Mar 2016 10:56:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc; bh=kylBG/zq7tsz8Ev9xsn+AEci/SYw55tXpzTWnKj+dTQ=; b=Mkc8j6vC+AH9qIlXbT+T/isx74AyFTOAoXSDrM4FKN4HyxqbZU+lyCdmBiuNgz5Tyu xO3fNHDJpLev/gnxrWbUXZLaQqeBgduoR5qPaDTc8o4o5ILGv/lp9jNpk7wz+F1KPAo/ fWRduyMEGHO3SmIt6a+oP7hPpQbcYEC1LTRwiZbospYT8CzRYCTbDgpugEHfaeEWgxun rtmwZvBDaCmVtu/jlh0rnRrZTrFZllkPLovyiEWbLb6b1XWLY5q5s4HL28a7cNbbfad9 LkaKAFdQVZ71flmsVCnzMLs3vPBJ8Nt2Rq63lR3esgzV6WZdH/zCoEqkSWAw9/nAGq/F cL3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to:cc; bh=kylBG/zq7tsz8Ev9xsn+AEci/SYw55tXpzTWnKj+dTQ=; b=CalEZCxoWGYLo8432Hto47sFx047LRvE7D+zkqDB5vMPTO9UfS3f9M1q1/1bzTp+b3 9rjT2Y4749/gwvkm60KZHNZGNNOr1dMhb5l/9Qp5k0JbXLopFeU26XGqTbgJXkk1fmge S+S/X46+5ZtWuadiAEBjks7PRnpYdu17YyO13934f267YAiNC8qphhzUjSQRqvO1rC7Q S72luhT23ytcy2SkO+gzTvfX9OBjUlwICuVyvJO7uV3SOu2WOSqSZ+PMeGVD5eyTHveX wGQX1rFTzFm+vENS64Ai7eoFU5OU9v3440RsmCQXCB6NDuamkYHw/wGrMOOHUSBZv/Is 1RVA== X-Gm-Message-State: AD7BkJIHJgg5D72L6wYbk/mlddk8Js1sBYdXQbybh2Yfzp22OhU3o7Izyo3idEC8ryAQkZfYyTMa95/IK2eE8w== MIME-Version: 1.0 X-Received: by 10.31.136.5 with SMTP id k5mr13891993vkd.35.1456858615533; Tue, 01 Mar 2016 10:56:55 -0800 (PST) Received: by 10.31.237.129 with HTTP; Tue, 1 Mar 2016 10:56:55 -0800 (PST) Date: Tue, 1 Mar 2016 13:56:55 -0500 Message-ID: From: Dhananjaya Reddy Eadala To: bruce.richardson@intel.com, pablo.de.lara.guarch@intel.com Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: dev@dpdk.org Subject: [dpdk-dev] [PATCH] hash: fix memcmp function pointer in multi-process 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: Tue, 01 Mar 2016 18:56:56 -0000 Hi We found a problem in dpdk-2.2 using under multi-process environment. Here is the brief description how we are using the dpdk: We have two processes proc1, proc2 using dpdk. These proc1 and proc2 are two different compiled binaries. proc1 is started as primary process and proc2 as secondary process. proc1: Calls srcHash = rte_hash_create("src_hash_name") to create rte_hash structure. As part of this, this api initalized the rte_hash structure and set the srcHash->rte_hash_cmp_eq to the address of memcmp() from proc1 address space. proc2: calls srcHash = rte_hash_find_existing("src_hash_name"). This returns the rte_hash created by proc1. This srcHash->rte_hash_cmp_eq still points to the address of memcmp() from proc1 address space. Later proc2 calls rte_hash_lookup_with_hash(srcHash, (const void*) &key, key.sig); Under the hood, rte_hash_lookup_with_hash() invokes __rte_hash_lookup_with_hash(), which in turn calls h->rte_hash_cmp_eq(key, k->key, h->key_len). This leads to a crash as h->rte_hash_cmp_eq is an address from proc1 address space and is invalid address in proc2 address space. We found, from dpdk documentation, that " The use of function pointers between multiple processes running based of different compiled binaries is not supported, since the location of a given function in one process may be different to its location in a second. This prevents the librte_hash library from behaving properly as in a multi- threaded instance, since it uses a pointer to the hash function internally. To work around this issue, it is recommended that multi-process applications perform the hash calculations by directly calling the hashing function from the code and then using the rte_hash_add_with_hash()/rte_hash_lookup_with_hash() functions instead of the functions which do the hashing internally, such as rte_hash_add()/rte_hash_lookup(). " We did follow the recommended steps by invoking rte_hash_lookup_with_hash(). It was no issue up to and including dpdk-2.0. In later releases started crashing because rte_hash_cmp_eq is introduced in dpdk-2.1 We fixed it with the following patch and would like to submit the patch to dpdk.org. Patch is created such that, if anyone wanted to use dpdk in multi-process environment with function pointers not shared, they need to define RTE_LIB_MP_NO_FUNC_PTR in their Makefile. Without defining this flag in Makefile, it works as it is now. Please find here attached is the patch file. Thanks Dhana