* [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
@ 2015-12-09 13:19 ` Kamil Rytarowski
2015-12-09 16:38 ` Stephen Hemminger
2016-01-18 14:22 ` Yuanhan Liu
2015-12-16 14:14 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
` (3 subsequent siblings)
4 siblings, 2 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2015-12-09 13:19 UTC (permalink / raw)
To: dev
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..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;
}
--
2.6.3
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules
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
1 sibling, 1 reply; 42+ messages in thread
From: Stephen Hemminger @ 2015-12-09 16:38 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
On Wed, 9 Dec 2015 14:19:58 +0100
Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com> wrote:
> + /* 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;
> }
This check is redundant. Remove it.
If the later "/sys/module/foo" would fail if /sys/module was not present.
> - 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);
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules
2015-12-09 16:38 ` Stephen Hemminger
@ 2015-12-09 16:45 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2015-12-09 16:45 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: dev
W dniu 09.12.2015 o 17:38, Stephen Hemminger pisze:
> On Wed, 9 Dec 2015 14:19:58 +0100
> Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com> wrote:
>
>> + /* 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;
>> }
> This check is redundant. Remove it.
> If the later "/sys/module/foo" would fail if /sys/module was not present.
This check isn't redundant. It checks different thing (sysfs mounted vs
module loaded) and formulates different error message.
Please see pci_vfio_enable():
module_vfio_type1 = rte_eal_check_module("vfio_iommu_type1");
/* return error directly */
if (module_vfio_type1 == -1) {
RTE_LOG(INFO, EAL, "Could not get loaded module
details!\n");
return -1;
}
/* return 0 if VFIO modules not loaded */
if (module_vfio_type1 == 0) {
RTE_LOG(INFO, EAL, "VFIO modules not all loaded, "
"skip VFIO support...\n");
return 0;
}
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 2/2] eal/linux: " Kamil Rytarowski
2015-12-09 16:38 ` Stephen Hemminger
@ 2016-01-18 14:22 ` Yuanhan Liu
2016-01-19 16:38 ` Kamil Rytarowski
1 sibling, 1 reply; 42+ messages in thread
From: Yuanhan Liu @ 2016-01-18 14:22 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
On Wed, Dec 09, 2015 at 02:19:58PM +0100, 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>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Thanks.
--yliu
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 2/2] eal/linux: Add support for handling built-in kernel modules
2016-01-18 14:22 ` Yuanhan Liu
@ 2016-01-19 16:38 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-19 16:38 UTC (permalink / raw)
To: Yuanhan Liu, Kamil Rytarowski; +Cc: dev
W dniu 18.01.2016 o 15:22, Yuanhan Liu pisze:
> On Wed, Dec 09, 2015 at 02:19:58PM +0100, 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>
> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>
> Thanks.
>
> --yliu
Thank you, I will submit v6 and note you with the the Acked-by line.
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
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-16 14:14 ` Kamil Rytarowski
2016-01-18 9:26 ` Kamil Rytarowski
2016-01-18 14:21 ` Yuanhan Liu
` (2 subsequent siblings)
4 siblings, 1 reply; 42+ messages in thread
From: Kamil Rytarowski @ 2015-12-16 14:14 UTC (permalink / raw)
To: dev
ping?
W dniu 09.12.2015 o 14:19, Kamil Rytarowski pisze:
> Currently dpdk_nic_bind.py 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>
> ---
> tools/dpdk_nic_bind.py | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
> index f02454e..e161062 100755
> --- a/tools/dpdk_nic_bind.py
> +++ b/tools/dpdk_nic_bind.py
> @@ -156,22 +156,29 @@ def check_modules():
> '''Checks that igb_uio is loaded'''
> global dpdk_drivers
>
> - fd = file("/proc/modules")
> - loaded_mods = fd.readlines()
> - fd.close()
> -
> # list of supported modules
> mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
>
> # first check if module is loaded
> - for line in loaded_mods:
> + try:
> + # Get list of syfs modules, some of them might be builtin and merge with mods
> + sysfs_path = '/sys/module/'
> +
> + # Get the list of directories in sysfs_path
> + sysfs_mods = [os.path.join(sysfs_path,o) for o in os.listdir(sysfs_path) if os.path.isdir(os.path.join(sysfs_path,o))]
> +
> + # Extract the last element of '/sys/module/abc' in the array
> + sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
> +
> + # special case for vfio_pci (module is named vfio-pci,
> + # but its .ko is named vfio_pci)
> + sysfs_mods = map(lambda a: a if a != 'vfio_pci' else 'vfio-pci', sysfs_mods)
> +
> for mod in mods:
> - if line.startswith(mod["Name"]):
> - mod["Found"] = True
> - # special case for vfio_pci (module is named vfio-pci,
> - # but its .ko is named vfio_pci)
> - elif line.replace("_", "-").startswith(mod["Name"]):
> + if mod["Found"] == False and (mod["Name"] in sysfs_mods):
> mod["Found"] = True
> + except:
> + pass
>
> # check if we have at least one loaded module
> if True not in [mod["Found"] for mod in mods] and b_flag is not None:
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2015-12-16 14:14 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
@ 2016-01-18 9:26 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-18 9:26 UTC (permalink / raw)
To: dev
ping?
W dniu 16.12.2015 o 15:14, Kamil Rytarowski pisze:
> ping?
>
> W dniu 09.12.2015 o 14:19, Kamil Rytarowski pisze:
>> Currently dpdk_nic_bind.py 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>
>> ---
>> tools/dpdk_nic_bind.py | 27 +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
>> index f02454e..e161062 100755
>> --- a/tools/dpdk_nic_bind.py
>> +++ b/tools/dpdk_nic_bind.py
>> @@ -156,22 +156,29 @@ def check_modules():
>> '''Checks that igb_uio is loaded'''
>> global dpdk_drivers
>> - fd = file("/proc/modules")
>> - loaded_mods = fd.readlines()
>> - fd.close()
>> -
>> # list of supported modules
>> mods = [{"Name" : driver, "Found" : False} for driver in
>> dpdk_drivers]
>> # first check if module is loaded
>> - for line in loaded_mods:
>> + try:
>> + # Get list of syfs modules, some of them might be builtin
>> and merge with mods
>> + sysfs_path = '/sys/module/'
>> +
>> + # Get the list of directories in sysfs_path
>> + sysfs_mods = [os.path.join(sysfs_path,o) for o in
>> os.listdir(sysfs_path) if os.path.isdir(os.path.join(sysfs_path,o))]
>> +
>> + # Extract the last element of '/sys/module/abc' in the array
>> + sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
>> +
>> + # special case for vfio_pci (module is named vfio-pci,
>> + # but its .ko is named vfio_pci)
>> + sysfs_mods = map(lambda a: a if a != 'vfio_pci' else
>> 'vfio-pci', sysfs_mods)
>> +
>> for mod in mods:
>> - if line.startswith(mod["Name"]):
>> - mod["Found"] = True
>> - # special case for vfio_pci (module is named vfio-pci,
>> - # but its .ko is named vfio_pci)
>> - elif line.replace("_", "-").startswith(mod["Name"]):
>> + if mod["Found"] == False and (mod["Name"] in sysfs_mods):
>> mod["Found"] = True
>> + except:
>> + pass
>> # check if we have at least one loaded module
>> if True not in [mod["Found"] for mod in mods] and b_flag is not
>> None:
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
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-16 14:14 ` [dpdk-dev] [PATCH v5 1/2] tools: " 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-20 9:48 ` [dpdk-dev] [PATCH v6 " krytarowski
4 siblings, 1 reply; 42+ messages in thread
From: Yuanhan Liu @ 2016-01-18 14:21 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
Hi Kamil,
First of all, sorry for no one has reviewed your patches for over one
month! You may want to ping more often (say, per week) next time if it
still happenes :)
Another thing is that there is no maintainer for tools code.
On Wed, Dec 09, 2015 at 02:19:57PM +0100, Kamil Rytarowski wrote:
> Currently dpdk_nic_bind.py 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>
> ---
> tools/dpdk_nic_bind.py | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
> index f02454e..e161062 100755
> --- a/tools/dpdk_nic_bind.py
> +++ b/tools/dpdk_nic_bind.py
> @@ -156,22 +156,29 @@ def check_modules():
> '''Checks that igb_uio is loaded'''
> global dpdk_drivers
>
> - fd = file("/proc/modules")
> - loaded_mods = fd.readlines()
> - fd.close()
> -
> # list of supported modules
> mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
>
> # first check if module is loaded
> - for line in loaded_mods:
> + try:
> + # Get list of syfs modules, some of them might be builtin and merge with mods
> + sysfs_path = '/sys/module/'
> +
> + # Get the list of directories in sysfs_path
> + sysfs_mods = [os.path.join(sysfs_path,o) for o in os.listdir(sysfs_path) if os.path.isdir(os.path.join(sysfs_path,o))]
Minor nit: it's quite a long line; you may need break it. And space is
needed after ','.
Otherwise, this patch looks good to me.
--yliu
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2016-01-18 14:21 ` Yuanhan Liu
@ 2016-01-19 16:34 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-19 16:34 UTC (permalink / raw)
To: Yuanhan Liu, Kamil Rytarowski; +Cc: dev
Thank you, I will submit improved version as v6.
W dniu 18.01.2016 o 15:21, Yuanhan Liu pisze:
> Hi Kamil,
>
> First of all, sorry for no one has reviewed your patches for over one
> month! You may want to ping more often (say, per week) next time if it
> still happenes :)
>
> Another thing is that there is no maintainer for tools code.
>
> On Wed, Dec 09, 2015 at 02:19:57PM +0100, Kamil Rytarowski wrote:
>> Currently dpdk_nic_bind.py 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>
>> ---
>> tools/dpdk_nic_bind.py | 27 +++++++++++++++++----------
>> 1 file changed, 17 insertions(+), 10 deletions(-)
>>
>> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
>> index f02454e..e161062 100755
>> --- a/tools/dpdk_nic_bind.py
>> +++ b/tools/dpdk_nic_bind.py
>> @@ -156,22 +156,29 @@ def check_modules():
>> '''Checks that igb_uio is loaded'''
>> global dpdk_drivers
>>
>> - fd = file("/proc/modules")
>> - loaded_mods = fd.readlines()
>> - fd.close()
>> -
>> # list of supported modules
>> mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
>>
>> # first check if module is loaded
>> - for line in loaded_mods:
>> + try:
>> + # Get list of syfs modules, some of them might be builtin and merge with mods
>> + sysfs_path = '/sys/module/'
>> +
>> + # Get the list of directories in sysfs_path
>> + sysfs_mods = [os.path.join(sysfs_path,o) for o in os.listdir(sysfs_path) if os.path.isdir(os.path.join(sysfs_path,o))]
> Minor nit: it's quite a long line; you may need break it. And space is
> needed after ','.
>
> Otherwise, this patch looks good to me.
>
> --yliu
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
` (2 preceding siblings ...)
2016-01-18 14:21 ` Yuanhan Liu
@ 2016-01-18 14:32 ` Thomas Monjalon
2016-01-19 16:35 ` Kamil Rytarowski
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 " krytarowski
4 siblings, 1 reply; 42+ messages in thread
From: Thomas Monjalon @ 2016-01-18 14:32 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
Hi Kamil,
2015-12-09 14:19, Kamil Rytarowski:
> Currently dpdk_nic_bind.py 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>
I have a doubt about this tag:
> Signed-off-by: David Marchand <david.marchand@6wind.com>
What do you mean here?
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2016-01-18 14:32 ` Thomas Monjalon
@ 2016-01-19 16:35 ` Kamil Rytarowski
2016-01-26 15:12 ` Thomas Monjalon
0 siblings, 1 reply; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-19 16:35 UTC (permalink / raw)
To: Thomas Monjalon, Kamil Rytarowski; +Cc: dev
W dniu 18.01.2016 o 15:32, Thomas Monjalon pisze:
> Hi Kamil,
>
> 2015-12-09 14:19, Kamil Rytarowski:
>> Currently dpdk_nic_bind.py 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>
> I have a doubt about this tag:
>> Signed-off-by: David Marchand <david.marchand@6wind.com>
> What do you mean here?
Excuse me, it should be: Acked-by: David Marchand
<david.marchand@6wind.com>
http://dpdk.org/ml/archives/dev/2015-December/029720.html
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2016-01-19 16:35 ` Kamil Rytarowski
@ 2016-01-26 15:12 ` Thomas Monjalon
2016-01-28 11:16 ` Kamil Rytarowski
0 siblings, 1 reply; 42+ messages in thread
From: Thomas Monjalon @ 2016-01-26 15:12 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
2016-01-19 17:35, Kamil Rytarowski:
>
> W dniu 18.01.2016 o 15:32, Thomas Monjalon pisze:
> > Hi Kamil,
> >
> > 2015-12-09 14:19, Kamil Rytarowski:
> >> Currently dpdk_nic_bind.py 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>
> > I have a doubt about this tag:
> >> Signed-off-by: David Marchand <david.marchand@6wind.com>
> > What do you mean here?
>
> Excuse me, it should be: Acked-by: David Marchand
> <david.marchand@6wind.com>
>
> http://dpdk.org/ml/archives/dev/2015-December/029720.html
The ack was only for the patch 2/2
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v5 1/2] tools: Add support for handling built-in kernel modules
2016-01-26 15:12 ` Thomas Monjalon
@ 2016-01-28 11:16 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-28 11:16 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
W dniu 26.01.2016 o 16:12, Thomas Monjalon pisze:
> 2016-01-19 17:35, Kamil Rytarowski:
>> W dniu 18.01.2016 o 15:32, Thomas Monjalon pisze:
>>> Hi Kamil,
>>>
>>> 2015-12-09 14:19, Kamil Rytarowski:
>>>> Currently dpdk_nic_bind.py 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>
>>> I have a doubt about this tag:
>>>> Signed-off-by: David Marchand <david.marchand@6wind.com>
>>> What do you mean here?
>> Excuse me, it should be: Acked-by: David Marchand
>> <david.marchand@6wind.com>
>>
>> http://dpdk.org/ml/archives/dev/2015-December/029720.html
> The ack was only for the patch 2/2
I see. I will correct it.
^ permalink raw reply [flat|nested] 42+ messages in thread
* [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
2015-12-09 13:19 ` [dpdk-dev] [PATCH v5 1/2] tools: " Kamil Rytarowski
` (3 preceding siblings ...)
2016-01-18 14:32 ` Thomas Monjalon
@ 2016-01-20 9:48 ` krytarowski
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 2/2] eal/linux: " krytarowski
` (3 more replies)
4 siblings, 4 replies; 42+ messages in thread
From: krytarowski @ 2016-01-20 9:48 UTC (permalink / raw)
To: dev
From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
Currently dpdk_nic_bind.py 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>
Acked-by: David Marchand <david.marchand@6wind.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
tools/dpdk_nic_bind.py | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index f02454e..1d16d9f 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -156,22 +156,32 @@ def check_modules():
'''Checks that igb_uio is loaded'''
global dpdk_drivers
- fd = file("/proc/modules")
- loaded_mods = fd.readlines()
- fd.close()
-
# list of supported modules
mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
# first check if module is loaded
- for line in loaded_mods:
+ try:
+ # Get list of syfs modules, some of them might be builtin and merge with mods
+ sysfs_path = '/sys/module/'
+
+ # Get the list of directories in sysfs_path
+ sysfs_mods = [os.path.join(sysfs_path, o) for o
+ in os.listdir(sysfs_path)
+ if os.path.isdir(os.path.join(sysfs_path, o))]
+
+ # Extract the last element of '/sys/module/abc' in the array
+ sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
+
+ # special case for vfio_pci (module is named vfio-pci,
+ # but its .ko is named vfio_pci)
+ sysfs_mods = map(lambda a:
+ a if a != 'vfio_pci' else 'vfio-pci', sysfs_mods)
+
for mod in mods:
- if line.startswith(mod["Name"]):
- mod["Found"] = True
- # special case for vfio_pci (module is named vfio-pci,
- # but its .ko is named vfio_pci)
- elif line.replace("_", "-").startswith(mod["Name"]):
+ if mod["Found"] == False and (mod["Name"] in sysfs_mods):
mod["Found"] = True
+ except:
+ pass
# check if we have at least one loaded module
if True not in [mod["Found"] for mod in mods] and b_flag is not None:
--
1.9.1
^ permalink raw reply [flat|nested] 42+ messages in thread
* [dpdk-dev] [PATCH v6 2/2] eal/linux: Add support for handling built-in kernel modules
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 " krytarowski
@ 2016-01-20 9:48 ` krytarowski
2016-01-26 9:31 ` [dpdk-dev] [PATCH v6 1/2] tools: " Kamil Rytarowski
` (2 subsequent siblings)
3 siblings, 0 replies; 42+ messages in thread
From: krytarowski @ 2016-01-20 9:48 UTC (permalink / raw)
To: dev
From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
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>
Acked-by: David Marchand <david.marchand@6wind.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.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..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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
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 ` Kamil Rytarowski
2016-01-26 15:23 ` Thomas Monjalon
2016-01-28 13:13 ` [dpdk-dev] [PATCH v7 " krytarowski
3 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-26 9:31 UTC (permalink / raw)
To: dev
ping?
W dniu 20.01.2016 o 10:48, krytarowski@caviumnetworks.com pisze:
> From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
>
> Currently dpdk_nic_bind.py 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>
> Acked-by: David Marchand <david.marchand@6wind.com>
> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> ---
> tools/dpdk_nic_bind.py | 30 ++++++++++++++++++++----------
> 1 file changed, 20 insertions(+), 10 deletions(-)
>
> diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
> index f02454e..1d16d9f 100755
> --- a/tools/dpdk_nic_bind.py
> +++ b/tools/dpdk_nic_bind.py
> @@ -156,22 +156,32 @@ def check_modules():
> '''Checks that igb_uio is loaded'''
> global dpdk_drivers
>
> - fd = file("/proc/modules")
> - loaded_mods = fd.readlines()
> - fd.close()
> -
> # list of supported modules
> mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
>
> # first check if module is loaded
> - for line in loaded_mods:
> + try:
> + # Get list of syfs modules, some of them might be builtin and merge with mods
> + sysfs_path = '/sys/module/'
> +
> + # Get the list of directories in sysfs_path
> + sysfs_mods = [os.path.join(sysfs_path, o) for o
> + in os.listdir(sysfs_path)
> + if os.path.isdir(os.path.join(sysfs_path, o))]
> +
> + # Extract the last element of '/sys/module/abc' in the array
> + sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
> +
> + # special case for vfio_pci (module is named vfio-pci,
> + # but its .ko is named vfio_pci)
> + sysfs_mods = map(lambda a:
> + a if a != 'vfio_pci' else 'vfio-pci', sysfs_mods)
> +
> for mod in mods:
> - if line.startswith(mod["Name"]):
> - mod["Found"] = True
> - # special case for vfio_pci (module is named vfio-pci,
> - # but its .ko is named vfio_pci)
> - elif line.replace("_", "-").startswith(mod["Name"]):
> + if mod["Found"] == False and (mod["Name"] in sysfs_mods):
> mod["Found"] = True
> + except:
> + pass
>
> # check if we have at least one loaded module
> if True not in [mod["Found"] for mod in mods] and b_flag is not None:
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
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 13:13 ` [dpdk-dev] [PATCH v7 " krytarowski
3 siblings, 1 reply; 42+ messages in thread
From: Thomas Monjalon @ 2016-01-26 15:23 UTC (permalink / raw)
To: krytarowski; +Cc: dev
2016-01-20 10:48, krytarowski@caviumnetworks.com:
> --- a/tools/dpdk_nic_bind.py
> +++ b/tools/dpdk_nic_bind.py
> - for line in loaded_mods:
> + try:
> + # Get list of syfs modules, some of them might be builtin and merge with mods
Please could you explain this comment?
Is it remaining from previous versions of the patch?
[...]
> + # special case for vfio_pci (module is named vfio-pci,
> + # but its .ko is named vfio_pci)
Isn't it common to have dash replaced by underscore for kernel modules?
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
2016-01-26 15:23 ` Thomas Monjalon
@ 2016-01-28 11:17 ` Kamil Rytarowski
2016-01-28 11:22 ` Panu Matilainen
2016-01-28 13:52 ` Thomas Monjalon
0 siblings, 2 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-28 11:17 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
W dniu 26.01.2016 o 16:23, Thomas Monjalon pisze:
> 2016-01-20 10:48, krytarowski@caviumnetworks.com:
>> --- a/tools/dpdk_nic_bind.py
>> +++ b/tools/dpdk_nic_bind.py
>> - for line in loaded_mods:
>> + try:
>> + # Get list of syfs modules, some of them might be builtin and merge with mods
> Please could you explain this comment?
> Is it remaining from previous versions of the patch?
Yes. It might be changed to:
# Get list of sysfs modules (both built-in and dynamically loaded)
> [...]
>> + # special case for vfio_pci (module is named vfio-pci,
>> + # but its .ko is named vfio_pci)
> Isn't it common to have dash replaced by underscore for kernel modules?
>
I retained the logic for special case of vfio-pci. At the moment
(according to my knowledge) there are no other DPDK modules with this
name replacement.
I checked few example Linux modules and if a module is named with dash,
it's being replaced to underscore. The modprobe(8) tool can accept both
names as interchangeable (with dash and underscore).
Would you like to make it a general rule and replace all dashes with
underscores?
Thank you
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
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
1 sibling, 1 reply; 42+ messages in thread
From: Panu Matilainen @ 2016-01-28 11:22 UTC (permalink / raw)
To: Kamil Rytarowski, Thomas Monjalon; +Cc: dev
On 01/28/2016 01:17 PM, Kamil Rytarowski wrote:
>
>
> W dniu 26.01.2016 o 16:23, Thomas Monjalon pisze:
>> 2016-01-20 10:48, krytarowski@caviumnetworks.com:
>>> --- a/tools/dpdk_nic_bind.py
>>> +++ b/tools/dpdk_nic_bind.py
>>> - for line in loaded_mods:
>>> + try:
>>> + # Get list of syfs modules, some of them might be builtin
>>> and merge with mods
>> Please could you explain this comment?
>> Is it remaining from previous versions of the patch?
>
> Yes. It might be changed to:
> # Get list of sysfs modules (both built-in and dynamically loaded)
>
>> [...]
>>> + # special case for vfio_pci (module is named vfio-pci,
>>> + # but its .ko is named vfio_pci)
>> Isn't it common to have dash replaced by underscore for kernel modules?
>>
>
> I retained the logic for special case of vfio-pci. At the moment
> (according to my knowledge) there are no other DPDK modules with this
> name replacement.
>
> I checked few example Linux modules and if a module is named with dash,
> it's being replaced to underscore. The modprobe(8) tool can accept both
> names as interchangeable (with dash and underscore).
>
> Would you like to make it a general rule and replace all dashes with
> underscores?
It would be nice to behave the same as modprobe wrt dash and underscore,
yes.
- Panu -
> Thank you
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
2016-01-28 11:22 ` Panu Matilainen
@ 2016-01-28 12:54 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-28 12:54 UTC (permalink / raw)
To: Panu Matilainen, Thomas Monjalon; +Cc: dev
W dniu 28.01.2016 o 12:22, Panu Matilainen pisze:
> On 01/28/2016 01:17 PM, Kamil Rytarowski wrote:
>> I retained the logic for special case of vfio-pci. At the moment
>> (according to my knowledge) there are no other DPDK modules with this
>> name replacement.
>>
>> I checked few example Linux modules and if a module is named with dash,
>> it's being replaced to underscore. The modprobe(8) tool can accept both
>> names as interchangeable (with dash and underscore).
>>
>> Would you like to make it a general rule and replace all dashes with
>> underscores?
>
> It would be nice to behave the same as modprobe wrt dash and
> underscore, yes.
>
> - Panu -
>
My patch is intended to support built-in modules, the rest isn't that
trivial without changing the behavior.
I prototyped it and it added extra unnecessary complexity, while we just
want to handle vfio_pci -> vfio-pci.
I'm going to submit new version with improved comment in the code.
Please continue possible improvements in separate threads.
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
2016-01-28 11:17 ` Kamil Rytarowski
2016-01-28 11:22 ` Panu Matilainen
@ 2016-01-28 13:52 ` Thomas Monjalon
2016-01-28 15:33 ` Kamil Rytarowski
1 sibling, 1 reply; 42+ messages in thread
From: Thomas Monjalon @ 2016-01-28 13:52 UTC (permalink / raw)
To: Kamil Rytarowski; +Cc: dev
2016-01-28 12:17, Kamil Rytarowski:
>
> W dniu 26.01.2016 o 16:23, Thomas Monjalon pisze:
> > 2016-01-20 10:48, krytarowski@caviumnetworks.com:
> >> --- a/tools/dpdk_nic_bind.py
> >> +++ b/tools/dpdk_nic_bind.py
> >> - for line in loaded_mods:
> >> + try:
> >> + # Get list of syfs modules, some of them might be builtin and merge with mods
> > Please could you explain this comment?
> > Is it remaining from previous versions of the patch?
>
> Yes. It might be changed to:
> # Get list of sysfs modules (both built-in and dynamically loaded)
OK
> > [...]
> >> + # special case for vfio_pci (module is named vfio-pci,
> >> + # but its .ko is named vfio_pci)
> > Isn't it common to have dash replaced by underscore for kernel modules?
> >
>
> I retained the logic for special case of vfio-pci. At the moment
> (according to my knowledge) there are no other DPDK modules with this
> name replacement.
>
> I checked few example Linux modules and if a module is named with dash,
> it's being replaced to underscore. The modprobe(8) tool can accept both
> names as interchangeable (with dash and underscore).
>
> Would you like to make it a general rule and replace all dashes with
> underscores?
I don't know. Do what you think is best.
Thanks
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v6 1/2] tools: Add support for handling built-in kernel modules
2016-01-28 13:52 ` Thomas Monjalon
@ 2016-01-28 15:33 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-01-28 15:33 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
W dniu 28.01.2016 o 14:52, Thomas Monjalon pisze:
> 2016-01-28 12:17, Kamil Rytarowski:
> [...]
>>>> + # special case for vfio_pci (module is named vfio-pci,
>>>> + # but its .ko is named vfio_pci)
>>> Isn't it common to have dash replaced by underscore for kernel modules?
>>>
>> I retained the logic for special case of vfio-pci. At the moment
>> (according to my knowledge) there are no other DPDK modules with this
>> name replacement.
>>
>> I checked few example Linux modules and if a module is named with dash,
>> it's being replaced to underscore. The modprobe(8) tool can accept both
>> names as interchangeable (with dash and underscore).
>>
>> Would you like to make it a general rule and replace all dashes with
>> underscores?
> I don't know. Do what you think is best.
> Thanks
I suggest to leave it as it is. There is no need to add a layer of
abstraction for a single known exception.
Also, this is out of scope of my patch.
Thank you.
^ permalink raw reply [flat|nested] 42+ messages in thread
* [dpdk-dev] [PATCH v7 1/2] tools: Add support for handling built-in kernel modules
2016-01-20 9:48 ` [dpdk-dev] [PATCH v6 " krytarowski
` (2 preceding siblings ...)
2016-01-26 15:23 ` Thomas Monjalon
@ 2016-01-28 13:13 ` krytarowski
2016-01-28 13:13 ` [dpdk-dev] [PATCH v7 2/2] eal/linux: " krytarowski
2016-01-29 7:21 ` [dpdk-dev] [PATCH v7 1/2] tools: " Yuanhan Liu
3 siblings, 2 replies; 42+ messages in thread
From: krytarowski @ 2016-01-28 13:13 UTC (permalink / raw)
To: dev
From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
Currently dpdk_nic_bind.py 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>
---
tools/dpdk_nic_bind.py | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/tools/dpdk_nic_bind.py b/tools/dpdk_nic_bind.py
index f02454e..85cb6f1 100755
--- a/tools/dpdk_nic_bind.py
+++ b/tools/dpdk_nic_bind.py
@@ -156,22 +156,32 @@ def check_modules():
'''Checks that igb_uio is loaded'''
global dpdk_drivers
- fd = file("/proc/modules")
- loaded_mods = fd.readlines()
- fd.close()
-
# list of supported modules
mods = [{"Name" : driver, "Found" : False} for driver in dpdk_drivers]
# first check if module is loaded
- for line in loaded_mods:
+ try:
+ # Get list of sysfs modules (both built-in and dynamically loaded)
+ sysfs_path = '/sys/module/'
+
+ # Get the list of directories in sysfs_path
+ sysfs_mods = [os.path.join(sysfs_path, o) for o
+ in os.listdir(sysfs_path)
+ if os.path.isdir(os.path.join(sysfs_path, o))]
+
+ # Extract the last element of '/sys/module/abc' in the array
+ sysfs_mods = [a.split('/')[-1] for a in sysfs_mods]
+
+ # special case for vfio_pci (module is named vfio-pci,
+ # but its .ko is named vfio_pci)
+ sysfs_mods = map(lambda a:
+ a if a != 'vfio_pci' else 'vfio-pci', sysfs_mods)
+
for mod in mods:
- if line.startswith(mod["Name"]):
- mod["Found"] = True
- # special case for vfio_pci (module is named vfio-pci,
- # but its .ko is named vfio_pci)
- elif line.replace("_", "-").startswith(mod["Name"]):
+ if mod["Name"] in sysfs_mods:
mod["Found"] = True
+ except:
+ pass
# check if we have at least one loaded module
if True not in [mod["Found"] for mod in mods] and b_flag is not None:
--
1.9.1
^ permalink raw reply [flat|nested] 42+ messages in thread
* [dpdk-dev] [PATCH v7 2/2] eal/linux: Add support for handling built-in kernel modules
2016-01-28 13:13 ` [dpdk-dev] [PATCH v7 " krytarowski
@ 2016-01-28 13:13 ` krytarowski
2016-02-09 14:56 ` Thomas Monjalon
2016-01-29 7:21 ` [dpdk-dev] [PATCH v7 1/2] tools: " Yuanhan Liu
1 sibling, 1 reply; 42+ messages in thread
From: krytarowski @ 2016-01-28 13:13 UTC (permalink / raw)
To: dev
From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
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>
Acked-by: David Marchand <david.marchand@6wind.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.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..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
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v7 2/2] eal/linux: Add support for handling built-in kernel modules
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
0 siblings, 1 reply; 42+ messages in thread
From: Thomas Monjalon @ 2016-02-09 14:56 UTC (permalink / raw)
To: krytarowski, Kamil Rytarowski; +Cc: dev
2016-01-28 14:13, krytarowski@caviumnetworks.com:
> From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
>
> 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>
> Acked-by: David Marchand <david.marchand@6wind.com>
> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
An include is missing:
#include <sys/stat.h>
After adding this line,
Series applied, thanks
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v7 2/2] eal/linux: Add support for handling built-in kernel modules
2016-02-09 14:56 ` Thomas Monjalon
@ 2016-02-09 16:07 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-02-09 16:07 UTC (permalink / raw)
To: Thomas Monjalon; +Cc: dev
Thank you!
W dniu 09.02.2016 o 15:56, Thomas Monjalon pisze:
> 2016-01-28 14:13, krytarowski@caviumnetworks.com:
>> From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
>>
>> 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>
>> Acked-by: David Marchand <david.marchand@6wind.com>
>> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> An include is missing:
> #include <sys/stat.h>
> After adding this line,
> Series applied, thanks
>
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v7 1/2] tools: Add support for handling built-in kernel modules
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-01-29 7:21 ` Yuanhan Liu
2016-02-08 22:14 ` Kamil Rytarowski
1 sibling, 1 reply; 42+ messages in thread
From: Yuanhan Liu @ 2016-01-29 7:21 UTC (permalink / raw)
To: krytarowski; +Cc: dev
On Thu, Jan 28, 2016 at 02:13:53PM +0100, krytarowski@caviumnetworks.com wrote:
> From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
>
> Currently dpdk_nic_bind.py 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>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
--yliu
^ permalink raw reply [flat|nested] 42+ messages in thread
* Re: [dpdk-dev] [PATCH v7 1/2] tools: Add support for handling built-in kernel modules
2016-01-29 7:21 ` [dpdk-dev] [PATCH v7 1/2] tools: " Yuanhan Liu
@ 2016-02-08 22:14 ` Kamil Rytarowski
0 siblings, 0 replies; 42+ messages in thread
From: Kamil Rytarowski @ 2016-02-08 22:14 UTC (permalink / raw)
To: Yuanhan Liu; +Cc: dev
ping?
W dniu 29.01.2016 o 08:21, Yuanhan Liu pisze:
> On Thu, Jan 28, 2016 at 02:13:53PM +0100, krytarowski@caviumnetworks.com wrote:
>> From: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
>>
>> Currently dpdk_nic_bind.py 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>
> Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>
> --yliu
^ permalink raw reply [flat|nested] 42+ messages in thread