From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2on0090.outbound.protection.outlook.com [65.55.169.90]) by dpdk.org (Postfix) with ESMTP id 42CE55A71 for ; Wed, 20 Jan 2016 10:49:01 +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 BY2PR07MB1444.namprd07.prod.outlook.com (10.162.76.146) with Microsoft SMTP Server (TLS) id 15.1.390.13; Wed, 20 Jan 2016 09:48:59 +0000 From: To: Date: Wed, 20 Jan 2016 10:48:37 +0100 Message-ID: <1453283317-1078-2-git-send-email-krytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> References: <1449667198-27218-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1453283317-1078-1-git-send-email-krytarowski@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [213.17.239.108] X-ClientProxiedBy: AM3PR05CA017.eurprd05.prod.outlook.com (10.141.192.27) To BY2PR07MB1444.namprd07.prod.outlook.com (25.162.76.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 2:WbN8X6FDMbYD6OJZoL8d4KUc1xFjcJqQXofANz5GnLsJnvRKAlV8YBIqnyAlDeWv8PI+uXE5OnFMYL//pJIpt4Cr0rd4pW+QnM43mbaf2rOF49g34GVheQSa5XCIr7jDxf+Z9vAyIyWCo1PVVkZJWw==; 3:Ghcl+K5SpNH+QUaoEb58UT7yZa9SMFyR82yw2ISaaO2/IVU0DKU4bla5KApd/NoAEpBg8+uDk2yEcFHKxPz6kuMNcSXWRMEkFPWaKn3WE9WAlSXcQ71JZ2POWq1LWptb; 25:lL/1KLBmVqesSmarukYIWPxVUzLlI1dU40WYFtOQQ6+1VXZvL9EwWFqN5Wli1Gm8RYZOZgMQi0M/frpVjKLJhYcTKm3OM3IYYHEWVA+0i2W/bqjjd5cYs1CXGu57BsqQR6BlOUv5lSM2RP3M0vGn7RhcCrBRaV1O30VISQFOMsI/gz8oiGaW97ziJLn59sMMtcs+jDSCo2XIDJLouks4n+5X3hLqiJZwJCO3Qxua+YhcZZDFbz6VbDXMPOCHxUVH X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB1444; X-MS-Office365-Filtering-Correlation-Id: 530a70ec-a527-45bc-b856-08d3217eec5a X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 20:B+iPDhYbpK7/ECXTBJ9eZjpWlNXpKQL91rlrDb3BgCVI37kiNs3qLFG5QksJm2P0TrCqLXweLMWy1yuTs8gWYZPbuZ6+8Vn45QGzNhQs3KZ50MGq0njv1IbIABn0h6R23wZ8llt9BK1C4bz1RXmMitrpFkpGieirzuoRhNF48smu7qFf4oOCH2HsDA/+JoaapCIZ3mdaQ8QkrKj33m+ISJE2HdNpOhyjNRniEsppisrFbH/Y432hIJELTwQW/8QBbjbwhVhNKYqLdvnzcWXw4ZdZMXAr6F+V5QjrcE1Ii8ZIKiahj+PaIHsFZ1Hmz1b2d4ijhplBPLC/+YWSdznIxZ1IFMeonVygPMSyhfJcV0oMcXGhK8MVeWce0gxXcHbkJah2o13bdOdmlK16ZL2k01i9Nf67HQFVnxhJo3gU7cRswJ5FPGdKJh9lq7add8jik0wFeBM8qUfd8x77q6Y5vExQVfCXgxAq6LR+BGIOemmpk4tSavESbRBpJPofV2j48pnaReCVIOHFFrdukI8v2bzuRwIy1+MLoSGTiGvCex7xF3jReZ8YUM6T9MrVRR2QS7n8BiuLOraJ7/fgizFpkuG72kHycKK4plw4SMFJgHQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(123027)(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:BY2PR07MB1444; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB1444; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 4:FNux3DJqjhkS76vw3b9cZjNTPJTsOSAfWvycSsTRom+r/qBhU3stzNifA7ozUPPfXR9pFHO/ac7CT3vmOFWA9zpbrtkyIMFeXwXlgMuLuXkMZoJopIlGELMslNnyOVb17oxAr39CBBzXilkRDFbf94XiempK4VsUUujwrf29Z4IkHjWhpk8P5LP3dCwn2PB8if3/Ah8f+4u0yIAHrYF3H7RBXsxPNdjzMdI3fDNmFgZh+xtWzS38Fevq/iPnOFuPFT2J8IyPKHBQkfu8LuF3OrzJbDugR8oFJSyDCJK+D2VqxFBdjDi6GuXd6q+xOtll7dc1Lu90QOFV9nOXUHzWvV3ahWvwFpi2cy90tPQkuUiaGa2IO4hqW13zy7yOY7+fvVxn6mmwu00Bn+4waAdzIA== X-Forefront-PRVS: 0827D7ACB9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(1096002)(229853001)(2351001)(19580395003)(19580405001)(4326007)(2950100001)(2906002)(92566002)(33646002)(6116002)(3846002)(586003)(106356001)(105586002)(50986999)(42186005)(87976001)(76176999)(36756003)(97736004)(189998001)(5008740100001)(107886002)(5001960100002)(122386002)(47776003)(81156007)(66066001)(110136002)(5004730100002)(40100003)(77096005)(2876002)(5003940100001)(86152002)(50226001)(101416001)(48376002)(50466002)(4001430100002); 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:42/BDHUFxCjFCgkJPX7sTWhRXTe8ZNrlkP8Ay75ix?= =?us-ascii?Q?VJsQ1ObnswQAftaBQEAAuW4S5FMz3hbBp6jdfbdvy75esK3E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IWOHyUy/KH2z2ZjDD5AaREVIcMivprh0?= =?us-ascii?Q?HLQQYie28qnSHzROzMFJp5TJP2/qG3I04DIvmJpgXsTVKefNEA203BU+KdAI?= =?us-ascii?Q?H69sZvg4W6Q9YiS5oCqioOT4LipfLjhHvadaqu73p5NSnvG0XlQokbI2tT5t?= =?us-ascii?Q?RSTRrtyQR2C800a/ZsPcSKZdcmllRC/?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB1444; 5:H0aLQRsC24ED9RiKXciyQQsnzlu4GAtIqRKqmogxtKPuV8re7aE8y9GzC5kgFYfz4kc2X7pXQ8yWwe39R329PSieYpZ2cS5uyv+Qtm1sliO64zmnes4/aq1bPCK2aw53M9a5jwk5rizkqtpYJ89QDQ==; 24:+08FoVvrvPj7vi7Ntz7iiGA3HTZqRjiMMn+4I7QW7eryz07EG40s0ycKIKqrdjEWCSgzyBx38l6A99MBlJ1UBFNEf7eyvBlDbQXhzJ78qdI= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2016 09:48:59.1679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB1444 Subject: [dpdk-dev] [PATCH v6 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, 20 Jan 2016 09:49:01 -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