From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Marchand Subject: Re: [PATCH v2 2/2] eal/linux: Add support for handling built-in kernel modules Date: Mon, 7 Dec 2015 18:14:03 +0100 Message-ID: References: <1449499771-31466-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1449507460-32038-1-git-send-email-Kamil.Rytarowski@caviumnetworks.com> <1449507460-32038-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: "dev@dpdk.org" To: Kamil Rytarowski Return-path: Received: from mail-oi0-f53.google.com (mail-oi0-f53.google.com [209.85.218.53]) by dpdk.org (Postfix) with ESMTP id F08709A92 for ; Mon, 7 Dec 2015 18:14:03 +0100 (CET) Received: by oies6 with SMTP id s6so102597052oie.1 for ; Mon, 07 Dec 2015 09:14:03 -0800 (PST) In-Reply-To: <1449507460-32038-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hello Kamil, On Mon, Dec 7, 2015 at 5:57 PM, Kamil Rytarowski < Kamil.Rytarowski@caviumnetworks.com> 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 > > Signed-off-by: Kamil Rytarowski > --- > lib/librte_eal/linuxapp/eal/eal.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal.c > b/lib/librte_eal/linuxapp/eal/eal.c > index 635ec36..6cab906 100644 > --- a/lib/librte_eal/linuxapp/eal/eal.c > +++ b/lib/librte_eal/linuxapp/eal/eal.c > @@ -52,6 +52,8 @@ > #if defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_I686) > #include > #endif > +#include > +#include > > #include > #include > @@ -902,7 +904,10 @@ int > rte_eal_check_module(const char *module_name) > { > char mod_name[30]; /* Any module names can be longer than 30 > bytes? */ > + char sysfs_mod_name[PATH_MAX]; > + struct stat st; > int ret = 0; > + int rv; > int n; > > if (NULL == module_name) > @@ -918,9 +923,23 @@ rte_eal_check_module(const char *module_name) > n = fscanf(fd, "%29s %*[^\n]", mod_name); > if ((n == 1) && !strcmp(mod_name, module_name)) { > ret = 1; > - break; > + goto finish; > } > } > + RTE_LOG(DEBUG, EAL, "Module %s not found in /proc/modules", > + module_name); > + > + /* A module might be builtin, try sysfs */ > + snprintf(sysfs_mod_name, PATH_MAX, "/sys/module/%s", module_name); > + if ((rv = stat(sysfs_mod_name, &st)) == 0) { > + ret = 1; > + goto finish; > + } > + > + RTE_LOG(DEBUG, EAL, "Open %s failed! error %i (%s)\n", > + sysfs_mod_name, errno, strerror(errno)); > + > +finish: > fclose(fd); > > return ret; > Well, in the end, won't all modules end up in /sys/module ? So, I would say we can get rid of /proc/modules parsing. The only thing that bothers me is this comment in the kernel documentation : /sys/module/MODULENAME The name of the module that is in the kernel. This module name will always show up if the module is loaded as a dynamic module. If it is built directly into the kernel, it will only show up if it has a version or at least one parameter. Note: The conditions of creation in the built-in case are not by design and may be removed in the future. But, at the moment, I suppose we are fine. -- David Marchand