All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: dm-devel@redhat.com
Subject: Re: [PATCH 1/4] multipathd: don't flood system with sd_notify calls
Date: Thu, 7 Sep 2017 16:31:30 -0500	[thread overview]
Message-ID: <20170907213130.GB3145@octiron.msp.redhat.com> (raw)
In-Reply-To: <20170828220536.13208-1-mwilck@suse.com>

On Tue, Aug 29, 2017 at 12:05:33AM +0200, Martin Wilck wrote:
> DAEMON_RUNNING is only used by checkerloop to indicate that
> path checkers are running. checkerloop switches back and forth
> between DAEMON_IDLE and DAEMON_RUNNING in every iteration, i.e.
> it performs two status changes per second on an idle system.
> The repeated sd_notify() calls cause a lot of traffic on dbus as
> systemd forwards these messages on the system bus. This can be
> seen with systemd.log_level=debug. Better skip these notifications
> that don't provide useful information to the user, who is very
> unlikely to catch the daemon in "running" state anyway.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> ---
>  multipathd/main.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/multipathd/main.c b/multipathd/main.c
> index 4be2c579..b5e2b00d 100644
> --- a/multipathd/main.c
> +++ b/multipathd/main.c
> @@ -161,15 +161,27 @@ sd_notify_status(void)
>  	case DAEMON_CONFIGURE:
>  		return "STATUS=configure";
>  	case DAEMON_IDLE:
> -		return "STATUS=idle";
>  	case DAEMON_RUNNING:
> -		return "STATUS=running";
> +		return "STATUS=up";
>  	case DAEMON_SHUTDOWN:
>  		return "STATUS=shutdown";
>  	}
>  	return NULL;
>  }
>  
> +static void do_sd_notify(enum daemon_status old_state)
> +{
> +	/*
> +	 * Checkerloop switches back and forth between idle and running state.
> +	 * No need to tell systemd each time.
> +	 * These notifications cause a lot of overhead on dbus.
> +	 */
> +	if ((running_state == DAEMON_IDLE || running_state == DAEMON_RUNNING) &&
> +	    (old_state == DAEMON_IDLE || old_state == DAEMON_RUNNING))
> +		return;
> +	sd_notify(0, sd_notify_status());
> +}
> +
>  static void config_cleanup(void *arg)
>  {
>  	pthread_mutex_unlock(&config_lock);
> @@ -179,10 +191,12 @@ void post_config_state(enum daemon_status state)
>  {
>  	pthread_mutex_lock(&config_lock);
>  	if (state != running_state) {
> +		enum daemon_status old_state = running_state;
> +
>  		running_state = state;
>  		pthread_cond_broadcast(&config_cond);
>  #ifdef USE_SYSTEMD
> -		sd_notify(0, sd_notify_status());
> +		do_sd_notify(old_state);
>  #endif
>  	}
>  	pthread_mutex_unlock(&config_lock);
> @@ -195,6 +209,8 @@ int set_config_state(enum daemon_status state)
>  	pthread_cleanup_push(config_cleanup, NULL);
>  	pthread_mutex_lock(&config_lock);
>  	if (running_state != state) {
> +		enum daemon_status old_state = running_state;
> +
>  		if (running_state != DAEMON_IDLE) {
>  			struct timespec ts;
>  
> @@ -207,7 +223,7 @@ int set_config_state(enum daemon_status state)
>  			running_state = state;
>  			pthread_cond_broadcast(&config_cond);
>  #ifdef USE_SYSTEMD
> -			sd_notify(0, sd_notify_status());
> +			do_sd_notify(old_state);
>  #endif
>  		}
>  	}
> -- 
> 2.14.0
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>

-Ben

      parent reply	other threads:[~2017-09-07 21:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 22:05 [PATCH 1/4] multipathd: don't flood system with sd_notify calls Martin Wilck
2017-08-28 22:05 ` [PATCH 2/4] libmultipath: add_feature: skip pointless NULL check Martin Wilck
2017-08-29  6:37   ` Hannes Reinecke
2017-08-29  7:21     ` Martin Wilck
2017-09-07 21:33   ` Benjamin Marzinski
2017-08-28 22:05 ` [PATCH 3/4] libmultipath: add_feature: allow only 1 feature Martin Wilck
2017-08-29  6:39   ` Hannes Reinecke
2017-09-07 21:42   ` Benjamin Marzinski
2017-09-07 22:37     ` Benjamin Marzinski
2017-08-28 22:05 ` [PATCH 4/4] multipath: delegate dangerous commands to multipathd Martin Wilck
2017-08-29  6:40   ` Hannes Reinecke
2017-09-07 21:57   ` Benjamin Marzinski
2017-09-08  8:16     ` Martin Wilck
2017-08-29  6:36 ` [PATCH 1/4] multipathd: don't flood system with sd_notify calls Hannes Reinecke
2017-09-07 21:31 ` Benjamin Marzinski [this message]

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=20170907213130.GB3145@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.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.