From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bn1-obe.outbound.protection.outlook.com (mail-bn1bon0093.outbound.protection.outlook.com [157.56.111.93]) by dpdk.org (Postfix) with ESMTP id 572199A92 for ; Mon, 7 Dec 2015 19:36:31 +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 BY2PR07MB1444.namprd07.prod.outlook.com (10.162.76.146) with Microsoft SMTP Server (TLS) id 15.1.331.20; Mon, 7 Dec 2015 18:36:29 +0000 From: Kamil Rytarowski To: Date: Mon, 7 Dec 2015 19:36:05 +0100 Message-ID: <1449513365-22282-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1449513365-22282-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449507460-32038-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1449513365-22282-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: AM3PR01CA036.eurprd01.prod.exchangelabs.com (10.141.191.26) To BY2PR07MB1444.namprd07.prod.outlook.com (25.162.76.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 2:44SZODVeYSGTkHzBcF+hHv7k7HEdpQxd5q8d2zHuiMG97JC4BiFnOn7xjcdoF9JRN749wxSjMSysCuD5rC9SWmLRlwlraXbEFhp/u6rZ7iIjoFsg/UkXPs7BLWSlkyuOV+uqSQVlCxwBMNXKK2WL0w==; 3:PRMOskkPUqos8VxXyTFJA0q0Cq976hrCTR0+zEo0DaoPYcP0uYkKF1uIOcK5TrawVEDubPV/PAPhm9eQu573aiy2G/E+hKAocCI99i9UutzooYpd3BZjTPW0vawOvpIw; 25:C+eZ46QaVDSPpbIzF2e6LJNlLHhmotS7OQpQH1TMf9D2bPwuoMhp+NjtIa2zpX+CucjSjvHrQkHhMcwx+p9KA8MPynjaafU+NPAmmqPXXLc7lugqTuykQpeuVIL/U31a+WagYxCQ8dtYjo/GZFTNtQ9ER1z+ud7euXT8OUCw5J795FVdnY0t62F+4biHnswCb8d/mQz6iqMvdgaITQu5Tjk6QBczUtqW4pYLj2dgsF3mKCbgzcb0K5pvF741R8vr X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 20:U0wclSDBGmHsTQomdMVnQiPYTShQUgPd6e/aPhiM7Q52pEsj7LHA+x4aH7AyPnT0ybTkR0fj2NK9QWu+EHRO2gZNkVLW6L9Tm18lVVcWOla8jjCQeNsYA7CjMtMG3IPTFRuw61GiQI/deiyN8HaRo83J1jRvvHdgyPZQtX3TO1JC4ZQQbwv+zhX0kNBjnsnKEsFtUKWrxlAGi9BaZANll4JhCqV6GBcQOlwiL+nDKPggeRlORyu4g82OaVZvZZwTqHNkBpht0Z61B24axgJ0ncQoHf6Iugay6gn+hTyK/ZD5M8pDupuuAal2xr65VpW5n+bo4vcaUAMyvpUSsUnGXVJfYOnML/1baBoHbTdKDRvUFqTVli3ub23I17+vWeNG5MlPO0QDXYfQG7ofJaHtIN6j4Ujyy1lD6pSRK3v8Q72slqZE0FfqjH1KF2GSiPtX5lFmr/AoaXnw43iEeM2F7BpoACXJ2/A2QCGbfE5iKaTVHSwjPqIjuYmM69Erf/r/dqhkjEwbfSWXS/Us2PlYLvio52jnnhAUAji5r63Fs9cHiDlpK+s/XVxVR9wX/51PxoQ6lme1DrqAY0BOKwdOl7wUcUKv3H2twldjrkrp2rI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046); SRVR:BY2PR07MB1444; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 4:yuAOWHtlQ4COQjG8P3qTW++aVpp6omx//ckIKzJTFQCY7B0CFwFpBRwKQeV7JjNtK7+OhlrN6A7yB8q8eoas4TLSLucpXp4eF/LUDg6WlggvvqK6OnrwLaaAPXcfH9IqCplH9MKuqHOyulJu6GoQ3LiZnMrcx9WP5IX4quM/8Xhf/Ozlmj22869cwz8K5iOkUEumH6o65UQZfNOOv07F8LxJIkfu92jnGHQU42nKxtdUJtgldCVPiRsi9v0HadCIWcFulkDzyu6hYL4ebt9C2ZUaGW5VzX4d7fNKE+wey3OkJjdXw/AxgMDKglGOsa/dTd7m0NPnaAzsKM9TDYxFOF1GEEF7slkuzmvIV1RofJPRcBV2Zp7iBcTtddPMFW4ORBJVKag3U45PvgSDfKUtDyZbceNjvU0k/njvN2QD8ok= X-Forefront-PRVS: 078310077C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(50226001)(1096002)(87976001)(86362001)(92566002)(122386002)(105586002)(586003)(42186005)(106356001)(189998001)(2351001)(229853001)(76176999)(48376002)(2950100001)(3846002)(4001430100002)(6116002)(5004730100002)(50466002)(101416001)(47776003)(19580405001)(36756003)(19580395003)(5003940100001)(97736004)(5008740100001)(107886002)(81156007)(40100003)(110136002)(5001960100002)(66066001)(50986999)(77096005)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB1444; 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; BY2PR07MB1444; 23:KbGDXMz8kSD4Bby9oqAosPma9PAWzCW1TI+LCDRaS?= =?us-ascii?Q?lMEKxOLZ5v9tXEEw8wkgfc2CL0+19DevmQlHn9yiywPFW6LytsHdwlR4FQ30?= =?us-ascii?Q?iBb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mh5jOV9?= =?us-ascii?Q?ydeKCR3flEaJvNF3KAflZKH7vCavQ9QTD3PWc8/ClINDf29dg0H/pU+3j0Kr?= =?us-ascii?Q?24Ww6xdSDSDFdwIeGQjKnx/mHw/CWd/kQncEtAxbC4h5+El3Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 5:m2QWXyCrR4pkUh+1+zUVQWrL9ynWPguAHZh/MPF7Vl+H/uPQSAAkoNrSrbm0GY57/O+fdmyfGozX0bw5qdEJJocii37UIQEUyeoufGolrKYTjv1kJqbrfzqD3bmNyGvHZ6XpV8vyrxf4ZendH3KEVQ==; 24:OreGIIATWIxOOfXFNpZh9tqa/83kZN5uBqVOJdatAKLJzkjzx+QhjngubFoCbV0dOFqQudcSIb0Qhl5bgXAHQJxwNke5zqX5fkXgfAgM3mo= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2015 18:36:29.2005 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1444 Subject: [dpdk-dev] [PATCH v3 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: Mon, 07 Dec 2015 18:36:32 -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 --- lib/librte_eal/linuxapp/eal/eal.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 635ec36..539188f 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -52,6 +52,8 @@ #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686) #include #endif +#include +#include #include #include @@ -901,27 +903,27 @@ 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; - int n; + char sysfs_mod_name[PATH_MAX]; + struct stat st; 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, "Open /sys/module failed: %s\n", + 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 */ + snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name); + if (stat(sysfs_mod_name, &st) != 0) { + RTE_LOG(DEBUG, EAL, "Open %s failed! error %i (%s)\n", + sysfs_mod_name, errno, strerror(errno)); + return 0; } - fclose(fd); - return ret; + /* Module has been found */ + return 1; } -- 2.5.0