Send Linux-ha-cvs mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Linux-ha-cvs digest..."


Today's Topics:

   1. Linux-HA CVS: crm by andrew from 
      ([email protected])
   2. Linux-HA CVS: include by alan from 
      ([email protected])
   3. Linux-HA CVS: lib by alan from  ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Mon, 30 Jan 2006 09:40:12 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: crm by andrew from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : andrew
Host    : 
Project : linux-ha
Module  : crm

Dir     : linux-ha/crm/cib


Modified Files:
        main.c 


Log Message:
Improvements to "CIB Stats

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/crm/cib/main.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -3 -r1.33 -r1.34
--- main.c      26 Jan 2006 10:24:06 -0000      1.33
+++ main.c      30 Jan 2006 16:40:11 -0000      1.34
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.33 2006/01/26 10:24:06 andrew Exp $ */
+/* $Id: main.c,v 1.34 2006/01/30 16:40:11 andrew Exp $ */
 /* 
  * Copyright (C) 2004 Andrew Beekhof <[EMAIL PROTECTED]>
  * 
@@ -144,14 +144,31 @@
        return init_start();
 }
 
+unsigned long cib_num_ops = 0;
+const char *cib_stat_interval = "5min";
+unsigned long cib_num_local = 0, cib_num_updates = 0, cib_num_fail = 0;
+
 gboolean cib_stats(gpointer data);
-unsigned long cib_num_ops = 0, cib_num_local = 0, cib_num_updates = 0, 
cib_num_fail = 0;
 
 gboolean
 cib_stats(gpointer data)
 {
-       crm_info("Processed %lu operations (%lu local, %lu updates, %lu 
failures)",
-                cib_num_ops, cib_num_local, cib_num_updates, cib_num_fail);
+       int local_log_level = LOG_DEBUG;
+       static unsigned long last_stat = 0;
+
+       if(cib_num_ops - last_stat > 0) {
+               local_log_level = LOG_INFO;
+       }
+       
+       crm_log_maybe(local_log_level,
+                     "Processed %lu operations in the last %s",
+                     cib_num_ops - last_stat, cib_stat_interval);
+       
+       crm_log_maybe(local_log_level+1, "Processed %lu operations"
+                     " (%lu local, %lu updates, %lu failures)",
+                     cib_num_ops, cib_num_local, cib_num_updates,cib_num_fail);
+
+       last_stat = cib_num_ops;
        return TRUE;
 }
 
@@ -279,7 +296,8 @@
                crm_info("Starting %s mainloop", crm_system_name);
 
                Gmain_timeout_add(crm_get_msec("1s"), cib_msg_timeout, NULL);
-               Gmain_timeout_add(crm_get_msec("5min"), cib_stats, NULL); 
+               Gmain_timeout_add(
+                       crm_get_msec(cib_stat_interval), cib_stats, NULL); 
                
                g_main_run(mainloop);
                return_to_orig_privs();




------------------------------

Message: 2
Date: Mon, 30 Jan 2006 11:41:59 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: include by alan from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : alan
Host    : 
Project : linux-ha
Module  : include

Dir     : linux-ha/include/clplumbing


Modified Files:
        GSource.h Gmain_timeout.h 


Log Message:
Put in instrumentation into our GSource code so I can find out when and where 
delays are being incurred.

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/clplumbing/GSource.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- GSource.h   28 Jul 2005 08:20:05 -0000      1.13
+++ GSource.h   30 Jan 2006 18:41:59 -0000      1.14
@@ -1,4 +1,4 @@
-/* $Id: GSource.h,v 1.13 2005/07/28 08:20:05 sunjd Exp $ */
+/* $Id: GSource.h,v 1.14 2006/01/30 18:41:59 alan Exp $ */
 /*
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -26,6 +26,9 @@
 typedef struct GTRIGSource_s   GTRIGSource;
 
 
+void G_main_setmaxdispatchdelay(GSource* s, unsigned long delayms);
+void G_main_setmaxdispatchtime(GSource* s, unsigned long dispatchms);
+
 
 /***********************************************************************
  *     Functions for interfacing input to the mainloop
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/include/clplumbing/Gmain_timeout.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- Gmain_timeout.h     17 Feb 2004 22:11:58 -0000      1.4
+++ Gmain_timeout.h     30 Jan 2006 18:41:59 -0000      1.5
@@ -1,4 +1,4 @@
-/* $Id: Gmain_timeout.h,v 1.4 2004/02/17 22:11:58 lars Exp $ */
+/* $Id: Gmain_timeout.h,v 1.5 2006/01/30 18:41:59 alan Exp $ */
 #ifndef _CLPLUMBING_GMAIN_TIMEOUT_H
 #define _CLPLUMBING_GMAIN_TIMEOUT_H
 #include <glib.h>
@@ -42,4 +42,6 @@
 ,      GDestroyNotify  notify);
 
 void Gmain_timeout_remove(guint tag);
+void Gmain_timeout_setmaxdispatchtime(GSource* src, long dispatchms);
+void Gmain_timeout_setmaxdispatchdelay(GSource* src, long delayms);
 #endif




------------------------------

Message: 3
Date: Mon, 30 Jan 2006 11:42:00 -0700 (MST)
From: [email protected]
Subject: [Linux-ha-cvs] Linux-HA CVS: lib by alan from 
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>

linux-ha CVS committal

Author  : alan
Host    : 
Project : linux-ha
Module  : lib

Dir     : linux-ha/lib/clplumbing


Modified Files:
        GSource.c Gmain_timeout.c 


Log Message:
Put in instrumentation into our GSource code so I can find out when and where 
delays are being incurred.

===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/GSource.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -3 -r1.53 -r1.54
--- GSource.c   15 Sep 2005 00:02:52 -0000      1.53
+++ GSource.c   30 Jan 2006 18:41:59 -0000      1.54
@@ -1,4 +1,4 @@
-/* $Id: GSource.c,v 1.53 2005/09/15 00:02:52 gshi Exp $ */
+/* $Id: GSource.c,v 1.54 2006/01/30 18:41:59 alan Exp $ */
 /*
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -42,6 +42,9 @@
 #define        IS_SIGSOURCE(p) ((p)->magno == MAG_GSIGSOURCE)
 #define        IS_TRIGSOURCE(p) ((p)->magno == MAG_GTRIGSOURCE)
 
+#define IS_ONEOFOURS(p)        (IS_CHSOURCE(p)|IS_FDSOURCE(p)|IS_WCSOURCE(p)|  
\
+                       IS_SIGSOURCE(p)|IS_TRIGSOURCE(p))
+
 #ifndef _NSIG
 # define _NSIG 2*NSIG
 #endif
@@ -49,6 +52,9 @@
 struct GFDSource_s {
        GSource source;
        unsigned        magno;  /* MAG_GFDSOURCE */
+       long            maxdispatchms;  /* Maximum time to spend in the 
dispatch function */
+       long            maxdispatchdelayms;     /* Max delay before processing 
*/
+       longclock_t     detecttime;
        void*           udata;
        gboolean        (*dispatch)(int fd, gpointer user_data);
        GPollFD         gpfd;
@@ -62,6 +68,9 @@
 struct GCHSource_s {
        GSource source;
        unsigned        magno;  /* MAG_GCHSOURCE */
+       long            maxdispatchms;  /* Maximum time to spend in the 
dispatch function */
+       long            maxdispatchdelayms;     /* Max delay before processing 
*/
+       longclock_t     detecttime;
        void*           udata;
        IPC_Channel*    ch;
        gboolean        (*dispatch)(IPC_Channel* ch, gpointer user_data);
@@ -79,6 +88,9 @@
 struct GWCSource_s {
        GSource source;
        unsigned                magno;  /* MAG_GWCSOURCE */
+       long                    maxdispatchms;  /* Maximum time to spend in the 
dispatch function */
+       long                    maxdispatchdelayms;     /* Max delay before 
processing */
+       longclock_t             detecttime;
        void*                   udata;
        GPollFD                 gpfd;
        GDestroyNotify          dnotify;
@@ -91,6 +103,9 @@
 struct GSIGSource_s {
        GSource source;
        unsigned        magno;  /* MAG_GCHSOURCE */
+       long            maxdispatchms;  /* Maximum time to spend in the 
dispatch function */
+       long            maxdispatchdelayms;     /* Max delay before processing 
*/
+       longclock_t     detecttime;
        void*           udata;
        int             signal;
        gboolean        signal_triggered;
@@ -102,6 +117,9 @@
 struct GTRIGSource_s {
        GSource source;
        unsigned        magno;  /* MAG_GCHSOURCE */
+       long            maxdispatchms;  /* Maximum time to spend in the 
dispatch function */
+       long            maxdispatchdelayms;     /* Max delay before processing 
*/
+       longclock_t     detecttime;
        void*           udata;
        gboolean        manual_trigger;
        gboolean        (*dispatch)(gpointer user_data);
@@ -114,6 +132,35 @@
 #define        OUTPUT_EVENTS   (G_IO_OUT)
 #define        DEF_EVENTS      (INPUT_EVENTS|ERR_EVENTS)
 
+#define        WARN_DELAY(ms, input)   cl_log(LOG_WARNING      \
+       ,       "%s: Dispatch function was delayed"     \
+       " %ld ms before being called (GSource: 0x%lx)"          \
+       ,       __FUNCTION__,   ms, POINTER_TO_ULONG(input))
+
+#define        WARN_TOOLONG(ms, input) cl_log(LOG_WARNING                      
\
+       ,       "%s: Dispatch function took too long to execute"        \
+       ": %ld ms (GSource: 0x%lx)"                                     \
+       ,       __FUNCTION__,   ms, POINTER_TO_ULONG(input))
+
+#define CHECK_DISPATCH_DELAY(input)    {                               \
+       unsigned long   ms;                                             \
+       dispstart = time_longclock();                                   \
+       ms = sub_longclock(dispstart, (input)->detecttime);             \
+       if ((input)->maxdispatchdelayms > 0                             \
+       &&      ms > input->maxdispatchdelayms) {                       \
+               WARN_DELAY(ms, input);                                  \
+       }                                                               \
+}
+
+#define CHECK_DISPATCH_TIME(input)     {                               \
+       unsigned long   ms;                                             \
+       longclock_t     dispend = time_longclock();                     \
+       ms = sub_longclock(dispend, dispstart);                         \
+       if ((input)->maxdispatchms > 0 && ms > input->maxdispatchms) {  \
+               WARN_TOOLONG(ms, input);                                \
+       }                                                               \
+}
+
 
 static gboolean G_fd_prepare(GSource* source,
                             gint* timeout);
@@ -168,6 +215,8 @@
        GFDSource* ret = (GFDSource*)source;
        
        ret->magno = MAG_GFDSOURCE;
+       ret->maxdispatchdelayms = 0;
+       ret->maxdispatchms = 0;
        ret->udata = userdata;
        ret->dispatch = dispatch;
        ret->gpfd.fd = fd;
@@ -244,7 +293,11 @@
 {
        GFDSource*      fdp =  (GFDSource*)source;
        g_assert(IS_FDSOURCE(fdp));
-       return fdp->gpfd.revents != 0;
+       if (fdp->gpfd.revents != 0) {
+               fdp->detecttime = time_longclock();
+               return TRUE;
+       }
+       return FALSE;
 }
 
 /*
@@ -257,7 +310,9 @@
 {
 
        GFDSource*      fdp =  (GFDSource*)source;
+       longclock_t     dispstart;
        g_assert(IS_FDSOURCE(fdp));
+       CHECK_DISPATCH_DELAY(fdp);
        
 
        /* Is output now unblocked? 
@@ -273,8 +328,10 @@
                if(!(fdp->dispatch(fdp->gpfd.fd, fdp->udata))){
                        g_source_remove_poll(source,&fdp->gpfd);
                        g_source_unref(source);
+                       CHECK_DISPATCH_TIME(fdp);
                        return FALSE;
                }
+               CHECK_DISPATCH_TIME(fdp);
        }
        
        return TRUE;
@@ -345,6 +402,8 @@
        chp = (GCHSource*)source;
        
        chp->magno = MAG_GCHSOURCE;
+       chp->maxdispatchdelayms = 0;
+       chp->maxdispatchms = 0;
        chp->ch = ch;
        chp->dispatch = dispatch;
        chp->udata=userdata;
@@ -479,6 +538,7 @@
 {
 
        GCHSource* chp = (GCHSource*)source;
+       gboolean        ret;
 
        g_assert(IS_CHSOURCE(chp));
        
@@ -489,9 +549,13 @@
                return FALSE;
        }
        
-       return (chp->infd.revents != 0
+       ret = (chp->infd.revents != 0
                ||      (!chp->fd_fdx && chp->outfd.revents != 0)
                ||      chp->ch->ops->is_message_pending(chp->ch));
+       if (ret) {
+               chp->detecttime = time_longclock();
+       }
+       return ret;
 }
 
 /*
@@ -503,8 +567,10 @@
              gpointer user_data)
 {
        GCHSource* chp = (GCHSource*)source;
+       longclock_t     dispstart;
 
        g_assert(IS_CHSOURCE(chp));
+       CHECK_DISPATCH_DELAY(chp);
 
 
        if (chp->dontread){
@@ -542,8 +608,10 @@
                                g_source_remove_poll(source, &chp->outfd);
                        }
                        g_source_unref(source);
+                       CHECK_DISPATCH_TIME(chp);
                        return FALSE;
                }
+               CHECK_DISPATCH_TIME(chp);
        }
 
        if (chp->ch->ch_status == IPC_DISCONNECT){
@@ -611,6 +679,8 @@
        wcp = (GWCSource*)source;
        
        wcp->magno = MAG_GWCSOURCE;
+       wcp->maxdispatchdelayms = 0;
+       wcp->maxdispatchms = 0;
        wcp->udata = userdata;
        wcp->gpfd.fd = wch->ops->get_select_fd(wch);
        wcp->gpfd.events = DEF_EVENTS;
@@ -639,7 +709,8 @@
 
 
 /* Delete the given IPC_WaitConnection from the gmainloop world */
-gboolean G_main_del_IPC_WaitConnection(GWCSource* wcp)
+gboolean
+G_main_del_IPC_WaitConnection(GWCSource* wcp)
 {
 
        GSource* source =  (GSource*) wcp;
@@ -683,7 +754,11 @@
        GWCSource* wcp = (GWCSource*)source;
        g_assert(IS_WCSOURCE(wcp));
 
-       return wcp->gpfd.revents != 0;
+       if (wcp->gpfd.revents != 0) {
+               wcp->detecttime = time_longclock();
+               return TRUE;
+       }
+       return FALSE;
 }
 
 /*
@@ -699,8 +774,10 @@
        IPC_Channel*    ch;
        gboolean        rc = TRUE;
        int             count = 0;
+       longclock_t     dispstart;
        
        g_assert(IS_WCSOURCE(wcp));
+       CHECK_DISPATCH_DELAY(wcp);
        
         while(1) {
                ch = wcp->wch->ops->accept_connection(wcp->wch, wcp->auth_info);
@@ -714,6 +791,7 @@
                }
 
                rc = wcp->dispatch(ch, wcp->udata);
+               CHECK_DISPATCH_TIME(wcp);
                if(!rc) {
                        g_source_remove_poll(source, &wcp->gpfd);
                        g_source_unref(source);
@@ -784,6 +862,8 @@
        sig_src = (GSIGSource*)source;
        
        sig_src->magno          = MAG_GSIGSOURCE;
+       sig_src->maxdispatchdelayms = 0;
+       sig_src->maxdispatchms  = 0;
        sig_src->signal         = signal;
        sig_src->dispatch       = dispatch;
        sig_src->udata          = userdata;
@@ -897,8 +977,10 @@
              gpointer user_data)
 {
        GSIGSource* sig_src = (GSIGSource*)source;
+       longclock_t     dispstart;
 
        g_assert(IS_SIGSOURCE(sig_src));
+       CHECK_DISPATCH_DELAY(sig_src);
 
        sig_src->signal_triggered = FALSE;
 
@@ -906,7 +988,9 @@
                if(!(sig_src->dispatch(sig_src->signal, sig_src->udata))){
                        G_main_del_SignalHandler(sig_src);
                        return FALSE;
+                       CHECK_DISPATCH_TIME(sig_src);
                }
+               CHECK_DISPATCH_TIME(sig_src);
        }
        
        return TRUE;
@@ -942,11 +1026,12 @@
 
 /*     g_assert(sig_src != NULL); */
        if(sig_src == NULL) {
-               cl_log(LOG_CRIT, "No handler for signal -%d", nsig);
+               /* cl_log(LOG_CRIT, "No handler for signal -%d", nsig); */
                return;
        }
        
        g_assert(IS_SIGSOURCE(sig_src));
+       sig_src->detecttime = time_longclock();
        sig_src->signal_triggered = TRUE;
 }
 
@@ -1072,6 +1157,8 @@
        trig_src = (GTRIGSource*)source;
        
        trig_src->magno         = MAG_GTRIGSOURCE;
+       trig_src->maxdispatchdelayms = 0;
+       trig_src->maxdispatchms = 0;
        trig_src->dispatch      = dispatch;
        trig_src->udata         = userdata;
        trig_src->dnotify       = notify;
@@ -1154,8 +1241,11 @@
        GTRIGSource* trig_src = (GTRIGSource*)source;
 
        g_assert(IS_TRIGSOURCE(trig_src));
-       
-       return trig_src->manual_trigger;
+       if (trig_src->manual_trigger) {
+               trig_src->detecttime = time_longclock();
+               return TRUE;
+       }
+       return FALSE;
 }
 
 /*
@@ -1167,16 +1257,20 @@
              gpointer user_data)
 {
        GTRIGSource* trig_src = (GTRIGSource*)source;
+       longclock_t     dispstart;
 
        g_assert(IS_TRIGSOURCE(trig_src));
+       CHECK_DISPATCH_DELAY(trig_src);
 
        trig_src->manual_trigger = FALSE;
 
        if(trig_src->dispatch) {
                if(!(trig_src->dispatch(trig_src->udata))){
                        G_main_del_TriggerHandler(trig_src);
+                       CHECK_DISPATCH_TIME(trig_src);
                        return FALSE;
                }
+               CHECK_DISPATCH_TIME(trig_src);
        }
        
        return TRUE;
@@ -1198,3 +1292,16 @@
        }       
 }
 
+void
+G_main_setmaxdispatchdelay(GSource* s, unsigned long delayms)
+{
+       GFDSource*      fdp =  (GFDSource*)s;
+       g_assert(IS_ONEOFOURS(fdp));
+       fdp->maxdispatchdelayms = delayms;
+}
+void
+G_main_setmaxdispatchtime(GSource* s, unsigned long dispatchms)
+{
+       GFDSource*      fdp =  (GFDSource*)s;
+       fdp->maxdispatchms = dispatchms;
+}
===================================================================
RCS file: /home/cvs/linux-ha/linux-ha/lib/clplumbing/Gmain_timeout.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -3 -r1.14 -r1.15
--- Gmain_timeout.c     10 Nov 2005 01:08:55 -0000      1.14
+++ Gmain_timeout.c     30 Jan 2006 18:41:59 -0000      1.15
@@ -1,4 +1,4 @@
-/* $Id: Gmain_timeout.c,v 1.14 2005/11/10 01:08:55 gshi Exp $ */
+/* $Id: Gmain_timeout.c,v 1.15 2006/01/30 18:41:59 alan Exp $ */
 /*
  * Glib mainloop timeout handling code.
  *
@@ -30,6 +30,7 @@
  */
 #include <glib.h>
 #include <clplumbing/longclock.h>
+#include <clplumbing/cl_log.h>
 #include <clplumbing/Gmain_timeout.h>
 #include <string.h>
 
@@ -54,6 +55,8 @@
        GSource         Source;
        longclock_t     nexttime;
        guint           interval;
+       unsigned long   maxdispatchdelayms;
+       unsigned long   maxdispatchms;
 };
 
 #define        GTIMEOUT(GS)    ((struct GTimeoutAppend*)((void*)(GS)))
@@ -85,6 +88,8 @@
        append->nexttime = add_longclock(time_longclock()
                                         ,msto_longclock(interval));
        append->interval = interval; 
+       append->maxdispatchms = 0;
+       append->maxdispatchdelayms = 10000;
        
        g_source_set_priority(source, priority);
        
@@ -148,11 +153,45 @@
 Gmain_timeout_dispatch(GSource* src, GSourceFunc func, gpointer user_data)
 {
        struct GTimeoutAppend* append = GTIMEOUT(src);
+       longclock_t     lstart = time_longclock();
+       long            ms = longclockto_ms(sub_longclock(lstart, 
append->nexttime));
+       gboolean        ret;
+
+       if (append->maxdispatchdelayms > 0 && ms > append->maxdispatchdelayms) {
+               cl_log(LOG_WARNING, "Timeout dispatch function [%lx] called %ld 
ms late."
+               ,       (unsigned long)func, ms);
+       }
+       
 
        /* Schedule our next dispatch */
        append->nexttime = add_longclock(time_longclock()
                                          , msto_longclock(append->interval));
 
        /* Then call the user function */
-       return func(user_data);
+       ret = func(user_data);
+
+       /* Time it if requested */
+       if (append->maxdispatchms > 0) {
+               longclock_t     lend = time_longclock();
+               ms = longclockto_ms(sub_longclock(lend, lstart));
+               if (ms > append->maxdispatchms) {
+                       cl_log(LOG_WARNING, "Timeout dispatch function [%lx] 
took %ld ms."
+                       ,       (unsigned long)func, ms);
+               }
+       }
+       return ret;
+}
+
+void
+Gmain_timeout_setmaxdispatchtime(GSource* src, long dispatchms)
+{
+       struct GTimeoutAppend* append = GTIMEOUT(src);
+       append->maxdispatchms = dispatchms;
+}
+
+void
+Gmain_timeout_setmaxdispatchdelay(GSource* src, long delayms)
+{
+       struct GTimeoutAppend* append = GTIMEOUT(src);
+       append->maxdispatchdelayms = delayms;
 }




------------------------------

_______________________________________________
Linux-ha-cvs mailing list
[email protected]
http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs


End of Linux-ha-cvs Digest, Vol 26, Issue 64
********************************************

Reply via email to