All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Goulet <dgoulet@efficios.com>
To: Umut Tezduyar Lindskog <umut.tezduyar@axis.com>
Cc: lttng-dev@lists.lttng.org, Umut Tezduyar Lindskog <umuttl@axis.com>
Subject: Re: [PATCH] Load modules through kmod
Date: Mon, 8 Sep 2014 15:36:11 -0400	[thread overview]
Message-ID: <20140908193611.GH6836__3703.46224303848$1410205031$gmane$org@thessa> (raw)
In-Reply-To: <1409819453-24245-1-git-send-email-umut.tezduyar@axis.com>


[-- Attachment #1.1: Type: text/plain, Size: 4661 bytes --]

Merged!

I've made some basic syntax fix.

Big thanks for this!

Cheers!
David

On 04 Sep (10:30:53), Umut Tezduyar Lindskog wrote:
> Instead of forking processes, load modules through libkmod.
> 
> This adds an optional package dependency to kmod but can be
> disabled by --disable-kmod option in ./configure. If
> --enable-kmod option is given but no kmod is found, loading
> will happen by forking a process.
> 
> The startup time has decreased by %36 on our embedded mips
> product. The measurement is done by cgroup cpu shares.
> ---
>  configure.ac                      |   34 ++++++++++++++++++++++++
>  src/bin/lttng-sessiond/modprobe.c |   53 +++++++++++++++++++++++++++++++++++++
>  2 files changed, 87 insertions(+)
> 
> diff --git a/configure.ac b/configure.ac
> index a8e04f5..fb0b03f 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -200,6 +200,32 @@ AC_CHECK_DECL([cmm_smp_mb__before_uatomic_or], [],
>          [AC_MSG_ERROR([liburcu $liburcu_version or newer is needed])], [[#include <urcu.h>]]
>  )
>  
> +# Check kmod library
> +AC_ARG_WITH(kmod-prefix,
> +  AS_HELP_STRING([--with-kmod-prefix=PATH],
> +                 [Specify the installation prefix of the kmod library.
> +	          Headers must be in PATH/include; libraries in PATH/lib.]),
> +		  [
> +		    CPPFLAGS="$CPPFLAGS -I${withval}/include"
> +		    LDFLAGS="$LDFLAGS -L${withval}/lib64 -L${withval}/lib"
> +		  ])
> +
> +AC_ARG_ENABLE(kmod,
> +	AS_HELP_STRING([--disable-kmod],[build without kmod support]),
> +	kmod_support=$enableval, kmod_support=yes)
> +
> +AS_IF([test "x$kmod_support" = "xyes"], [
> +	AC_CHECK_LIB([kmod], [kmod_module_probe_insert_module],
> +		[
> +			AC_DEFINE([HAVE_KMOD], [1], [has kmod support])
> +			LIBS="$LIBS -lkmod"
> +			kmod_found=yes
> +		],
> +		kmod_found=no
> +	)
> +])
> +AM_CONDITIONAL([HAVE_KMOD], [test "x$kmod_found" = xyes])
> +
>  AC_ARG_WITH(lttng-ust-prefix,
>    AS_HELP_STRING([--with-lttng-ust-prefix=PATH],
>                   [Specify the installation prefix of the lttng-ust library.
> @@ -483,6 +509,14 @@ done
>  AS_ECHO_N("Target architecture: ")
>  AS_ECHO($target_arch)
>  
> +# kmod enabled/disabled
> +AS_ECHO_N("kmod support: ")
> +AS_IF([test "x$kmod_found" = "xyes"],[
> +	AS_ECHO("Enabled")
> +],[
> +	AS_ECHO("Disabled")
> +])
> +
>  # LTTng-UST enabled/disabled
>  AS_ECHO_N("Lttng-UST support: ")
>  AS_IF([test "x$lttng_ust_support" = "xyes"],[
> diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c
> index 3cc67f0..40a2ee0 100644
> --- a/src/bin/lttng-sessiond/modprobe.c
> +++ b/src/bin/lttng-sessiond/modprobe.c
> @@ -164,6 +164,58 @@ void modprobe_remove_lttng_all(void)
>  	modprobe_remove_lttng_control();
>  }
>  
> +#if HAVE_KMOD
> +#include <libkmod.h>
> +static void log_kmod(void *data, int priority, const char *file, int line,
> +		     const char *fn, const char *format, va_list args)
> +{
> +	char *str;
> +	if (vasprintf(&str, format, args) < 0)
> +		return;
> +	DBG("libkmod: %s", str);
> +	free(str);
> +}
> +static int modprobe_lttng(struct kern_modules_param *modules,
> +			  int entries, int required)
> +{
> +	int ret = 0, i;
> +	struct kmod_ctx *ctx;
> +
> +	ctx = kmod_new(NULL, NULL);
> +	if (!ctx) {
> +		PERROR("Unable to create kmod library context");
> +		ret = -ENOMEM;
> +		goto error;
> +	}
> +
> +	kmod_set_log_fn(ctx, log_kmod, NULL);
> +	kmod_load_resources(ctx);
> +
> +	for (i = 0; i < entries; i++) {
> +		struct kmod_module *mod = NULL;
> +
> +		ret = kmod_module_new_from_name(ctx, modules[i].name, &mod);
> +		if (ret < 0) {
> +			PERROR("Failed to create kmod module for %s", modules[i].name);
> +			goto error;
> +		}
> +
> +		ret = kmod_module_probe_insert_module(mod, KMOD_PROBE_IGNORE_LOADED, NULL, NULL, NULL, NULL);
> +		if (required && ret < 0) {
> +			ERR("Unable to load module %s", modules[i].name);
> +		} else {
> +			DBG("Modprobe successfully %s", modules[i].name);
> +		}
> +
> +		kmod_module_unref(mod);
> +	}
> +
> +error:
> +	if (ctx)
> +		kmod_unref(ctx);
> +	return ret;
> +}
> +#else
>  static int modprobe_lttng(struct kern_modules_param *modules,
>  			  int entries, int required)
>  {
> @@ -194,6 +246,7 @@ static int modprobe_lttng(struct kern_modules_param *modules,
>  error:
>  	return ret;
>  }
> +#endif
>  
>  /*
>   * Load control kernel module(s).
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 603 bytes --]

[-- Attachment #2: Type: text/plain, Size: 155 bytes --]

_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

           reply	other threads:[~2014-09-08 19:36 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1409819453-24245-1-git-send-email-umut.tezduyar@axis.com>]

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='20140908193611.GH6836__3703.46224303848$1410205031$gmane$org@thessa' \
    --to=dgoulet@efficios.com \
    --cc=lttng-dev@lists.lttng.org \
    --cc=umut.tezduyar@axis.com \
    --cc=umuttl@axis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.