<div dir="ltr">Applied,<div>Thanks.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 30, 2014 at 7:14 AM, Benjamin Marzinski <span dir="ltr"><<a href="mailto:bmarzins@redhat.com" target="_blank">bmarzins@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Normally multipathd runs the path checkers asynchronously. However if there<br>
are a lot of paths, this can cause large CPU spikes (for instance, in<br>
cases where they are all competing for the Big Kernel Lock). In these<br>
situations, overall machine performance is better if multipath doesn't have<br>
hundreds or even thousands of path checkers running at the same time. This<br>
patch lets users turn off the asynchronous mode of these checks if they<br>
see this problem.<br>
<br>
Signed-off-by: Benjamin Marzinski <<a href="mailto:bmarzins@redhat.com">bmarzins@redhat.com</a>><br>
---<br>
 libmultipath/config.c      |  1 +<br>
 libmultipath/config.h      |  1 +<br>
 libmultipath/dict.c        | 33 +++++++++++++++++++++++++++++++++<br>
 libmultipath/discovery.c   |  8 ++++++--<br>
 multipath.conf.annotated   | 11 +++++++++++<br>
 multipath/multipath.conf.5 |  9 +++++++++<br>
 6 files changed, 61 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/libmultipath/config.c b/libmultipath/config.c<br>
index e13c307..39963b4 100644<br>
--- a/libmultipath/config.c<br>
+++ b/libmultipath/config.c<br>
@@ -561,6 +561,7 @@ load_config (char * file, struct udev *udev)<br>
        conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;<br>
        conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;<br>
        conf->detect_prio = DEFAULT_DETECT_PRIO;<br>
+       conf->force_sync = 0;<br>
<br>
        /*<br>
         * preload default hwtable<br>
diff --git a/libmultipath/config.h b/libmultipath/config.h<br>
index ac7c58e..1a23e4b 100644<br>
--- a/libmultipath/config.h<br>
+++ b/libmultipath/config.h<br>
@@ -124,6 +124,7 @@ struct config {<br>
        int reassign_maps;<br>
        int retain_hwhandler;<br>
        int detect_prio;<br>
+       int force_sync;<br>
        unsigned int version[3];<br>
<br>
        char * dev;<br>
diff --git a/libmultipath/dict.c b/libmultipath/dict.c<br>
index 91d9b83..7de7a67 100644<br>
--- a/libmultipath/dict.c<br>
+++ b/libmultipath/dict.c<br>
@@ -685,6 +685,29 @@ def_detect_prio_handler(vector strvec)<br>
        return 0;<br>
 }<br>
<br>
+static int<br>
+def_force_sync_handler(vector strvec)<br>
+{<br>
+       char * buff;<br>
+<br>
+       buff = set_value(strvec);<br>
+<br>
+       if (!buff)<br>
+               return 1;<br>
+<br>
+       if ((strlen(buff) == 2 && !strcmp(buff, "no")) ||<br>
+           (strlen(buff) == 1 && !strcmp(buff, "0")))<br>
+               conf->force_sync = 0;<br>
+       else if ((strlen(buff) == 3 && !strcmp(buff, "yes")) ||<br>
+                (strlen(buff) == 1 && !strcmp(buff, "1")))<br>
+               conf->force_sync = 1;<br>
+       else<br>
+               conf->force_sync = 0;<br>
+<br>
+       FREE(buff);<br>
+       return 0;<br>
+}<br>
+<br>
 /*<br>
  * blacklist block handlers<br>
  */<br>
@@ -2783,6 +2806,15 @@ snprint_def_detect_prio(char * buff, int len, void * data)<br>
 }<br>
<br>
 static int<br>
+snprint_def_force_sync(char * buff, int len, void * data)<br>
+{<br>
+       if (conf->force_sync)<br>
+               return snprintf(buff, len, "yes");<br>
+       else<br>
+               return snprintf(buff, len, "no");<br>
+}<br>
+<br>
+static int<br>
 snprint_ble_simple (char * buff, int len, void * data)<br>
 {<br>
        struct blentry * ble = (struct blentry *)data;<br>
@@ -2849,6 +2881,7 @@ init_keywords(void)<br>
        install_keyword("reservation_key", &def_reservation_key_handler, &snprint_def_reservation_key);<br>
        install_keyword("retain_attached_hw_handler", &def_retain_hwhandler_handler, &snprint_def_retain_hwhandler_handler);<br>
        install_keyword("detect_prio", &def_detect_prio_handler, &snprint_def_detect_prio);<br>
+       install_keyword("force_sync", &def_force_sync_handler, &snprint_def_force_sync);<br>
        __deprecated install_keyword("default_selector", &def_selector_handler, NULL);<br>
        __deprecated install_keyword("default_path_grouping_policy", &def_pgpolicy_handler, NULL);<br>
        __deprecated install_keyword("default_uid_attribute", &def_uid_attribute_handler, NULL);<br>
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c<br>
index b62a59c..a5f5a20 100644<br>
--- a/libmultipath/discovery.c<br>
+++ b/libmultipath/discovery.c<br>
@@ -1053,8 +1053,12 @@ get_state (struct path * pp, int daemon)<br>
                }<br>
        }<br>
        checker_clear_message(c);<br>
-       if (daemon)<br>
-               checker_set_async(c);<br>
+       if (daemon) {<br>
+               if (conf->force_sync == 0)<br>
+                       checker_set_async(c);<br>
+               else<br>
+                       checker_set_sync(c);<br>
+       }<br>
        if (!conf->checker_timeout &&<br>
            sysfs_get_timeout(pp, &(c->timeout)) <= 0)<br>
                c->timeout = DEF_TIMEOUT;<br>
diff --git a/multipath.conf.annotated b/multipath.conf.annotated<br>
index f158746..0af1d4c 100644<br>
--- a/multipath.conf.annotated<br>
+++ b/multipath.conf.annotated<br>
@@ -270,6 +270,7 @@<br>
 #      # default : determined by the OS<br>
 #      dev_loss_tmo 600<br>
 #<br>
+#      #<br>
 #      # name    : bindings_file<br>
 #      # scope   : multipath<br>
 #      # desc    : The location of the bindings file that is used with<br>
@@ -278,6 +279,7 @@<br>
 #      # default : "/var/lib/multipath/bindings"<br>
 #      bindings_file "/etc/multipath/bindings"<br>
 #<br>
+#      #<br>
 #      # name    : wwids_file<br>
 #      # scope   : multipath<br>
 #      # desc    : The location of the wwids file multipath uses to<br>
@@ -286,6 +288,7 @@<br>
 #      # default : "/var/lib/multipath/wwids"<br>
 #      wwids_file "/etc/multipath/wwids"<br>
 #<br>
+#      #<br>
 #      # name    : reservation_key<br>
 #      # scope   : multipath<br>
 #      # desc    : Service action reservation key used by mpathpersist.<br>
@@ -293,6 +296,14 @@<br>
 #      # default : (null)<br>
 #      reservation_key "mpathkey"<br>
 #<br>
+#      #<br>
+#      # name    : force_sync<br>
+#      # scope   : multipathd<br>
+#      # desc    : If set to yes, multipath will run all of the checkers in<br>
+#      #           sync mode, even if the checker has an async mode.<br>
+#      # values  : yes|no<br>
+#      # default : no<br>
+#      force_sync yes<br>
 #}<br>
 #<br>
 ##<br>
diff --git a/multipath/multipath.conf.5 b/multipath/multipath.conf.5<br>
index 195e663..cadb34d 100644<br>
--- a/multipath/multipath.conf.5<br>
+++ b/multipath/multipath.conf.5<br>
@@ -409,6 +409,15 @@ will automatically use the<br>
 .I alua<br>
 prioritizer. If not, the prioritizer will be selected as usual. Default is<br>
 .I no<br>
+.TP<br>
+.B force_sync<br>
+If set to<br>
+.I yes<br>
+, multipathd will call the path checkers in sync mode only.  This means that<br>
+only one checker will run at a time.  This is useful in the case where many<br>
+multipathd checkers running in parallel causes significant CPU pressure. The<br>
+Default is<br>
+.I no<br>
 .<br>
 .SH "blacklist section"<br>
 The<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.1<br>
<br>
</font></span></blockquote></div><br></div>