From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by dpdk.org (Postfix) with ESMTP id 0E8E01B53 for ; Tue, 28 Nov 2017 05:06:21 +0100 (CET) Received: by mail-pg0-f65.google.com with SMTP id r12so19709604pgu.10 for ; Mon, 27 Nov 2017 20:06:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=g2Hx8rGgzz7Yk5N7O2P3XfImK7HoPqg1UM853HWGbrQ=; b=cpnmCP+t0FfKZYps1Jkf7fnRG2/vGGRLM0Q2/Aals7qvlVQdoKKLC201350ZgNg3EC akZiwhRV417Vn3wUDDrnnqLXXgIB0XYfLs1r1jz2n4ZFjksABoXs3MhPT3u1wHd9n232 7NqYg7vz3FN6t6eG7dEtWev1I45Xw+vxaXYtpiL0TkhEEVM/GgMT66s16Ts7DZhlLQ/j OP+G9VMaMWOsFleaTW++kqcaXOu1/BLJna7SoC6YrqOsQsF55WtBApeFV0ZLKcF2w8ru EcSV+xSv5TqVR8JVe4AEGbCzG+1XkPjh110y7HCJWP7y5lvhoOKl0dOoASfrdWPiuZh5 Jjrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=g2Hx8rGgzz7Yk5N7O2P3XfImK7HoPqg1UM853HWGbrQ=; b=OeiSTMZVXAWyg/D2aVWfttfSY0p3epA2dPoZHiWfGDQEu5XNQAIVd5oOe/acCKkDxS nw0IoWqZJtJFHNOHjUt+HRS9XThy3EwlkO96TEJvYeZxyV1+H5MaStGIke+2Sq0Up9W7 /E9Uy0KUoVIL8TcYJ9+WrfIeG80TGukPhyK1lSDvkQvd0FFGTsquFQ/hsDuYgKAKw9S2 JTLF5oJgfF5fWUVn16xV8fzVF3Ik1wi9+ijINZSqD1adHD/Sb4w8Jl96ayGNd6GuCIMm M1fWMMkbMbA0Mi2UvZFj1uDAKQv7+n/emnIb/ke17XYADAU0B7744a0FG9uBhLZK3Y6f V+fw== X-Gm-Message-State: AJaThX4QUp8sl1razhzC+WerhRzcq86IfMYAHruUrNR5HfRjpaegauuM fQcOdGBt3NtF4jZR3CiYQ/i31Xl40m4= X-Google-Smtp-Source: AGs4zMY7kbNiNEYNQBGVfp8lJwmVKvHtHoVO5hEOX9s5sdbm9AWnWrYAKQRYN0UJ1D6cT0tyDzyIYg== X-Received: by 10.98.158.139 with SMTP id f11mr28860379pfk.216.1511841981126; Mon, 27 Nov 2017 20:06:21 -0800 (PST) Received: from xeon-e3 (76-14-207-240.or.wavecable.com. [76.14.207.240]) by smtp.gmail.com with ESMTPSA id h13sm3723005pfi.40.2017.11.27.20.06.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Nov 2017 20:06:21 -0800 (PST) Date: Mon, 27 Nov 2017 20:06:13 -0800 From: Stephen Hemminger To: "Wu, Xiaoban" Cc: "users@dpdk.org" , "dev@dpdk.org" Message-ID: <20171127200613.74783eff@xeon-e3> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-users] [dpdk-dev] A question about the possible race condition in the l3fwd example? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Nov 2017 04:06:22 -0000 On Tue, 28 Nov 2017 02:22:57 +0000 "Wu, Xiaoban" wrote: > Dear All, > > > I am studying the source code of the l3fwd example. I am confused about a possible race condition in the l3fwd_lpm_simple_forward(). > > > In this function it calls send_single_packet(), which executes the following code, > > len = qconf->tx_mbufs[port].len; > qconf->tx_mbufs[port].m_table[len] = m; > len++; > > As you can see, if two threads are trying to call send_single_packet() at the same time and send different packets to the same port, which writes the value to the same array and updates the same counter 'len', then the race condition happens, so we might lose packets. > > Can anybody please clarify if this indeed brings race condition? If yes, then why we want to design it in this way, just for high performance? If no, why? > > Thanks very much for your help. > > Best wishes, > Xiaoban > > > qconf is in in a per core data structure, so it is impossible for sharing to happen.