From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0086.outbound.protection.outlook.com [65.55.169.86]) by dpdk.org (Postfix) with ESMTP id 88380568B for ; Wed, 9 Dec 2015 14:20:24 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Kamil.Rytarowski@caviumnetworks.com; Received: from cavium1.semihalf.local (80.82.22.190) by CY1PR07MB1448.namprd07.prod.outlook.com (10.161.167.146) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 9 Dec 2015 13:20:22 +0000 From: Kamil Rytarowski To: Date: Wed, 9 Dec 2015 14:19:58 +0100 Message-ID: <1449667198-27218-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449588833-485-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [80.82.22.190] X-ClientProxiedBy: VI1PR02CA0021.eurprd02.prod.outlook.com (25.162.7.159) To CY1PR07MB1448.namprd07.prod.outlook.com (25.161.167.146) X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 2:OLoL0Aq1BoP3yNHnNG+TfRlruLq4drU0fCtbRiKKH+lyJOSvAhN6G6cucA3Hqfyc/vwpBe774hT3LJpqyjDV//0sYHXyPq6RyEASok90F16VJgZC2T7Ln8pJ6KllsL6LWBUjXO8deZAo/dKJX3JIsg==; 3:izj8a1+NurV/FQHjR6LMbaPo9M1+b6cBitO40kVzHlM/V8/Tysh4+w5nyaytjBd0gUBib/kF5yovkBNASsSZwwnD8n/s2WniGFdqULBvW7FEN+w63sBg3xtw99zSWxlZ; 25:RDZStgR+vU84WgPZ8wKvWA3igrzjT5eq05UegVAf+s/k0JLxUy+QYmKb7EjxCJww6MrFM06fb49FHFhAhiQloF7C0Ar11hdoGE7oXGJ47WZ0v1RKRPcJaTX6k2c9rJBqn+tTQWkIDJD+gHaoRlWdyEvhmXNkjgla/qfPcTFRL9tvQIUvafmxpBs2mZMF3rhh0J8d4+XyPlMlDBmEtTJ7hrHRbTTKnIy0iHz01Z5SGKklip4CruoIeQdAuLkrr8nKXjtQdhH0gP40PGuqdWXfdA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 20:NbnSIGirNytTovzhpQJWghj6I3NRS6BOtKZYYh0Ukx5L7ZMxFKOZYr3PXbPV83/1Qy/bPgrlxgfy9FQCjlrpIzwhEZROhKxbBfFMSthhxbpC3Hwp3d2dCxFGazQPZwTfVAPaW0DbBMpxK23bfOfyVDUamiHgFO3CjOp++RIwQ6dlycSgCiiVuOT3ETBHHZLEk2psFyVKKm6eZTNr1EpUiMVkbUhv6XIztlPNj0rIUwE6xya7TRNFF7Ao6UWdA+aAYPebtdnIxzVBTGK/7Cjilus3NxZ84v8gMgdEGtpC8nh7Lba/n/VcpHdbMeXdimejng/eojwH+nZxoOPNwOdeVN6o1+NfTsQTFUz4ta7SHvhguXD+KPyh7jsTPHSnDQvSfQtkDJy5i/XzRyl5mhHEHhAvgLQTf16wo0TUEEak6XzRiI4sVFUBapUfd54NIuB7bm9lWx1CO8h7mSEGISrQe81KSOQGdJRSMV1YebsgMACgX0oJtAS4ztrJ32rMQEMN7pFGJWzC5/xiInXVCFqs22+3UjT/FNJJEsTZPNGdyYqNAsVpf8WmbtG/JQ56Ls1iep2zdpdePtFmOvP24CvlhNpvqO3iTgzHwV30wICDBso= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:CY1PR07MB1448; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB1448; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 4:p+y7qFR/RF2PZc81uJLUiW9Fo8XT6C6FmNAFVTDiL5tj4SsQl1l5xcniXxFV19TUmGEcfLES4BUwtd2SYIoHiDLSdIFPJVsXJCv5y4uAjGjvGa0q7TEZbrayujlbV9hRXek0No0hvCYjkAO9H8d/ZoBJE2R9GZEQie3gft6xlYx10VS5vVjZ0bz336FC8QNKpRv39MCJNBD8RjbnLLh4GVFFb3LY4w8f59a2knLIllOQhsIsZht7Dm/AQWBPFgl7w0PjAGkVSfuGIPrhDBHe4Ygv/+uGBtp2rbsYBtbarA5IVAVwb6cpeEXHnO+pwoTuFrUg1GoKkiXG9vWANTY0OrEsVG7ZOUdnoTHQihHa0v5xobCe1O+0LbgTd5fmm11YLbF1Oo8Ih+AJfs09dnULHyVUERqwfKpKlmypxSw2+YtZIDhbaIVtN6QEBWBiZPRV X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(105586002)(92566002)(42186005)(586003)(19580395003)(106356001)(3846002)(19580405001)(5008740100001)(50226001)(1096002)(5004730100002)(122386002)(229853001)(66066001)(110136002)(36756003)(5001960100002)(6116002)(76176999)(50986999)(47776003)(189998001)(101416001)(77096005)(2950100001)(97736004)(81156007)(2351001)(86362001)(5003940100001)(50466002)(87976001)(40100003)(48376002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1448; H:cavium1.semihalf.local; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB1448; 23:af1DMKbjXM/X+cMaoWD9XTQY09zTVp3gUzFLXotzP?= =?us-ascii?Q?ArI0iA+xDjGoJndTScZwjK4+YLufb/wtyd8IrDRkXZ8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wAbNUeUSf3aqhiIucVCcg94CK7MTg4l9S2mw0boAoFf?= =?us-ascii?Q?7jjlr1bOXLhhQKcGL/AG1O8GUxxeUeG1oH/ofVElN0JJQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1448; 5:2Svt5lTr2lhFPxny6Y/NYHO6KwzAiIEh/J9tgtaE5pH/Wrq4RSydq1OhbqYFPifx6WC8YFFmtljnSleuHOPRYFyNcfodI3Queyn1AzJUj1YpxiZ5/fSWU9hLt/s9heWBewtgDixW74bNpSy1E8ClXg==; 24:uBQpFMzoph/7nazldCUrHUhvqbcv7/nXWJ9YI2d3fvAX3jh3+e3mSN4rzn/9tIlnv/PGhmTj9CIEy2o4nbsbV6FuCjbeVsCqWcDJG1HMqs4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2015 13:20:22.6276 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1448 Subject: [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Dec 2015 13:20:25 -0000 Currently rte_eal_check_module() detects Linux kernel modules via reading /proc/modules. Built-in ones aren't listed there and therefore they are not being found by the script. Add support for checking built-in modules with parsing the sysfs files This commit obsoletes the /proc/modules parsing approach. Signed-off-by: Kamil Rytarowski Signed-off-by: David Marchand --- lib/librte_eal/linuxapp/eal/eal.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 635ec36..21a4a32 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -901,27 +901,33 @@ int rte_eal_has_hugepages(void) int rte_eal_check_module(const char *module_name) { - char mod_name[30]; /* Any module names can be longer than 30 bytes? */ - int ret = 0; + char sysfs_mod_name[PATH_MAX]; + struct stat st; int n; if (NULL == module_name) return -1; - FILE *fd = fopen("/proc/modules", "r"); - if (NULL == fd) { - RTE_LOG(ERR, EAL, "Open /proc/modules failed!" - " error %i (%s)\n", errno, strerror(errno)); + /* Check if there is sysfs mounted */ + if (stat("/sys/module", &st) != 0) { + RTE_LOG(DEBUG, EAL, "sysfs is not mounted! error %i (%s)\n", + errno, strerror(errno)); return -1; } - while (!feof(fd)) { - n = fscanf(fd, "%29s %*[^\n]", mod_name); - if ((n == 1) && !strcmp(mod_name, module_name)) { - ret = 1; - break; - } + + /* A module might be built-in, therefore try sysfs */ + n = snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name); + if (n < 0 || n > PATH_MAX) { + RTE_LOG(DEBUG, EAL, "Could not format module path\n"); + return -1; } - fclose(fd); - return ret; + if (stat(sysfs_mod_name, &st) != 0) { + RTE_LOG(DEBUG, EAL, "Module %s not found! error %i (%s)\n", + sysfs_mod_name, errno, strerror(errno)); + return 0; + } + + /* Module has been found */ + return 1; } -- 2.6.3