From: Kamil Rytarowski <krytarowski@caviumnetworks.com>
To: Panu Matilainen <pmatilai@redhat.com>,
Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>,
<dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v4 2/2] eal/linux: Add support for handling built-in kernel modules
Date: Wed, 9 Dec 2015 14:28:10 +0100 [thread overview]
Message-ID: <56682C6A.8030806@caviumnetworks.com> (raw)
In-Reply-To: <5667D879.9020006@redhat.com>
W dniu 09.12.2015 o 08:30, Panu Matilainen pisze:
> On 12/08/2015 05:33 PM, Kamil Rytarowski wrote:
>> 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 <Kamil.Rytarowski@caviumnetworks.com>
>> Signed-off-by: David Marchand <david.marchand@6wind.com>
>> ---
>> 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;
>> + }
>
> Like with /sys/module, its not trying to *open* sysfs_mod_name
> directory either so it shouldn't claim to do so.
>
> I did use plural on purpose when I said "the debug messages are
> incorrect/misleading. It's certainly not trying to *open* these
> directories so it should not claim to do so" in my previous mail :)
>
> - Panu -
>
Should be good now!
Thank you.
next prev parent reply other threads:[~2015-12-09 13:28 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1449499771-31466-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com>
2015-12-07 16:57 ` [dpdk-dev] [PATCH v2 1/2] tools: " Kamil Rytarowski
2015-12-07 16:57 ` [dpdk-dev] [PATCH v2 2/2] eal/linux: " Kamil Rytarowski
2015-12-07 17:14 ` David Marchand
2015-12-07 18:36 ` [dpdk-dev] [PATCH v3 1/2] tools: " Kamil Rytarowski
2015-12-07 18:36 ` [dpdk-dev] [PATCH v3 2/2] eal/linux: " Kamil Rytarowski
2015-12-07 20:45 ` David Marchand
2015-12-07 20:55 ` Stephen Hemminger
2015-12-08 7:25 ` Panu Matilainen
2015-12-08 13:08 ` Kamil Rytarowski
2015-12-08 15:33 ` [dpdk-dev] [PATCH v4 1/2] tools: " Kamil Rytarowski
2015-12-08 15:33 ` [dpdk-dev] [PATCH v4 2/2] eal/linux: " Kamil Rytarowski
2015-12-09 7:30 ` Panu Matilainen
2015-12-09 13:28 ` Kamil Rytarowski [this message]
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 2/2] eal/linux: " Kamil Rytarowski
2015-12-09 16:38 ` Stephen Hemminger
2015-12-09 16:45 ` Kamil Rytarowski
2016-01-18 14:22 ` Yuanhan Liu
2016-01-19 16:38 ` Kamil Rytarowski
2015-12-16 14:14 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
2016-01-18 9:26 ` Kamil Rytarowski
2016-01-18 14:21 ` Yuanhan Liu
2016-01-19 16:34 ` Kamil Rytarowski
2016-01-18 14:32 ` Thomas Monjalon
2016-01-19 16:35 ` Kamil Rytarowski
2016-01-26 15:12 ` Thomas Monjalon
2016-01-28 11:16 ` Kamil Rytarowski
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 " krytarowski
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 2/2] eal/linux: " krytarowski
2016-01-26 9:31 ` [dpdk-dev] [PATCH v6 1/2] tools: " Kamil Rytarowski
2016-01-26 15:23 ` Thomas Monjalon
2016-01-28 11:17 ` Kamil Rytarowski
2016-01-28 11:22 ` Panu Matilainen
2016-01-28 12:54 ` Kamil Rytarowski
2016-01-28 13:52 ` Thomas Monjalon
2016-01-28 15:33 ` Kamil Rytarowski
2016-01-28 13:13 ` [dpdk-dev] [PATCH v7 " krytarowski
2016-01-28 13:13 ` [dpdk-dev] [PATCH v7 2/2] eal/linux: " krytarowski
2016-02-09 14:56 ` Thomas Monjalon
2016-02-09 16:07 ` Kamil Rytarowski
2016-01-29 7:21 ` [dpdk-dev] [PATCH v7 1/2] tools: " Yuanhan Liu
2016-02-08 22:14 ` Kamil Rytarowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56682C6A.8030806@caviumnetworks.com \
--to=krytarowski@caviumnetworks.com \
--cc=Kamil.Rytarowski@caviumnetworks.com \
--cc=dev@dpdk.org \
--cc=pmatilai@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).