From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0056.outbound.protection.outlook.com [207.46.100.56]) by dpdk.org (Postfix) with ESMTP id 80742C3B2 for ; Thu, 28 Jan 2016 14:14:27 +0100 (CET) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Kamil.Rytarowski@caviumnetworks.com; Received: from cavium1.semihalf.local (213.17.239.108) by BY2PR07MB1443.namprd07.prod.outlook.com (10.162.76.145) with Microsoft SMTP Server (TLS) id 15.1.390.13; Thu, 28 Jan 2016 13:14:25 +0000 From: To: Date: Thu, 28 Jan 2016 14:13:54 +0100 Message-ID: <1453986834-31128-2-git-send-email-krytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453986834-31128-1-git-send-email-krytarowski@caviumnetworks.com> References: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> <1453986834-31128-1-git-send-email-krytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [213.17.239.108] X-ClientProxiedBy: VI1PR08CA0028.eurprd08.prod.outlook.com (25.164.95.38) To BY2PR07MB1443.namprd07.prod.outlook.com (25.162.76.145) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 2:mSzbdp1IWAqRAMbVAtLTCkMO1RjSUu62PDCu7x3i423PBiU8MkNtAhT0vcD6DrStoAm7Mu1tIaXGijO2R0IeMAWTKiEtlsAf5LAWRV8zw9P+lY5blpkXYKEtAullmI8r1rH3313QQCPJuWQXNvxA+Q==; 3:lvslAHtJ88KUdHA/sk2H20P6FgtAWvnBpfcvXPwUrNsAdfpHTOXrMdMgy7DPCVPruC4+jBje0Gov9MKtWfArPEDONwOhDx+LWSj/JtGBX/tZ1aOA6qUkav95cxK12lcE; 25:SoHyqukBX1iNcAqhcn+3mAbtWVdp+Z/9MeTHrDjDqwIOQiKWYLD8EF8VMHU2DO2OqW8P5n5desf4XfkDhu2ui4BULt9TS4dJvUmSET59Z1K/TN7mRT64GQVjVHq8M9XpUNqQGOTu737VxyoamkN78LmH5EXHSx4lZQIrj5E/cMx7p0k5FkFhrMhbJ/TY9rVHuCGTD1s+aVKTnqni2O8O8KssAFIrRXFwSu7MsvtPygEpJrDGJo0KxMh7u7gqtVNO X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1443; X-MS-Office365-Filtering-Correlation-Id: 7c29ef0a-54a3-496e-e09b-08d327e4f2d3 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 20:StQs7VL8FiYoWy+cenIgHi6VNyghseahCEMVgz6/oQsMiwwyXH1gqeItXkOO55aeLlDVp7nVDkG2OYVBlCEbo1u6aXu5ZBFEQiote9EKRNirkeShECV7HctRk4CDV73Rm3G5EGBiKZ4aw42ZPAQOF3EGG8Hm0RdMBToBcwJnSZbEwddyc3Qn5Arf6byxYTaOKy/RetWhhvUB84nlHVLYAbDdksSKN3dJo/a9/OgSGBpLAW/eFwkeEDVcQjhjKHRNfWr2DLsOjCDR/2HePClthN1zdQ/D9AvC0uvWu57l7v9BrR+KiiyqOVN8fE6rhlzymKcXOnAKOG+Rs8wTq8HcChx7iBWnMKadVT3qGKBYGbDzC5lJOOi1gor1X6wTSpbynWR1Np00aISOK9bzY17uog6jCqADEEezQ+fNdPA6pZYcRxRbIF0w5FynpnoV2cl73kBmuvzVXjISQE6Uq3zg8LPjJzrg73YrVJp0LKpSDiAUyF5SxdQfE6FV8t5tiVgVTHNzxBJYKnud8knhbbvVQ+sf4DK0FEmalCPX8FRFQjDgHWr3vmijbLQoeV96wgh/a1V3gQPzi0Fxbvi15u5qiSYxcx2aEYDh/rKGMt0cN+A= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BY2PR07MB1443; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1443; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 4:MepUIoBt1vi56Y3zD5TEV38lcxNpQVKqUfVWu6PNE3ICvJ5nAuu/TnKTw5hn5Dz9jTv/Y6jByNIOhVakScdlsIP+th5NfZrXuGHnnEaNqzEvV6xyKrhUn5u23LMrATxvlBbHDyuxInY5or4mzS/P8i/6u+CseoeKUNw7iba18lUSN/F96sEaFRZTkRpssM7gdOFKkcOhz21FF0H3kqtl4qIY1m4WN6zxnIilqnVWusJWVaB0kNuHsjC1q2nQoxGdfppGUjDZrKwR5QfQVoyZAQd6pi8vwSf7bVj3CVnuJc+3IZK1t08FNGuLMcjtnzf33t8gaKsNYDBxop+03A73LIWyWAXFNcW8gOXuxrtvwYHcIaA2c6MBRTG2+pn7+ztq X-Forefront-PRVS: 083526BF8A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(189002)(199003)(50226001)(5008740100001)(101416001)(33646002)(122386002)(36756003)(3470700001)(3846002)(6116002)(40100003)(1096002)(92566002)(586003)(48376002)(4326007)(2876002)(2906002)(42186005)(76176999)(50986999)(110136002)(107886002)(19580395003)(19580405001)(4001430100002)(97736004)(2351001)(47776003)(81156007)(87976001)(50466002)(5001960100002)(106356001)(2950100001)(229853001)(189998001)(86152002)(105586002)(66066001)(5003940100001)(77096005)(5004730100002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB1443; H:cavium1.semihalf.local; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; BY2PR07MB1443; 23:7SeTb2WvV5bIX+Ux/52uRnHmvbuYDyc1t6mu65MEJ?= =?us-ascii?Q?7xrY27NrVo1yajhWVfIcK9cygMeUi/RCU4kzaQghR83C9ArqDdI9TljUiGNH?= =?us-ascii?Q?7lnGTFI91T+wCJD8j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=?us-ascii?Q?KDeYIM54lwKOgCjoqRDiU0lQEUwEFH5g/2AIKDl53UFzULzyws35DgmZTkRu?= =?us-ascii?Q?bZXxqOUdwqGizMlBEr3fKvdmsq1adVJ7epv1FHNMsEZQNYUf/WU1YgyRgwIT?= =?us-ascii?Q?w0e94luZQAxUje8iQjf3a7KGTs78/+fxmOaFevWTCmDK7mpDFr8YrQquf6fV?= =?us-ascii?Q?4ZAYSwwxiR/hro=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1443; 5:kiZige9wWIW/HyqQ1bP4q68zpxKfeqDgl8BgclI4GfR+hNahZzEZUpVHCoNuMRe9wKfGm+fo8Hyl+ywXm24nuSVND11J97v3kURk8QcfKrJ+NCxggd7K/iZSMN8O759GLOsanH7ApXf7p4Ggbwzt0g==; 24:+FANXKRDa3N8RBIXppkYq1Cc5yR5L8Dpy23OcOQl+BaN7V63o9wMRAMa0XfrUoOg/eWTJaR0rEya8ZjgTw/3ylOCjaAaakqOPYq1MTM8USY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2016 13:14:25.3452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1443 Subject: [dpdk-dev] [PATCH v7 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: Thu, 28 Jan 2016 13:14:27 -0000 From: Kamil Rytarowski 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 Acked-by: David Marchand Acked-by: Yuanhan Liu --- 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; } -- 1.9.1