From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 73A942B83 for ; Fri, 20 Jan 2017 19:37:36 +0100 (CET) Received: by mail-wm0-f53.google.com with SMTP id d140so16136837wmd.0 for ; Fri, 20 Jan 2017 10:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:user-agent:in-reply-to :references:mime-version:content-transfer-encoding; bh=QeTzTQqhp61p6+aN++k/Q2kQ3J4mqROHXAg5BU9YvgM=; b=WIFJ0zO85U3pVhTKULtYGPxvvA8upMFbOE7nQ4tvCvTMHwHk2UzPptGWOa0OPgHOpc +NUxPg/JVaXa5LqxKP3vYXHDc0NMF4JaB4muiw6GwlYRZ0iB08/uA4aot/faKc3g4T5l HQIcaBuNg7epINTimZTos/1D7AxLm1cbEhsOzOZPCmbsP39zNttc1Y8a43SVITYjeRDG NehadTWQCKdZ3R5dsz8FNZje3Hzeuj421bjOIQetC37n8mNmTpdQ3aEclLoXa/GdnDNj iJiPAWlel0heS/qaLHo9zVH9mcRdvR4GfCy96/h9Nzr57hsF3opX7Bv+NJ0aI1j0rwao UHBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=QeTzTQqhp61p6+aN++k/Q2kQ3J4mqROHXAg5BU9YvgM=; b=XXe42rW71EkpG8PMKfzt2xHeRvnsN8WWTAmKetNMcyZC+6XutoIOYoQj6sNg4fnIiC WRHKxAF6zWMllD0tbRJJjDPWIz4be/NOFHpD9fAiSYApwKRtaXiBudGHkuSYtqqjC5+a TMtpT88mW9ouMDbZ82IUYGQj+KcJVJREqo1n9E87yoFLyNC9fqy0m9EECLicLAwXnY4R at5bb6o8KNEUcuPmTC8BLnfN9YTEzcRg7+82wP/Ghb5hm+dxSMjas0w9OWDVGeNUEIMJ nLSTQRn5SLermQerwVFmPjL6dfT6psJcXQdDYk8mhyQloQrs1z3gdOIH9Tk6Qq45kNb2 0u1w== X-Gm-Message-State: AIkVDXJoMMQQh7VJPJSmiXZGVcAu0927FonTtkjC0PioPWd2NYf3dyWaGoSeJenKa5NsQUdu X-Received: by 10.28.66.88 with SMTP id p85mr4695509wma.64.1484937455023; Fri, 20 Jan 2017 10:37:35 -0800 (PST) Received: from xps13.localnet (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id m78sm7392609wmd.8.2017.01.20.10.37.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jan 2017 10:37:34 -0800 (PST) From: Thomas Monjalon To: Remy Horton Cc: dev@dpdk.org Date: Fri, 20 Jan 2017 19:37:33 +0100 Message-ID: <1923485.xZPm2OXYXH@xps13> User-Agent: KMail/4.14.10 (Linux/4.5.4-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <1484073764-15001-1-git-send-email-remy.horton@intel.com> References: <1484073764-15001-1-git-send-email-remy.horton@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH v1] ethdev: fix multi-process NULL dereference crashes 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: Fri, 20 Jan 2017 18:37:36 -0000 2017-01-11 02:42, Remy Horton: > +* **ethdev: Fixed crash with multi-processing.** > + > + Even though only primary processes should setup PMDs, secondary > + processes were also blanket zeroing ethernet device memory. The > + result was NULL dereference crashes in multi-process setups. > + 3 comments here: - it is in the wrong section (EAL instead of Drivers) - secondary processes can setup a vdev PMD - before Yuanhan's patch, even PCI PMD were blanking primary process data > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -212,7 +212,8 @@ rte_eth_dev_allocate(const char *name) > > eth_dev = &rte_eth_devices[port_id]; > eth_dev->data = &rte_eth_dev_data[port_id]; > - memset(eth_dev->data, 0, sizeof(*eth_dev->data)); > + if (rte_eal_process_type() == RTE_PROC_PRIMARY) > + memset(eth_dev->data, 0, sizeof(*eth_dev->data)); > snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name); > eth_dev->data->port_id = port_id; > eth_dev->data->mtu = ETHER_MTU; > I propose this rebase: - memset(&rte_eth_dev_data[port_id], 0, sizeof(struct rte_eth_dev_data)); eth_dev = eth_dev_get(port_id); + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + memset(eth_dev->data, 0, sizeof(*eth_dev->data)); snprintf(eth_dev->data->name, sizeof(eth_dev->data->name), "%s", name); eth_dev->data->port_id = port_id; eth_dev->data->mtu = ETHER_MTU;