From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0071.outbound.protection.outlook.com [207.46.100.71]) by dpdk.org (Postfix) with ESMTP id E74F33195 for ; Tue, 8 Dec 2015 16:34:22 +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 CY1PR07MB1446.namprd07.prod.outlook.com (10.161.167.144) with Microsoft SMTP Server (TLS) id 15.1.337.19; Tue, 8 Dec 2015 15:34:20 +0000 From: Kamil Rytarowski To: Date: Tue, 8 Dec 2015 16:33:53 +0100 Message-ID: <1449588833-485-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1449588833-485-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> References: <1449513365-22282-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1449588833-485-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: AM2PR09CA0028.eurprd09.prod.outlook.com (25.161.22.166) To CY1PR07MB1446.namprd07.prod.outlook.com (25.161.167.144) X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 2:F0Ed1URv48MCJBUfgBJuZou9t9BnLuZJHDGz/lIQn/OmPOqEmOFYkfEQ/YoVo2b6uPD5UY+vo/4UleBIZlH66hUc0CPUdE3Bwiw3sc5s/c4goi25zF33rpnmJtgXWyuDxqt3YkXxH3Pj93/wCFX1mQ==; 3:JuQfrurVTq/3qYfHPyO3VC6Yp9NQ8Z2iXNO2REbeQ6ej1q4/WV9n1Goq/e2HEXhleMgTDaosOQctyHDw9aGHe+ltUiMmfr9J037Gl21rwA3rgJSSyqWXdSza8wYpKVGm; 25:RES48e8a9KrbVKDhUQdvF/wZXx7ZzAuhHkG4f1qxuggfsS1sRLJSLVyxn5DejiWZXbFqIeNf6S4f2eQbUQldVLAmSiB0PZAVgKB1cV/rm/m9c0w0VDR2hLXHkfuhHq7Cz9P4HlJos7bFkfck91yygzhH21ucZcR/PuQHCd8TWjF3GKPTs5EZc/upGTiIE8ekgxm3fRPgrYJMjw+yWETsIKZ1+JcRutKOiyoNCA7+3afnrmPfv18vwBliBE4vga4QGc3d2Dwqa2ygsQGa6wRX0Q== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR07MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 20:MQJqn3htdVykZP3c7I/lQDG1gcRPy0zNiNEfXEfFK4fZzB+PobZ7krqBE2IvDMbBW1ByhZmBYVX53ct8VEPIbFJ0Pf0IQs6baaIsW4vhnyfb85FNYe54xx6GVn2ZuPlLMHh2bOPydudbtHC5UjD0EHHVttho3v2QCCiZBfpPzxwjGHpqv9leYHRiSH0086VEL5fSF+AVBrLEOAmykUsIx0hARkwyvzKQOVoaAVzQT5G/AnzLeF5UXP0ci/yZI+7P9DtuRc1J+PUukfpgDbng0Xzs3/nkyYXfKqGs4m7NN19EmOPDuZwrPK/eDDPpONSv7fHV9D/vgkFnMeAkVrdnW9/eceXYyWcVVxBPL9WNPS80CAQBSf9PHqUTDYr/CKR0arxPlDmddgvx/LcLf0sjVArb4ZAj+Xh0uh01uH4hgTFF3ToQ+MtNaY6Ehoc7KqeBsfu5s65fPGP5PHLbEWzdkLq1demtuE+bCf7B11sEc80TCsA9xGpOAJTx6CSsZnm/ca4Y89jCoh4bseTgbLmE69MKTJ+DZGR3mxVRf5LZiE/lhNelhJY95VmXw4XhQbW5NMFbPE6eY2jPK3tyeDhp5OMoT7clgV5TN6I3+xuzJQE= 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:CY1PR07MB1446; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 4:QN9GfKXh1Gupe9wY+kHtnZL+6ZiAfWO18RqXQF9JjoLknk7PzuYimBXWl4btuZBzIj5WPrvG7tUvjmbxr4Cl+4L3k9zX6NC15j7PQ9tDDsVIRwL83TGJzsnPw0/hslJuxMzf10upkEJyVVhn5PdWWKJtTPccOBX8O57iNpwvZQ5znk/QZ1knYlmZWdZR5MGq80W/25Y7XzInukJAs0ZZDeCCU1qoG6DwR6SdrG76t/Sa3gD4tJUoCgn/kXqymPv2uYGha1YSbgUw5FfAkjdc89weY/xSJaGBanN875e6gaeoW5zvX47SWTx6NQPshzDxDRdZh46mVNtWtR8TgjY8nKL5rbh5cYRWuvnt4Ve+bKLcvJ1a8WBMvP50Zgo6SRDn7ZDQnGt31BKalOdBV7yPKOgeI1NTdIsIsQnIc+3FJt+vKqbRPPn9MnL3Yxf7Yu2z X-Forefront-PRVS: 0784C803FD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(122386002)(19580395003)(107886002)(106356001)(86362001)(5001960100002)(76176999)(50226001)(2351001)(50986999)(97736004)(105586002)(40100003)(5004730100002)(48376002)(189998001)(110136002)(229853001)(19580405001)(81156007)(92566002)(5003940100001)(77096005)(47776003)(2950100001)(87976001)(50466002)(586003)(66066001)(42186005)(3846002)(36756003)(4001430100002)(101416001)(1096002)(5008740100001)(6116002)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB1446; 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; CY1PR07MB1446; 23:UbTaMiPehKYOxfi2fSzaPKtHuhOBv9Hm+zkMTGaPe?= =?us-ascii?Q?nj8NNfqd/Kv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LMjZ5?= =?us-ascii?Q?Plvths9Lls0XsBEeLVws/T96xKn0tYO9jtSSaTXWpyHNFO64Qljy+wYcuH1W?= =?us-ascii?Q?J4J0ku+CwO2xlr4zHrx3fx0JDf5y9g2cpR/7YGqJrafdhII/HTRIM46SJ2qP?= =?us-ascii?Q?/0MM2xFhgf3cdz3I9fSc7cNhsiw9gsQ/Vk3nlo1hwUzTOe0Xg=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB1446; 5:ympb0N62V5rsM2//vw2PHEzWKT+Pw/cVTnHzgcOhGGcGu9jlMjCfRbbe76RL6p7iNScFjUuyukzBpCrF4EalAeVNtVzBPj+a5CAUAFx42GxVr2I4fAl6umkXSZi99BxeITHhjL+ArhHzkAjDGZO3SA==; 24:NAB7fJLxsy+SSxnltbPD39BYpa6XD0yjkWvT87EzyJ8JrElL75+54Iwyx6TqGTkfUSc7h0c+kmAxZOKbwe/KCoh9z9jXQjg5mxuN9ZYEzkY= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2015 15:34:20.8348 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB1446 Subject: [dpdk-dev] [PATCH v4 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: Tue, 08 Dec 2015 15:34:23 -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..92482a0 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, "Open %s failed! error %i (%s)\n", + sysfs_mod_name, errno, strerror(errno)); + return 0; + } + + /* Module has been found */ + return 1; } -- 1.9.1