From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <david.marchand@6wind.com>
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 <dev@dpdk.org>; Mon,  7 Dec 2015 18:14:03 +0100 (CET)
Received: by oies6 with SMTP id s6so102597052oie.1
 for <dev@dpdk.org>; Mon, 07 Dec 2015 09:14:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=mime-version:in-reply-to:references:date:message-id:subject:from:to
 :cc:content-type;
 bh=p+KKDiYp5Pj0o3/a4jOFYb4iVwynbdKTZsXfAGWPOS0=;
 b=UGGWh7tZYvoNTgThjybaNALUU33awehN2YZbyHN8Pd1zFZDrF8aQ2fHBv09Tr+n3iK
 PMLRHXMWCFQapyGpMmUcTQbDPAuP+GtMcNp7bXRNajtOH9MGIdoEiAkKkSH7ObhFOjQ0
 oKpvrmN+dKI1+BJbSIHgkfkT8UUJxxL6hpyCzNHJv1B3qNDom6zSq4G5TkC+uZEQfTY/
 G+rE9uhnb6elRuhHds+LjmG8Wseh7J5HSF35uDTnPVV/UNRAbPL06bimlSUDfK4HkesC
 Y09gGQQo9Igbvp7yzypncY6cdt5IKWXGS7FXnf9vEmThkuxrlXVB+VSw7XPx9N5Z3WM0
 8ZXg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:in-reply-to:references:date
 :message-id:subject:from:to:cc:content-type;
 bh=p+KKDiYp5Pj0o3/a4jOFYb4iVwynbdKTZsXfAGWPOS0=;
 b=cCFwDG4cnrkXP0snx+5U0GfT9dIsE1qsiMv/dHDnfoiigbtbGkFOyHWJUOTH1EnsL3
 Ps4I8nlwnkuyejkh1IpI5fnWrJoYUfy4UtEld/alERYsUbTzL2wo11bRRww+AMCJTM+i
 ctSO5U65U1jrIcH9ssivVyIeIKdltJMxarFFl1ZwH6gvnz4wiI+tqufsMhnko5tI9xuP
 3Ol242yKshW8FkhgpU+9w4Iyv7IzBG1TXX6i0K31LKGdMRzZ7H9LznPgW1H2XyfSNuUB
 UieTlyF6tqWgUhFGOLst6M4S8TvOW7CvUztFgiPMH3WegI2ylmDPxFgvRJQgB4rtJUCb
 zx6w==
X-Gm-Message-State: ALoCoQkHyr0RxkkG1Q+iIjXYNFRojHsugKyWOI0T24mG/Pl3+lX/Bqyqm3L7Rc6I4zTTNeQnbqZ6
MIME-Version: 1.0
X-Received: by 10.202.104.91 with SMTP id d88mr22251934oic.57.1449508443277;
 Mon, 07 Dec 2015 09:14:03 -0800 (PST)
Received: by 10.76.153.5 with HTTP; Mon, 7 Dec 2015 09:14:03 -0800 (PST)
In-Reply-To: <1449507460-32038-2-git-send-email-Kamil.Rytarowski@caviumnetworks.com>
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>
Date: Mon, 7 Dec 2015 18:14:03 +0100
Message-ID: <CALwxeUsqNRkD80vCk0oLCVOktyKPDe2y7XnEavt2JriRPrd1rw@mail.gmail.com>
From: David Marchand <david.marchand@6wind.com>
To: Kamil Rytarowski <Kamil.Rytarowski@caviumnetworks.com>
Content-Type: text/plain; charset=UTF-8
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Dec 2015 17:14:04 -0000

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 <Kamil.Rytarowski@caviumnetworks.com>
> ---
>  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 <sys/io.h>
>  #endif
> +#include <sys/types.h>
> +#include <sys/stat.h>
>
>  #include <rte_common.h>
>  #include <rte_debug.h>
> @@ -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