From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9517EA052B for ; Tue, 28 Jul 2020 12:21:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C4081C0AC; Tue, 28 Jul 2020 12:21:10 +0200 (CEST) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 695FC2B9C; Tue, 28 Jul 2020 12:21:06 +0200 (CEST) Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 9C1665C0167; Tue, 28 Jul 2020 06:21:05 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Tue, 28 Jul 2020 06:21:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=fm1; bh= JgBA2z/DRFW5fYsFArvzD2jr1AuM39Akz8Da/xqHxdM=; b=Q0lunfoeIEAA7Bny RF1hCP1ljj0e53YKdbILQIh9ogpXabfc5hHI1kcsUZYRRkOh3MIj1a4FNzAxyddm p+CxV33DSHB5UVCd+cNMyQl/bJbK7XHpWbHKR/+PieaJQn8XRoAfXhEwqqBHCqVw h5ZXe7HU9uJJGC6Fc/2ABfQeVwIzZvr8rtvIr9SpkjBzgl9VUg4ZSpMZQ7LbAVAV Pv82HPxIz1aNyMFRxF/VvZTC9qlFHq6ATT7POHeI2RfwSTLj/5mOZMmtzPGH2CBt XG8Hcg1YoaK9TndgezCDbn4864okEyX91BPjuhgjPO8LRD7V07411N6AViQGmSU4 iFCIBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=JgBA2z/DRFW5fYsFArvzD2jr1AuM39Akz8Da/xqHx dM=; b=I2U909C0mm8WYRCxnhTTk2WPXguXno5ut2hJIkA7gtyaid6DP5hu4tPSD DdHns2vMZze2CPYFFNg8fOzOUCVcvIKkGvPLSat7sOHrhbteuYPVrH7Xm1TdLPlK rIcQY8xFjorZQwyLW7I8CyYcW+XnAGjf0xHC9uuC8vqdx3HYvNkJOex41g5dtoE8 H0t5K4e7hhG4UX8fOjyxxpOFMSVWi2ODEv/Dv8f8WTvnR5k9PDPR1WVLfiW2W3Y5 /1/N6g/D/qOPm9gxsYBfLElTv7uwxNgad7lzo46zEhA0o88PAGE8wu48cGJvD6V7 vXz83o2TSa4Jw1nyGPhs1yOh1DmhA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedriedvgddvgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkjghfggfgtgesthfuredttddtvdenucfhrhhomhepvfhhohhmrghs ucfoohhnjhgrlhhonhcuoehthhhomhgrshesmhhonhhjrghlohhnrdhnvghtqeenucggtf frrghtthgvrhhnpedugefgvdefudfftdefgeelgffhueekgfffhfeujedtteeutdejueei iedvffegheenucfkphepjeejrddufeegrddvtdefrddukeegnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvth X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id D56573280066; Tue, 28 Jul 2020 06:21:01 -0400 (EDT) From: Thomas Monjalon To: Matan Azrad Cc: "dev@dpdk.org" , Raslan Darawsheh , Shiri Kuzin , "stable@dpdk.org" , Shahaf Shuler , Slava Ovsiienko , Ray Kinsella , Neil Horman Date: Tue, 28 Jul 2020 12:21:00 +0200 Message-ID: <8862837.XqZ19bOpPU@thomas> In-Reply-To: References: <20200719100735.2473014-1-thomas@monjalon.net> <8766955.pzj3U7fHRR@thomas> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-stable] [PATCH] common/mlx5: fix CPU detection for PCI relaxed ordering X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 24/07/2020 17:43, Matan Azrad: > Hi Thomas > > From: Thomas Monjalon: > > 19/07/2020 13:41, Matan Azrad: > > > > > > From: Thomas Monjalon: > > > > 19/07/2020 12:56, Matan Azrad: > > > > > > > > > > From: Thomas Monjalon > > > > > > The detection of the CPU was done in a constructor and shared in > > > > > > a global variable. > > > > > > > > > > > > This variable may not be visible in the net PMD because it was > > > > > > not exported as part of the .map file. > > > > > > > > > > Can you explain exactly when it is not visible? > > > > > > > > I depends on linker options. > > It will be good to add here the compiling command which failed for you... > > > > > > > It is fixed by exporting a function, which is cleaner than a variable. > > > > > > > > > > Can you explain why? > > > > > We have classic example - rte_eth_devices. > > > > > > > > There is more control and more abstraction in functions, it can > > > > provide futre- proof abstraction. > > > > > > Also variable have more abstraction - struct. > > > In future, if it will be needed, we can change it. > > > > > > > We should not export variables at all, it is a basic rule of writing > > > > API. > > > > It is variable which is depended only in the running CPU - almost like > > > compile time condition, so it is not regular case. > > > I think it makes sense also to use a singleton variable as internal API. > > > > > > > Having a bad example in ethdev doesn't mean we should follow it. > > > > > > If ethdev rte_eth_devices is bad API, Are you going to change it? > > > > No, we avoid changing API. > > > > It is internal API, I don't understand your concern... > > > > > > > By checking the CPU only at the first call of the function, > > > > > > doing the check in a constructor becomes useless. > > > > > > > > > > Yes, but why not to do it in constructor? this variable is > > > > > initialized only once > > > > and doesn't depend in any parameter. > > > > > > > > Constructor must remain minimal. > > > > If constructor can be avoided, it must be. > > > > This is a golden rule. > > > > > > The cpu detection is a fast code. > > > > > > Using constructor here makes sense: > > > 1. we need only one initialization for all the program. > > > 2. no need to take care of multithreading on the single initialization (are > > your code thread safe?). > > > > I don't see what could be the issue. > > 2 mlx5 devices running configuration from 2 different threads. > The first MR from each one of the devices can be created at the same time. > The ask for the relaxed ordering cpu can be happened at the same time. DPDK configuration is not thread safe. Do you know any DPDK application configuring devices in 2 different threads? > > > 3. no parameters are required. > > > > > > > > > Note: the priority of the constructor was probably irrelevant. > > > > > > > > No comment about the constructor priority which was set as LOG for > > > > no good reason, proving that this code was not well reviewed? > > > > > > I guess you mean that comment is missing - you right. > > > > No I mean this constructor is declared with LOG priority, but it is not doing > > any log registration. > > > I hope you understand the motivation for higher priority, > The LOG is just the one above. > > > > We want to be sure that the variable is ready before any usage of it in the > > drivers (even in driver contractors). > > > > It is not used by other constructors. > > And avoiding constructor dependencies is exactly why we avoid using > > constructors at all. > > Yes, It is for future, because it makes sense the cpu detection query will be done at initialization time. > > Now, when I understand the community relevant guys don't like priorities(also I didn't convinced on the reasons), I think you can call it from common init function because it is the first call of mlx5 constructors. We want to avoid priorities, and more importantly, we want to avoid having too much code in constructors. > We need to fix the race issue introduced by this patch. > My favor is to call it from constructor. Initialization and configuration is supposed to be done by a single thread. There should not have any race condition.