eventstat-0.01.31/0000775000175000017500000000000012312565674012350 5ustar kingkingeventstat-0.01.31/Makefile0000664000175000017500000000127212312565670014006 0ustar kingkingVERSION=0.01.31 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' BINDIR=/usr/bin MANDIR=/usr/share/man/man8 eventstat: eventstat.o $(CC) $(CFLAGS) $< -lm -o $@ $(LDFLAGS) eventstat.8.gz: eventstat.8 gzip -c $< > $@ dist: rm -rf eventstat-$(VERSION) mkdir eventstat-$(VERSION) cp -rp Makefile eventstat.c eventstat.8 COPYING eventstat-$(VERSION) tar -zcf eventstat-$(VERSION).tar.gz eventstat-$(VERSION) rm -rf eventstat-$(VERSION) clean: rm -f eventstat eventstat.o eventstat.8.gz rm -f eventstat-$(VERSION).tar.gz install: eventstat eventstat.8.gz mkdir -p ${DESTDIR}${BINDIR} cp eventstat ${DESTDIR}${BINDIR} mkdir -p ${DESTDIR}${MANDIR} cp eventstat.8.gz ${DESTDIR}${MANDIR} eventstat-0.01.31/eventstat.80000664000175000017500000000763412312565670014464 0ustar kingking.\" Hey, EMACS: -*- nroff -*- .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH EVENTSTAT 8 "January 2, 2014" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .SH NAME eventstat \- a tool to measure system events. .br .SH SYNOPSIS .B eventstat .RI [options] " [delay " [count]] .br .SH DESCRIPTION eventstat is a program that dumps the current active system events. .SH OPTIONS eventstat options are as follow: .TP .B \-h show help .TP .B \-n event_count only display the first event_count number of top events. .TP .B \-q run quietly, only really makes sense with \-r option. .TP .B \-r csv_file output gathered data in a comma separated values file. This can be then imported and graphed using your favourite open source spread sheet. .TP .B \-s report short process name from /proc/pid/cmdline in CSV output. This reports just the process name. .TP .B \-l report long process name from /proc/pid/cmdline in CSV output. This reports the process name and all the command line arguments. .TP .B \-b just report events, PID and process name. By default the short task name from the kernel comm field will be displayed, however the \-s and \-l options will report more process name information. .TP .B \-k report just kernel threads. .TP .B \-u report just user space processes. .TP .B \-C report the sample event count in the CSV output rather than the default events per second rate. .TP .B \-S report the minimum, maximum, average and population standard deviation at the end of the CSV output. .TP .B \-d strip full directory path off the process name in the CSV output. .TP .B \-t threshold ignore samples where the event delta per second less than the given threshold. .TP .B \-c report cumulative events rather than events per sample period. .SH EXAMPLES .LP Dump events every second until stopped. .RS 8 sudo eventstat .RE .LP Dump the top 20 events every 60 seconds until stopped. .RS 8 sudo eventstat \-n 20 60 .RE .LP Dump events every 10 seconds just 5 times. .RS 8 sudo eventstat 10 5 .RE .LP Quietly dump events every 10 seconds just 5 times into a CSV file with short process name. .RS 8 sudo eventstat 10 5 \-q \-s \-r results.csv .RE .SH CSV OUTPUT .LP The \-r option generates a comma separated file report that can be imported into spreadsheets or parsed using text processing tools. Column 1 of the data is the label for each row, columns 2 onwards contain the data for each task that generated a wakeup event. .LP The first row lists the task name of the thread or process. Task names in [ ] brackets are kernel threads, other tasks are the names of user space processes. By default these names are derived from the task names from /proc/timer_stats but the \-s \-l options fetch more complete task names from /proc/pid/cmdline instead. .LP The second and third rows list the names of the internal Linux kernel timer init and callback functions, respectively. .LP The fourth row lists the total number of wakeup events for each task during the entire run of eventstat. .LP The subsequent rows list the average number of wakeups per second measured during the sample interval for each task in column two onwards. The first column indicates the sample time (in seconds) since the start of the measuring. .SH SEE ALSO .BR powertop (8) .SH AUTHOR eventstat was written by Colin King .PP This manual page was written by Colin King , for the Ubuntu project (but may be used by others). eventstat-0.01.31/eventstat.c0000664000175000017500000007343112312565670014535 0ustar kingking/* * Copyright (C) 2011-2014 Canonical * Hugely modified parts from powertop-1.13, Copyright 2007, Intel Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define APP_NAME "eventstat" #define TIMER_STATS "/proc/timer_stats" #define TABLE_SIZE (32771) /* Should be a prime */ #define OPT_QUIET (0x00000001) #define OPT_CUMULATIVE (0x00000002) #define OPT_CMD_SHORT (0x00000004) #define OPT_CMD_LONG (0x00000008) #define OPT_DIRNAME_STRIP (0x00000010) #define OPT_SAMPLE_COUNT (0x00000020) #define OPT_RESULT_STATS (0x00000040) #define OPT_BRIEF (0x00000080) #define OPT_KERNEL (0x00000100) #define OPT_USER (0x00000200) #define OPT_CMD (OPT_CMD_SHORT | OPT_CMD_LONG) typedef struct link { void *data; /* Data in list */ struct link *next; /* Next item in list */ } link_t; typedef struct { link_t *head; /* Head of list */ link_t *tail; /* Tail of list */ size_t length; /* Length of list */ } list_t; typedef void (*list_link_free_t)(void *); typedef struct timer_info { pid_t pid; char *task; /* Name of process/kernel task */ char *cmdline; /* From /proc/$pid/cmdline */ char *func; /* Kernel waiting func */ char *callback; /* Kernel timer callback func */ char *ident; /* Unique identity */ bool kernel_thread; /* True if task is a kernel thread */ unsigned long total; /* Total number of events */ } timer_info_t; typedef struct timer_stat { unsigned long count; /* Number of events */ unsigned long delta; /* Change in events since last time */ timer_info_t *info; /* Timer info */ struct timer_stat *next; /* Next timer stat in hash table */ struct timer_stat *sorted_freq_next; /* Next timer stat in event frequency sorted list */ } timer_stat_t; /* sample delta item as an element of the sample_delta_list_t */ typedef struct sample_delta_item { unsigned long delta; /* difference in timer events between old and new */ timer_info_t *info; /* timer this refers to */ } sample_delta_item_t; /* list of sample_delta_items */ typedef struct sample_delta_list { struct timeval whence; /* when the sample was taken */ list_t list; } sample_delta_list_t; typedef struct { char *task; /* Name of kernel task */ size_t len; /* Length */ } kernel_task_info; #define KERN_TASK_INFO(str) { str, sizeof(str) - 1 } static list_t timer_info_list; /* cache list of timer_info */ static list_t sample_list; /* list of samples, sorted in sample time order */ static char *csv_results; /* results in comma separated values */ static volatile bool stop_eventstat = false; /* set by sighandler */ static double opt_threshold; /* ignore samples with event delta less than this */ static unsigned int opt_flags; /* option flags */ static bool sane_procs; /* false if we are in a container */ /* * sane_proc_pid_info() * detect if proc info mapping from /proc/timer_stats * maps to proc pids OK. If we are in a container or * we can't tell, return false. */ static bool sane_proc_pid_info(void) { FILE *fp; static const char pattern[] = "container="; const char *ptr = pattern; bool ret = true; fp = fopen("/proc/1/environ", "r"); if (!fp) return false; while (!feof(fp)) { int ch = getc(fp); if (*ptr == ch) { ptr++; /* Match? So we're inside a container */ if (*ptr == '\0') { ret = false; break; } } else { /* No match, skip to end of var and restart scan */ do { ch = getc(fp); } while ((ch != EOF) && (ch != '\0')); ptr = pattern; } } fclose(fp); return ret; } /* * timeval_sub() * timeval a - b */ static struct timeval timeval_sub(const struct timeval *a, const struct timeval *b) { struct timeval ret, _b; _b.tv_sec = b->tv_sec; _b.tv_usec = b->tv_usec; if (a->tv_usec < _b.tv_usec) { int nsec = ((_b.tv_usec - a->tv_usec) / 1000000) + 1; _b.tv_sec += nsec; _b.tv_usec -= (1000000 * nsec); } if (a->tv_usec - _b.tv_usec > 1000000) { int nsec = (a->tv_usec - _b.tv_usec) / 1000000; _b.tv_sec -= nsec; _b.tv_usec += (1000000 * nsec); } ret.tv_sec = a->tv_sec - _b.tv_sec; ret.tv_usec = a->tv_usec - _b.tv_usec; return ret; } /* * timeval_add() * timeval a + b */ static struct timeval timeval_add(const struct timeval *a, const struct timeval *b) { struct timeval ret; ret.tv_sec = a->tv_sec + b->tv_sec; ret.tv_usec = a->tv_usec + b->tv_usec; if (ret.tv_usec > 1000000) { int nsec = (ret.tv_usec / 1000000); ret.tv_sec += nsec; ret.tv_usec -= (1000000 * nsec); } return ret; } /* * timeval_double * timeval to a double */ static inline double timeval_double(const struct timeval *tv) { return (double)tv->tv_sec + ((double)tv->tv_usec / 1000000.0); } /* * set_timer_stat() * enable/disable timer stat */ static void set_timer_stat(const char *str, const bool carp) { FILE *fp; if ((fp = fopen(TIMER_STATS, "w")) == NULL) { if (carp) { fprintf(stderr, "Cannot write to %s\n",TIMER_STATS); exit(EXIT_FAILURE); } else { return; } } fprintf(fp, "%s\n", str); fclose(fp); } /* * Stop gcc complaining about no return func */ static void eventstat_exit(const int status) __attribute__ ((noreturn)); /* * eventstat_exit() * exit and set timer stat to 0 */ static void eventstat_exit(const int status) { set_timer_stat("0", false); exit(status); } /* * list_init() * initialize list */ static inline void list_init(list_t *list) { list->head = NULL; list->tail = NULL; list->length = 0; } /* * list_append() * add a new item to end of the list */ static link_t *list_append(list_t *list, void *data) { link_t *link; if ((link = calloc(1, sizeof(link_t))) == NULL) { fprintf(stderr, "Cannot allocate list link\n"); eventstat_exit(EXIT_FAILURE); } link->data = data; if (list->head == NULL) { list->head = link; } else { list->tail->next = link; } list->tail = link; list->length++; return link; } /* * list_free() * free the list */ static void list_free(list_t *list, const list_link_free_t freefunc) { link_t *link, *next; if (list == NULL) return; for (link = list->head; link; link = next) { next = link->next; if (link->data && freefunc) freefunc(link->data); free(link); } } /* * handle_sigint() * catch SIGINT and flag a stop */ static void handle_sigint(int dummy) { (void)dummy; /* Stop unused parameter warning with -Wextra */ stop_eventstat = true; } /* * sample_delta_free() * free the sample delta list */ static void sample_delta_free(void *data) { sample_delta_list_t *sdl = (sample_delta_list_t*)data; list_free(&sdl->list, free); free(sdl); } /* * samples_free() * free collected samples */ static void samples_free(void) { list_free(&sample_list, sample_delta_free); } /* * sample_add() * add a timer_stat's delta and info field to a list at time position whence */ static void sample_add(timer_stat_t *timer_stat, struct timeval *whence) { link_t *link; bool found = false; sample_delta_list_t *sdl = NULL; sample_delta_item_t *sdi; if (csv_results == NULL) /* No need if not request */ return; for (link = sample_list.head; link; link = link->next) { sdl = (sample_delta_list_t*)link->data; if ((sdl->whence.tv_sec == whence->tv_sec) && (sdl->whence.tv_usec == whence->tv_usec)) { found = true; break; } } /* * New time period, need new sdl, we assume it goes at the end of the * list since time is assumed to be increasing */ if (!found) { if ((sdl = calloc(1, sizeof(sample_delta_list_t))) == NULL) { fprintf(stderr, "Cannot allocate sample delta list\n"); eventstat_exit(EXIT_FAILURE); } sdl->whence = *whence; list_append(&sample_list, sdl); } /* Now append the sdi onto the list */ if ((sdi = calloc(1, sizeof(sample_delta_item_t))) == NULL) { fprintf(stderr, "Cannot allocate sample delta item\n"); eventstat_exit(EXIT_FAILURE); } sdi->delta = timer_stat->delta; sdi->info = timer_stat->info; list_append(&sdl->list, sdi); } /* * sample_find() * scan through a sample_delta_list for timer info, return NULL if not found */ inline static sample_delta_item_t *sample_find(sample_delta_list_t *sdl, const timer_info_t *info) { link_t *link; for (link = sdl->list.head; link; link = link->next) { sample_delta_item_t *sdi = (sample_delta_item_t*)link->data; if (sdi->info == info) return sdi; } return NULL; } /* * info_compare_total() * used by qsort to sort array in sample event total order */ static int info_compare_total(const void *item1, const void *item2) { timer_info_t **info1 = (timer_info_t **)item1; timer_info_t **info2 = (timer_info_t **)item2; return (*info2)->total - (*info1)->total; } /* * pid_a_kernel_thread * */ static bool pid_a_kernel_thread(const char *task, const pid_t id) { if (sane_procs) { return getpgid(id) == 0; } else { /* In side a container, make a guess at kernel threads */ int i; pid_t pgid = getpgid(id); /* This fails for kernel threads inside a container */ if (pgid >= 0) return pgid == 0; /* * This is not exactly accurate, but if we can't look up * a process then try and infer something from the comm field. * Until we have better kernel support to map /proc/timer_stats * pids to containerised pids this is the best we can do. */ static kernel_task_info kernel_tasks[] = { KERN_TASK_INFO("swapper/"), KERN_TASK_INFO("kworker/"), KERN_TASK_INFO("ksoftirqd/"), KERN_TASK_INFO("watchdog/"), KERN_TASK_INFO("migration/"), KERN_TASK_INFO("irq/"), KERN_TASK_INFO("mmcqd/"), KERN_TASK_INFO("jbd2/"), KERN_TASK_INFO("kthreadd"), KERN_TASK_INFO("kthrotld"), KERN_TASK_INFO("kswapd"), KERN_TASK_INFO("ecryptfs-kthrea"), KERN_TASK_INFO("kauditd"), KERN_TASK_INFO("kblockd"), KERN_TASK_INFO("kcryptd"), KERN_TASK_INFO("kdevtmpfs"), KERN_TASK_INFO("khelper"), KERN_TASK_INFO("khubd"), KERN_TASK_INFO("khugepaged"), KERN_TASK_INFO("khungtaskd"), KERN_TASK_INFO("flush-"), KERN_TASK_INFO("bdi-default-"), { NULL, 0 } }; for (i = 0; kernel_tasks[i].task != NULL; i++) { if (strncmp(task, kernel_tasks[i].task, kernel_tasks[i].len) == 0) return true; } } return false; } /* * get_pid_cmdline * get process's /proc/pid/cmdline */ static char *get_pid_cmdline(const pid_t id) { char buffer[4096]; char *ptr; int fd; ssize_t ret; snprintf(buffer, sizeof(buffer), "/proc/%d/cmdline", id); if ((fd = open(buffer, O_RDONLY)) < 0) return NULL; if ((ret = read(fd, buffer, sizeof(buffer))) <= 0) { close(fd); return NULL; } close(fd); buffer[sizeof(buffer)-1] = '\0'; /* * OPT_CMD_LONG option we get the full cmdline args */ if (opt_flags & OPT_CMD_LONG) { for (ptr = buffer; ptr < buffer + ret - 1; ptr++) { if (*ptr == '\0') *ptr = ' '; } *ptr = '\0'; } /* * OPT_CMD_SHORT option we discard anything after a space */ if (opt_flags & OPT_CMD_SHORT) { for (ptr = buffer; *ptr && (ptr < buffer + ret); ptr++) { if (*ptr == ' ') *ptr = '\0'; } } if (opt_flags & OPT_DIRNAME_STRIP) return strdup(basename(buffer)); return strdup(buffer); } /* * samples_dump() * dump out collected sample information */ static void samples_dump(const char *filename, const struct timeval *duration) { sample_delta_list_t *sdl; timer_info_t **sorted_timer_infos; link_t *link; size_t i = 0; size_t n = timer_info_list.length; FILE *fp; unsigned long count = 0; double dur; bool dur_zero; if (filename == NULL) return; if ((fp = fopen(filename, "w")) == NULL) { fprintf(stderr, "Cannot write to file %s\n", filename); return; } if ((sorted_timer_infos = calloc(n, sizeof(timer_info_t*))) == NULL) { fprintf(stderr, "Cannot allocate buffer for sorting timer_infos\n"); eventstat_exit(EXIT_FAILURE); } /* Just want the timers with some non-zero total */ for (n = 0, link = timer_info_list.head; link; link = link->next) { timer_info_t *info = (timer_info_t*)link->data; if (info->total > 0) sorted_timer_infos[n++] = info; } qsort(sorted_timer_infos, n, sizeof(timer_info_t *), info_compare_total); fprintf(fp, "Task:"); for (i = 0; i < n; i++) { char *task; if ((opt_flags & OPT_CMD) && (sorted_timer_infos[i]->cmdline != NULL)) task = sorted_timer_infos[i]->cmdline; else task = sorted_timer_infos[i]->task; fprintf(fp, ",%s", task); } fprintf(fp, "\n"); fprintf(fp, "Init Function:"); for (i = 0; i < n; i++) fprintf(fp, ",%s", sorted_timer_infos[i]->func); fprintf(fp, "\n"); fprintf(fp, "Callback:"); for (i = 0; i < n; i++) fprintf(fp, ",%s", sorted_timer_infos[i]->callback); fprintf(fp, "\n"); fprintf(fp, "Total:"); for (i = 0; i < n; i++) fprintf(fp, ",%lu", sorted_timer_infos[i]->total); fprintf(fp, "\n"); /* * duration - if -C option is used then don't scale by the * per sample duration time, instead give the raw sample count * by scaling by 1.0 (i.e. no scaling). */ dur = (opt_flags & OPT_SAMPLE_COUNT) ? 1.0 : timeval_double(duration); dur_zero = (duration->tv_sec == 0) && (duration->tv_usec == 0); for (link = sample_list.head; link; link = link->next) { count++; sdl = (sample_delta_list_t*)link->data; fprintf(fp, "%f", timeval_double(&sdl->whence)); /* Scan in timer info order to be consistent for all sdl rows */ for (i = 0; i < n; i++) { sample_delta_item_t *sdi = sample_find(sdl, sorted_timer_infos[i]); if (sdi) fprintf(fp, ",%f", dur_zero ? 0.0 : (double)sdi->delta / dur); else fprintf(fp, ",%f", 0.0); } fprintf(fp, "\n"); } /* * -S option - some statistics, min, max, average, std.dev. */ if (opt_flags & OPT_RESULT_STATS) { fprintf(fp, "Min:"); for (i = 0; i < n; i++) { unsigned long min = ~0; for (link = sample_list.head; link; link = link->next) { sdl = (sample_delta_list_t*)link->data; sample_delta_item_t *sdi = sample_find(sdl, sorted_timer_infos[i]); if (sdi && min > sdi->delta) min = sdi->delta; } fprintf(fp, ",%f", dur_zero ? 0.0 : (double)min / dur); } fprintf(fp, "\n"); fprintf(fp, "Max:"); for (i = 0; i < n; i++) { unsigned long max = 0; for (link = sample_list.head; link; link = link->next) { sdl = (sample_delta_list_t*)link->data; sample_delta_item_t *sdi = sample_find(sdl, sorted_timer_infos[i]); if (sdi && max < sdi->delta) max = sdi->delta; } fprintf(fp, ",%f", dur_zero ? 0.0 : (double)max / dur); } fprintf(fp, "\n"); fprintf(fp, "Average:"); for (i = 0; i < n; i++) fprintf(fp, ",%f", dur_zero ? 0.0 : ((double)sorted_timer_infos[i]->total / dur) / (double)count); fprintf(fp, "\n"); /* * population standard deviation */ fprintf(fp, "Std.Dev.:"); for (i = 0; i < n; i++) { double average = (double)sorted_timer_infos[i]->total / (double)count; double sum = 0.0; for (link = sample_list.head; link; link = link->next) { sdl = (sample_delta_list_t*)link->data; sample_delta_item_t *sdi = sample_find(sdl, sorted_timer_infos[i]); if (sdi) { double diff = dur_zero ? 0.0 : ((double)sdi->delta - average) / dur; diff = diff * diff; sum += diff; } } sum = sum / (double)count; fprintf(fp, ",%f", sqrt(sum)); } fprintf(fp, "\n"); } free(sorted_timer_infos); fclose(fp); } /* * timer_info_find() * try to find existing timer info in cache, and to the cache * if it is new. */ static timer_info_t *timer_info_find(const timer_info_t *new_info) { link_t *link; timer_info_t *info; for (link = timer_info_list.head; link; link = link->next) { info = (timer_info_t*)link->data; if (strcmp(new_info->ident, info->ident) == 0) return info; } if ((info = calloc(1, sizeof(timer_info_t))) == NULL) { fprintf(stderr, "Cannot allocate timer info\n"); eventstat_exit(EXIT_FAILURE); } info->pid = new_info->pid; info->task = strdup(new_info->task); if (opt_flags & OPT_CMD) info->cmdline = get_pid_cmdline(new_info->pid); info->func = strdup(new_info->func); info->callback = strdup(new_info->callback); info->ident = strdup(new_info->ident); info->kernel_thread = new_info->kernel_thread; info->total = new_info->total; if (info->task == NULL || info->func == NULL || info->callback == NULL || info->ident == NULL) { fprintf(stderr, "Out of memory allocating a timer stat fields\n"); eventstat_exit(EXIT_FAILURE); } /* Does not exist in list, append it */ list_append(&timer_info_list, info); return info; } /* * timer_info_free() * free up timer_info */ static void timer_info_free(void *data) { timer_info_t *info = (timer_info_t*)data; free(info->task); free(info->cmdline); free(info->func); free(info->callback); free(info->ident); free(info); } /* * timer_info_free * free up all unique timer infos */ static void timer_info_list_free(void) { list_free(&timer_info_list, timer_info_free); } /* * hash_pjw() * Hash a string, from Aho, Sethi, Ullman, Compiling Techniques. */ static unsigned long hash_pjw(const char *str) { unsigned long h = 0; while (*str) { unsigned long g; h = (h << 4) + (*str); if (0 != (g = h&0xf0000000)) { h = h ^ (g >> 24); h = h ^ g; } str++; } return h % TABLE_SIZE; } /* * timer_stat_free_contents() * Free timers from a hash table */ static void timer_stat_free_contents( timer_stat_t *timer_stats[]) /* timer stat hash table */ { int i; for (i = 0; i < TABLE_SIZE; i++) { timer_stat_t *ts = timer_stats[i]; while (ts) { timer_stat_t *next = ts->next; free(ts); ts = next; } timer_stats[i] = NULL; } } /* * timer_stat_add() * add timer stats to a hash table if it is new, otherwise just * accumulate the event count. */ static void timer_stat_add( timer_stat_t *timer_stats[], /* timer stat hash table */ const unsigned long count, /* event count */ const pid_t pid, /* PID of task */ char *task, /* Name of task */ char *func, /* Kernel function */ char *callback, /* Kernel timer callback */ const bool kernel_thread) /* Is a kernel thread */ { char buf[4096]; timer_stat_t *ts; timer_stat_t *ts_new; timer_info_t info; unsigned long h; snprintf(buf, sizeof(buf), "%d:%s:%s:%s", pid, task, func, callback); h = hash_pjw(buf); ts = timer_stats[h]; for (ts = timer_stats[h]; ts; ts = ts->next) { if (strcmp(ts->info->ident, buf) == 0) { ts->count += count; return; } } /* Not found, it is new! */ if ((ts_new = malloc(sizeof(timer_stat_t))) == NULL) { fprintf(stderr, "Out of memory allocating a timer stat\n"); eventstat_exit(EXIT_FAILURE); } info.pid = pid; info.task = task; info.func = func; info.callback = callback; info.ident = buf; info.kernel_thread = kernel_thread; info.total = count; ts_new->count = count; ts_new->info = timer_info_find(&info); ts_new->next = timer_stats[h]; ts_new->sorted_freq_next = NULL; timer_stats[h] = ts_new; } /* * timer_stat_find() * find a timer stat (needle) in a timer stat hash table (haystack) */ static timer_stat_t *timer_stat_find( timer_stat_t *haystack[], /* timer stat hash table */ timer_stat_t *needle) /* timer stat to find */ { timer_stat_t *ts; char buf[4096]; snprintf(buf, sizeof(buf), "%d:%s:%s:%s", needle->info->pid, needle->info->task, needle->info->func, needle->info->callback); for (ts = haystack[hash_pjw(buf)]; ts; ts = ts->next) { if (strcmp(ts->info->ident, buf) == 0) return ts; } return NULL; /* no success */ } /* * timer_stat_sort_freq_add() * add a timer stat to a sorted list of timer stats */ static void timer_stat_sort_freq_add( timer_stat_t **sorted, /* timer stat sorted list */ timer_stat_t *new) /* timer stat to add */ { while (*sorted) { if (opt_flags & OPT_CUMULATIVE) { if ((*sorted)->count < new->count) { new->sorted_freq_next = *(sorted); break; } } else { if ((*sorted)->delta < new->delta) { new->sorted_freq_next = *(sorted); break; } } sorted = &(*sorted)->sorted_freq_next; } *sorted = new; } /* * timer_stat_diff() * find difference in event count between to hash table samples of timer * stats. We are interested in just current and new timers, not ones that * silently die */ static void timer_stat_diff( struct timeval *duration, /* time between each sample */ const int n_lines, /* number of lines to output */ struct timeval *whence, /* nth sample */ timer_stat_t *timer_stats_old[],/* old timer stats samples */ timer_stat_t *timer_stats_new[])/* new timer stats samples */ { int i; double dur = timeval_double(duration); timer_stat_t *sorted = NULL; for (i = 0; i < TABLE_SIZE; i++) { timer_stat_t *ts; for (ts = timer_stats_new[i]; ts; ts = ts->next) { timer_stat_t *found = timer_stat_find(timer_stats_old, ts); if (found) { ts->delta = ts->count - found->count; if (ts->delta >= opt_threshold) { timer_stat_sort_freq_add(&sorted, ts); sample_add(ts, whence); found->info->total += ts->delta; } } else { ts->delta = ts->count; if (ts->delta >= opt_threshold) { timer_stat_sort_freq_add(&sorted, ts); sample_add(ts, whence); } } } } if (!(opt_flags & OPT_QUIET)) { unsigned long total = 0UL, kt_total = 0UL; int j = 0; printf("%8s %-5s %-15s", opt_flags & OPT_CUMULATIVE ? "Events" : "Event/s", "PID", "Task"); if (!(opt_flags & OPT_BRIEF)) printf(" %-25s %-s\n", "Init Function", "Callback"); else printf("\n"); while (sorted) { if (((n_lines == -1) || (j < n_lines)) && (sorted->delta != 0)) { j++; if (opt_flags & OPT_CUMULATIVE) printf("%8lu ", sorted->count); else printf("%8.2f ", (double)sorted->delta / dur); if (opt_flags & OPT_BRIEF) { char *cmd = sorted->info->cmdline ? sorted->info->cmdline : sorted->info->task; printf("%5d %s\n", sorted->info->pid, opt_flags & OPT_CMD ? cmd : sorted->info->task); } else { printf("%5d %-15s %-25s %-s\n", sorted->info->pid, sorted->info->task, sorted->info->func, sorted->info->callback); } } total += sorted->delta; if (sorted->info->kernel_thread) kt_total += sorted->delta; sorted = sorted->sorted_freq_next; } printf("%lu Total events, %5.2f events/sec (kernel: %5.2f, userspace: %5.2f)\n", total, (double)total / dur, (double)kt_total / dur, (double)(total - kt_total) / dur); if (!sane_procs) printf("Note: this was run inside a container, kernel tasks were guessed.\n"); printf("\n"); } } /* * get_events() * scan /proc/timer_stats and populate a timer stat hash table with * unique events */ static void get_events(timer_stat_t *timer_stats[]) /* hash table to populate */ { FILE *fp; char buf[4096]; if ((fp = fopen(TIMER_STATS, "r")) == NULL) { fprintf(stderr, "Cannot open %s\n", TIMER_STATS); return; } /* Originally from PowerTop, but majorly re-worked */ while (!feof(fp)) { char *ptr = buf; unsigned long count = -1; pid_t pid = -1; char task[64]; char func[128]; char timer[128]; bool kernel_thread; int mask; if (fgets(buf, sizeof(buf), fp) == NULL) break; if (strstr(buf, "total events") != NULL) break; if (strstr(buf, ",") == NULL) continue; /* format: count[D], pid, task, func (timer) */ while (*ptr && *ptr != ',') ptr++; if (*ptr != ',') continue; if (ptr > buf && *(ptr-1) == 'D') continue; /* Deferred event, skip */ ptr++; sscanf(buf, "%21lu", &count); memset(task, 0, sizeof(task)); memset(func, 0, sizeof(func)); memset(timer, 0, sizeof(timer)); if (sscanf(ptr, "%10d %63s %127s (%127[^)])", &pid, task, func, timer) != 4) continue; kernel_thread = pid_a_kernel_thread(task, pid); /* Swapper is special, like all corner cases */ if (strncmp(task, "swapper", 6) == 0) kernel_thread = true; mask = kernel_thread ? OPT_KERNEL : OPT_USER; if (!(opt_flags & mask)) continue; if (kernel_thread) { char tmp[64]; task[13] = '\0'; snprintf(tmp, sizeof(tmp), "[%s]", task); strcpy(task, tmp); } if (strcmp(task, "insmod") == 0) strcpy(task, "[kern mod]"); if (strcmp(task, "modprobe") == 0) strcpy(task, "[kern mod]"); if ((strncmp(func, "tick_nohz_", 10) == 0) || (strncmp(func, "tick_setup_sched_timer", 20) == 0) || (strcmp(task, APP_NAME) == 0)) continue; timer_stat_add(timer_stats, count, pid, task, func, timer, kernel_thread); } fclose(fp); } /* * show_usage() * show how to use */ static void show_usage(void) { printf("%s, version %s\n\n", APP_NAME, VERSION); printf("Usage: %s [options] [duration] [count]\n", APP_NAME); printf("Options are:\n"); printf(" -c\t\treport cumulative events rather than events per second.\n"); printf(" -C\t\treport event count rather than event per second in CSV output.\n"); printf(" -d\t\tremove pathname from long process name in CSV output.\n"); printf(" -h\t\tprint this help.\n"); printf(" -l\t\tuse long cmdline text from /proc/pid/cmdline in CSV output.\n"); printf(" -n events\tspecifies number of events to display.\n"); printf(" -q\t\trun quietly, useful with option -r.\n"); printf(" -r filename\tspecifies a comma separated values (CSV) output file to dump samples into.\n"); printf(" -s\t\tuse short process name from /proc/pid/cmdline in CSV output.\n"); printf(" -S\t\tcalculate min, max, average and standard deviation in CSV output.\n"); printf(" -t threshold\tsamples less than the specified threshold are ignored.\n"); } int main(int argc, char **argv) { timer_stat_t **timer_stats_old, **timer_stats_new, **tmp; double duration_secs = 1.0; int count = 1; int n_lines = -1; bool forever = true; struct timeval tv1, tv2, duration, whence; list_init(&timer_info_list); list_init(&sample_list); for (;;) { int c = getopt(argc, argv, "bcCdksSlhn:qr:t:u"); if (c == -1) break; switch (c) { case 'b': opt_flags |= OPT_BRIEF; break; case 'c': opt_flags |= OPT_CUMULATIVE; break; case 'C': opt_flags |= OPT_SAMPLE_COUNT; break; case 'd': opt_flags |= OPT_DIRNAME_STRIP; break; case 'h': show_usage(); eventstat_exit(EXIT_SUCCESS); case 'n': n_lines = atoi(optarg); if (n_lines < 1) { fprintf(stderr, "-n option must be greater than 0\n"); eventstat_exit(EXIT_FAILURE); } break; case 't': opt_threshold = strtoull(optarg, NULL, 10); if (opt_threshold < 1) { fprintf(stderr, "-t threshold must be 1 or more.\n"); eventstat_exit(EXIT_FAILURE); } break; case 'q': opt_flags |= OPT_QUIET; break; case 'r': csv_results = optarg; break; case 's': opt_flags |= OPT_CMD_SHORT; break; case 'S': opt_flags |= OPT_RESULT_STATS; break; case 'l': opt_flags |= OPT_CMD_LONG; break; case 'k': opt_flags |= OPT_KERNEL; break; case 'u': opt_flags |= OPT_USER; break; } } if (!(opt_flags & (OPT_KERNEL | OPT_USER))) opt_flags |= (OPT_KERNEL | OPT_USER); if (optind < argc) { duration_secs = atof(argv[optind++]); if (duration_secs < 0.5) { fprintf(stderr, "Duration must 0.5 or more.\n"); eventstat_exit(EXIT_FAILURE); } } if (optind < argc) { forever = false; count = atoi(argv[optind++]); if (count < 1) { fprintf(stderr, "Count must be > 0\n"); eventstat_exit(EXIT_FAILURE); } } duration.tv_sec = (time_t)duration_secs; duration.tv_usec = (suseconds_t)(duration_secs * 1000000.0) - (duration.tv_sec * 1000000); opt_threshold *= duration_secs; if (geteuid() != 0) { fprintf(stderr, "%s requires root privileges to write to %s\n", APP_NAME, TIMER_STATS); eventstat_exit(EXIT_FAILURE); } sane_procs = sane_proc_pid_info(); if (!sane_procs) opt_flags &= ~(OPT_CMD_SHORT | OPT_CMD_LONG); signal(SIGINT, &handle_sigint); if ((timer_stats_old = calloc(TABLE_SIZE, sizeof(timer_stat_t*))) == NULL) { fprintf(stderr, "Cannot allocate old timer stats table\n"); eventstat_exit(EXIT_FAILURE); } if ((timer_stats_new = calloc(TABLE_SIZE, sizeof(timer_stat_t*))) == NULL) { fprintf(stderr, "Cannot allocate old timer stats table\n"); eventstat_exit(EXIT_FAILURE); } /* Should really catch signals and set back to zero before we die */ set_timer_stat("1", true); gettimeofday(&tv1, NULL); get_events(timer_stats_old); whence.tv_sec = 0; whence.tv_usec = 0; while (!stop_eventstat && (forever || count--)) { struct timeval tv; int ret; gettimeofday(&tv2, NULL); tv = timeval_add(&duration, &whence); tv = timeval_add(&tv, &tv1); tv2 = tv = timeval_sub(&tv, &tv2); /* Play catch-up, probably been asleep */ if (tv.tv_sec < 0) { tv.tv_sec = 0; tv.tv_usec = 0; tv2 = tv; } ret = select(0, NULL, NULL, NULL, &tv2); if (ret < 0) { if (errno == EINTR) { duration = timeval_sub(&tv, &tv2); stop_eventstat = true; } else { fprintf(stderr, "Select failed: %s\n", strerror(errno)); break; } } get_events(timer_stats_new); timer_stat_diff(&duration, n_lines, &whence, timer_stats_old, timer_stats_new); timer_stat_free_contents(timer_stats_old); tmp = timer_stats_old; timer_stats_old = timer_stats_new; timer_stats_new = tmp; whence = timeval_add(&duration, &whence); } samples_dump(csv_results, &duration); timer_stat_free_contents(timer_stats_old); timer_stat_free_contents(timer_stats_new); free(timer_stats_old); free(timer_stats_new); samples_free(); timer_info_list_free(); eventstat_exit(EXIT_SUCCESS); } eventstat-0.01.31/COPYING0000664000175000017500000004325412312565670013407 0ustar kingking GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License.