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 2735DA04C5; Fri, 15 Nov 2019 10:29:03 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 077762C28; Fri, 15 Nov 2019 10:29:02 +0100 (CET) Received: from integrity.niometrics.com (integrity.niometrics.com [42.61.70.122]) by dpdk.org (Postfix) with ESMTP id A8F902C18 for ; Fri, 15 Nov 2019 10:29:00 +0100 (CET) Received: from [10.15.0.122] (unknown [10.15.0.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by integrity.niometrics.com (Postfix) with ESMTPSA id E543F409CBA8 for ; Fri, 15 Nov 2019 17:28:58 +0800 (+08) DMARC-Filter: OpenDMARC Filter v1.3.2 integrity.niometrics.com E543F409CBA8 Authentication-Results: integrity.niometrics.com; dmarc=fail (p=reject dis=none) header.from=niometrics.com Authentication-Results: integrity.niometrics.com; spf=fail smtp.mailfrom=tranbaolong@niometrics.com DKIM-Filter: OpenDKIM Filter v2.11.0 integrity.niometrics.com E543F409CBA8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niometrics.com; s=default; t=1573810139; bh=ruTqIpamMGefBwRV0SmP/3ITw2XvJmjuPkEJnqyns5E=; h=From:Subject:Date:To:From; b=NeiVPBCW4DX+aGm+hKs9aDRKgk0AKVWzIBch/n+Se8vRC2Us+4mgEB2pX4CrEUJr4 2eQUioKck3vQ12mZK0Nx1IYboyga/PtxamlAEDQy4V7pVsmuV8Ww+1POrUXtwndgbE 7nt+CrXVSRLOtkqrPs4c2O+D8igBqIN8VJFK53rU= From: Bao-Long Tran Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Message-Id: Date: Fri, 15 Nov 2019 17:28:58 +0800 To: dev@dpdk.org X-Mailer: Apple Mail (2.3601.0.10) X-Spam-Status: No, score=-1.0 required=3.5 tests=ALL_TRUSTED autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on integrity.niometrics.com Subject: [dpdk-dev] rte_eal_init() behavior 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi, In most of the examples, the argc and argv from main are passed directly to rte_eal_init(). This has the implication that argv[0] is the program name. When a user crafts his own argv, he must submit a placeholder at argv[0] as well, or else the EAL parameters won't be parsed correctly. Below is a minimal demonstration. It requests 1 lcore, but EAL initializes all available lcores instead. If I put in some placeholder, then it's working as expected. #include #include #include #include int main(void) { int argc = 0; char *argv[4]; // if we don't add "foo", EAL won't initialize correctly //argv[argc++] = strdup("foo"); argv[argc++] = strdup("-l 0"); if (rte_eal_init(argc, argv) < 0) rte_exit(EXIT_FAILURE, "EAL initialization error\n"); printf("%s: lcore count specificed: 1, got: %u\n", 1 == rte_lcore_count() ? "PASS" : "FAIL", rte_lcore_count()); return 0; } If I'm not mistaken, this behavior is not documented anywhere, including the source code or API. It is also totally silent, no warning whatsoever. I guess one way to make sure that rte_eal_init() was correctly executed is to compare its return value to the number of args passed in, but this is too cumbersome and in fact most of the examples don't do it. I suggest we should document this behavior, and maybe fix it so that users won't need to pass in a placeholder. --BL