From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Rybchenko Subject: Re: [PATCH v2 02/15] ethdev: add linkstatus get/set helper functions Date: Sat, 6 Jan 2018 17:35:06 +0300 Message-ID: <750b9eff-9ba0-60b3-e587-fb22c2bfc5b7@solarflare.com> References: <20180106010656.9167-1-stephen@networkplumber.org> <20180106010656.9167-3-stephen@networkplumber.org> <20180106062456.1d1eba50@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: To: Stephen Hemminger Return-path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id A42281B16A for ; Sat, 6 Jan 2018 15:35:19 +0100 (CET) In-Reply-To: <20180106062456.1d1eba50@xeon-e3> Content-Language: en-GB List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 01/06/2018 05:24 PM, Stephen Hemminger wrote: > On Sat, 6 Jan 2018 13:49:50 +0300 > Andrew Rybchenko wrote: > >> On 01/06/2018 04:06 AM, Stephen Hemminger wrote: >>> +} >>> + >>> +void >>> +_rte_eth_linkstatus_get(const struct rte_eth_dev *dev, >>> + struct rte_eth_link *link) >>> +{ >>> + const uint64_t *src = (const uint64_t *)&(dev->data->dev_link); >>> + volatile uint64_t *dst = (uint64_t *)link; >>> + >>> + RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t)); >>> + >>> + /* >>> + * Note: this should never fail since both destination and expected >>> + * values are the same and are a pointer from caller. >>> + */ >>> + rte_atomic64_cmpset(dst, *dst, *src); >> As I understand nobody says that *link (i.e. *dst) is initialized, so it >> could be >> reading uninitialized value. Not fatal, but not good as well. >> May be it is better to use something like rte_atomic64_read(). >> > link is a pointer passed in by the caller. > If it is uninitialized, that is still ok since it will have some value. I thought about valgrind. Yes, it is problematic to run with hugepages, but should be possible (with some patches). If so, it will/can complain about usage of uninitialized value. > The different question is that since is almost backwards use of cmpset, > not sure if processor really guarantees atomic read of source pointer. > But this code is cloned from original in Intel driver so it is bug > for bug compatiable! I see, but if so it was local to corresponding Intel driver. Now it is becoming global.