Whamcloud - gitweb
* Added lwt stop now prints the wallclock time of the first trace record
authoreeb <eeb>
Sun, 30 Nov 2003 18:23:50 +0000 (18:23 +0000)
committereeb <eeb>
Sun, 30 Nov 2003 18:23:50 +0000 (18:23 +0000)
*    Turned off lwt support by default

lnet/include/linux/kp30.h
lnet/libcfs/module.c
lnet/utils/portals.c
lustre/portals/include/linux/kp30.h
lustre/portals/libcfs/module.c
lustre/portals/utils/portals.c

index 65cfa17..aca23f5 100644 (file)
@@ -690,7 +690,10 @@ char *portals_nid2str(int nal, ptl_nid_t nid, char *str);
 /******************************************************************************/
 /* Light-weight trace 
  * Support for temporary event tracing with minimal Heisenberg effect. */
-#define LWT_SUPPORT  1
+#define LWT_SUPPORT  0
+
+#define LWT_MEMORY   (64<<20)
+#define LWT_MAX_CPUS 4
 
 typedef struct {
         cycles_t    lwte_when;
@@ -728,7 +731,7 @@ extern void lwt_fini (void);
 extern int  lwt_lookup_string (int *size, char *knlptr,
                                char *usrptr, int usrsize);
 extern int  lwt_control (int enable, int clear);
-extern int  lwt_snapshot (int *ncpu, int *total_size,
+extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
                           void *user_ptr, int user_size);
 
 /* Note that we _don't_ define LWT_EVENT at all if LWT_SUPPORT isn't set.
index 7c0cafc..a9a268b 100644 (file)
@@ -514,7 +514,8 @@ static int kportal_ioctl(struct inode *inode, struct file *file,
                 break;
                 
         case IOC_PORTAL_LWT_SNAPSHOT:
-                err = lwt_snapshot (&data->ioc_count, &data->ioc_misc,
+                err = lwt_snapshot (&data->ioc_nid,
+                                    &data->ioc_count, &data->ioc_misc,
                                     data->ioc_pbuf1, data->ioc_plen1);
                 if (err == 0 &&
                     copy_to_user((char *)arg, data, sizeof (*data)))
index 3325892..c1c3fe5 100644 (file)
@@ -1371,7 +1371,8 @@ lwt_control(int enable, int clear)
 }
 
 static int
-lwt_snapshot(int *ncpu, int *totalsize, lwt_event_t *events, int size)
+lwt_snapshot(cycles_t *now, int *ncpu, int *totalsize, 
+             lwt_event_t *events, int size)
 {
         struct portal_ioctl_data data;
         int                      rc;
@@ -1390,6 +1391,9 @@ lwt_snapshot(int *ncpu, int *totalsize, lwt_event_t *events, int size)
         LASSERT (data.ioc_count != 0);
         LASSERT (data.ioc_misc != 0);
         
+        if (now != NULL)
+                *now = data.ioc_nid;
+
         if (ncpu != NULL)
                 *ncpu = data.ioc_count;
 
@@ -1499,14 +1503,13 @@ get_cycles_per_usec ()
 int
 jt_ptl_lwt(int argc, char **argv)
 {
-#define MAX_CPUS 8
         int             ncpus;
         int             totalspace;
         int             nevents_per_cpu;
         lwt_event_t    *events;
-        lwt_event_t    *cpu_event[MAX_CPUS + 1];
-        lwt_event_t    *next_event[MAX_CPUS];
-        lwt_event_t    *first_event[MAX_CPUS];
+        lwt_event_t    *cpu_event[LWT_MAX_CPUS + 1];
+        lwt_event_t    *next_event[LWT_MAX_CPUS];
+        lwt_event_t    *first_event[LWT_MAX_CPUS];
         int             cpu;
         lwt_event_t    *e;
         int             rc;
@@ -1514,6 +1517,9 @@ jt_ptl_lwt(int argc, char **argv)
         double          mhz;
         cycles_t        t0;
         cycles_t        tlast;
+        cycles_t        tnow;
+        struct timeval  tvnow;
+        int             printed_date = 0;
         FILE           *f = stdout;
 
         if (argc < 2 ||
@@ -1541,11 +1547,12 @@ jt_ptl_lwt(int argc, char **argv)
                 return (0);
         }
                 
-        if (lwt_snapshot(&ncpus, &totalspace, NULL, 0) != 0)
+        if (lwt_snapshot(NULL, &ncpus, &totalspace, NULL, 0) != 0)
                 return (-1);
 
-        if (ncpus > MAX_CPUS) {
-                fprintf(stderr, "Too many cpus: %d (%d)\n", ncpus, MAX_CPUS);
+        if (ncpus > LWT_MAX_CPUS) {
+                fprintf(stderr, "Too many cpus: %d (%d)\n", 
+                        ncpus, LWT_MAX_CPUS);
                 return (-1);
         }
 
@@ -1560,11 +1567,14 @@ jt_ptl_lwt(int argc, char **argv)
                 return (-1);
         }
 
-        if (lwt_snapshot(NULL, NULL, events, totalspace)) {
+        if (lwt_snapshot(&tnow, NULL, NULL, events, totalspace)) {
                 free(events);
                 return (-1);
         }
 
+        /* we want this time to be sampled at snapshot time */
+        gettimeofday(&tvnow, NULL);
+
         if (argc > 2) {
                 f = fopen (argv[2], "w");
                 if (f == NULL) {
@@ -1645,6 +1655,17 @@ jt_ptl_lwt(int argc, char **argv)
                 
                 if (t0 <= next_event[cpu]->lwte_when) {
                         /* on or after the first event */
+                        if (!printed_date) {
+                                cycles_t du = (tnow - t0) / mhz;
+                                time_t   then = tvnow.tv_sec - du/1000000;
+                                
+                                if (du % 1000000 > tvnow.tv_usec)
+                                        then--;
+
+                                fprintf(f, "%s", ctime(&then));
+                                printed_date = 1;
+                        }
+                        
                         rc = lwt_print(f, t0, tlast, mhz, cpu, next_event[cpu]);
                         if (rc != 0)
                                 break;
@@ -1666,5 +1687,4 @@ jt_ptl_lwt(int argc, char **argv)
 
         free(events);
         return (0);
-#undef MAX_CPUS
 }
index 65cfa17..aca23f5 100644 (file)
@@ -690,7 +690,10 @@ char *portals_nid2str(int nal, ptl_nid_t nid, char *str);
 /******************************************************************************/
 /* Light-weight trace 
  * Support for temporary event tracing with minimal Heisenberg effect. */
-#define LWT_SUPPORT  1
+#define LWT_SUPPORT  0
+
+#define LWT_MEMORY   (64<<20)
+#define LWT_MAX_CPUS 4
 
 typedef struct {
         cycles_t    lwte_when;
@@ -728,7 +731,7 @@ extern void lwt_fini (void);
 extern int  lwt_lookup_string (int *size, char *knlptr,
                                char *usrptr, int usrsize);
 extern int  lwt_control (int enable, int clear);
-extern int  lwt_snapshot (int *ncpu, int *total_size,
+extern int  lwt_snapshot (cycles_t *now, int *ncpu, int *total_size,
                           void *user_ptr, int user_size);
 
 /* Note that we _don't_ define LWT_EVENT at all if LWT_SUPPORT isn't set.
index 7c0cafc..a9a268b 100644 (file)
@@ -514,7 +514,8 @@ static int kportal_ioctl(struct inode *inode, struct file *file,
                 break;
                 
         case IOC_PORTAL_LWT_SNAPSHOT:
-                err = lwt_snapshot (&data->ioc_count, &data->ioc_misc,
+                err = lwt_snapshot (&data->ioc_nid,
+                                    &data->ioc_count, &data->ioc_misc,
                                     data->ioc_pbuf1, data->ioc_plen1);
                 if (err == 0 &&
                     copy_to_user((char *)arg, data, sizeof (*data)))
index 3325892..c1c3fe5 100644 (file)
@@ -1371,7 +1371,8 @@ lwt_control(int enable, int clear)
 }
 
 static int
-lwt_snapshot(int *ncpu, int *totalsize, lwt_event_t *events, int size)
+lwt_snapshot(cycles_t *now, int *ncpu, int *totalsize, 
+             lwt_event_t *events, int size)
 {
         struct portal_ioctl_data data;
         int                      rc;
@@ -1390,6 +1391,9 @@ lwt_snapshot(int *ncpu, int *totalsize, lwt_event_t *events, int size)
         LASSERT (data.ioc_count != 0);
         LASSERT (data.ioc_misc != 0);
         
+        if (now != NULL)
+                *now = data.ioc_nid;
+
         if (ncpu != NULL)
                 *ncpu = data.ioc_count;
 
@@ -1499,14 +1503,13 @@ get_cycles_per_usec ()
 int
 jt_ptl_lwt(int argc, char **argv)
 {
-#define MAX_CPUS 8
         int             ncpus;
         int             totalspace;
         int             nevents_per_cpu;
         lwt_event_t    *events;
-        lwt_event_t    *cpu_event[MAX_CPUS + 1];
-        lwt_event_t    *next_event[MAX_CPUS];
-        lwt_event_t    *first_event[MAX_CPUS];
+        lwt_event_t    *cpu_event[LWT_MAX_CPUS + 1];
+        lwt_event_t    *next_event[LWT_MAX_CPUS];
+        lwt_event_t    *first_event[LWT_MAX_CPUS];
         int             cpu;
         lwt_event_t    *e;
         int             rc;
@@ -1514,6 +1517,9 @@ jt_ptl_lwt(int argc, char **argv)
         double          mhz;
         cycles_t        t0;
         cycles_t        tlast;
+        cycles_t        tnow;
+        struct timeval  tvnow;
+        int             printed_date = 0;
         FILE           *f = stdout;
 
         if (argc < 2 ||
@@ -1541,11 +1547,12 @@ jt_ptl_lwt(int argc, char **argv)
                 return (0);
         }
                 
-        if (lwt_snapshot(&ncpus, &totalspace, NULL, 0) != 0)
+        if (lwt_snapshot(NULL, &ncpus, &totalspace, NULL, 0) != 0)
                 return (-1);
 
-        if (ncpus > MAX_CPUS) {
-                fprintf(stderr, "Too many cpus: %d (%d)\n", ncpus, MAX_CPUS);
+        if (ncpus > LWT_MAX_CPUS) {
+                fprintf(stderr, "Too many cpus: %d (%d)\n", 
+                        ncpus, LWT_MAX_CPUS);
                 return (-1);
         }
 
@@ -1560,11 +1567,14 @@ jt_ptl_lwt(int argc, char **argv)
                 return (-1);
         }
 
-        if (lwt_snapshot(NULL, NULL, events, totalspace)) {
+        if (lwt_snapshot(&tnow, NULL, NULL, events, totalspace)) {
                 free(events);
                 return (-1);
         }
 
+        /* we want this time to be sampled at snapshot time */
+        gettimeofday(&tvnow, NULL);
+
         if (argc > 2) {
                 f = fopen (argv[2], "w");
                 if (f == NULL) {
@@ -1645,6 +1655,17 @@ jt_ptl_lwt(int argc, char **argv)
                 
                 if (t0 <= next_event[cpu]->lwte_when) {
                         /* on or after the first event */
+                        if (!printed_date) {
+                                cycles_t du = (tnow - t0) / mhz;
+                                time_t   then = tvnow.tv_sec - du/1000000;
+                                
+                                if (du % 1000000 > tvnow.tv_usec)
+                                        then--;
+
+                                fprintf(f, "%s", ctime(&then));
+                                printed_date = 1;
+                        }
+                        
                         rc = lwt_print(f, t0, tlast, mhz, cpu, next_event[cpu]);
                         if (rc != 0)
                                 break;
@@ -1666,5 +1687,4 @@ jt_ptl_lwt(int argc, char **argv)
 
         free(events);
         return (0);
-#undef MAX_CPUS
 }