From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by dpdk.org (Postfix) with ESMTP id F3F2216E for ; Tue, 28 Nov 2017 05:06:21 +0100 (CET) Received: by mail-pg0-f68.google.com with SMTP id j16so19709824pgn.9 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=nNk26gMuHCl+ybx16hSKbMXgqfSSHmlaDqSa+nQyhzCJ5duNjImqq1geylJHfTeJlH GMK6X3Djw354h6/tNQkfnAzOq4If4/Ujy8KStjS6Xat1u4XsU9ZctVS5dAIDmDRCTzz+ G2HUY/1PAXyV1MjdfAdrrfA1XfT37AQoRDkwbXkglE5mqWgari1Wat/jkGVwXe8gtkBd Xuj4rhJuf2qA3bECV0QDqTH/GZ4SfWTQJM8AZvJbLJc1sIx2znpcnSrffXiBdHkrbi+3 MmviWUpOTyyD00O/MJ8TqrYmIUf+nlG5ss1vz4jtRwynBgdYQX4sGJehNYwegTLHgxsC 0yUQ== X-Gm-Message-State: AJaThX7SEXKpI5wUqlyrZTPMpAPe2avJ/yG+05aV6sntOq0nmPeSxHIQ NDLX/zxARHDd6CpGqzdqCgzm0A== 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-dev] A question about the possible race condition in the l3fwd example? X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and 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.