diff -u ureadahead-0.100.0/src/trace.c ureadahead-0.100.0/src/trace.c --- ureadahead-0.100.0/src/trace.c +++ ureadahead-0.100.0/src/trace.c @@ -117,6 +117,7 @@ int timeout) { int dfd; + FILE *fp; int unmount = FALSE; int old_sys_open_enabled = 0; int old_open_exec_enabled = 0; @@ -129,6 +130,7 @@ struct timeval tv; nih_local PackFile *files = NULL; size_t num_files = 0; + size_t num_cpus = 0; /* Mount debugfs if not already mounted */ dfd = open (PATH_DEBUGFS "/tracing", O_RDONLY | O_NOATIME); @@ -149,7 +151,29 @@ unmount = TRUE; } - /* Enable tracing of open() syscalls */ + /* + * Count the number of CPUs, default to 1 on error. + */ + fp = fopen("/proc/cpuinfo", "r"); + if (fp) { + int line_size=1024; + char *processor="processor"; + char *line = malloc(line_size); + if (line) { + num_cpus = 0; + while (fgets(line,line_size,fp) != NULL) { + if (!strncmp(line,processor,strlen(processor))) + num_cpus++; + } + free(line); + nih_message("Counted %d CPUs\n",num_cpus); + } + fclose(fp); + } + if (!num_cpus) + num_cpus = 1; + + /* Enable tracing of open() syscalls */ if (set_value (dfd, "events/fs/do_sys_open/enable", TRUE, &old_sys_open_enabled) < 0) goto error; @@ -166,7 +190,7 @@ old_uselib_enabled = -1; } - if (set_value (dfd, "buffer_size_kb", 128000, &old_buffer_size_kb) < 0) + if (set_value (dfd, "buffer_size_kb", 128000/num_cpus, &old_buffer_size_kb) < 0) goto error; if (set_value (dfd, "tracing_enabled", TRUE, &old_tracing_enabled) < 0) diff -u ureadahead-0.100.0/debian/changelog ureadahead-0.100.0/debian/changelog --- ureadahead-0.100.0/debian/changelog +++ ureadahead-0.100.0/debian/changelog @@ -1,3 +1,15 @@ +ureadahead (0.100.0-4.1.3) lucid-proposed; urgency=low + + * Count the number of CPUs and divide buffer_size_kb by the number of CPUs. + Users should watch for instances of "mmiotrace has lost events" in dmesg to make + sure the trace buffers are not too small. The original value for + buffer_size_kb was chosen somewhat arbitrarily. Empirical testing + has shown that its large enough, so we don't actually know where the lower + boundary lies. + -LP: #491943 + + -- Tim Gardner Fri, 13 Aug 2010 12:44:12 -0700 + ureadahead (0.100.0-4.1.2) lucid-proposed; urgency=low * Restore buffer_size_kb upon exit, but do it _after_