[PATCH] Remove unused "--kernel-buffersize-multiplier" option from operf

The "--kernel-buffersize-multiplier" option was not wired in to
perform any actions.  In the course of wiring it in to the mmap
call (where the operf record process mmap's the perf_events kernel
data) and performing functional tests, I found that bumping up
the mmap size had little noticeable beneficial effect -- perhaps
even *no* effect at all.  I expected that the perf_event_header type
of PERF_RECORD_LOST would be an indication that a larger kernel
buffer (i.e., mmap'ed area) was needed.  I was able to force such
"LOST" samples by using a very high sampling rate, yet increasing
the number mmap pages did not eliminate the LOST samples.  So I
removed this option from the code and the man page.

This patch has been pushed into the perf-events branch.

Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
---
 doc/operf.1.in                 |    6 ------
 libperf_events/operf_stats.cpp |   20 +++++++++++++++-----
 libperf_events/operf_stats.h   |    1 +
 pe_profiling/operf.cpp         |    8 +-------
 4 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/doc/operf.1.in b/doc/operf.1.in
index 5db93f5..0de46b1 100644
--- a/doc/operf.1.in
+++ b/doc/operf.1.in
@@ -100,12 +100,6 @@ invocation of oprofile post-processing tools.  For example:
 .I "   opreport --session-dir=`pwd`/oprofile_data session:previous"
 .br
 .TP
-.BI "--kernel-buffersize-multiplier / -k " buffersize
-This option enables operf to increase the kernel buffer size by a
-factor of
-.I buffersize.
-.br
-.TP
 .BI "--events / -e " event1[,event2[,...]]
 This option is for passing a comma-separated list of event specifications
 for profiling. Each event spec is of the form:
diff --git a/libperf_events/operf_stats.cpp b/libperf_events/operf_stats.cpp
index 0bdb94e..ba2db25 100644
--- a/libperf_events/operf_stats.cpp
+++ b/libperf_events/operf_stats.cpp
@@ -56,16 +56,26 @@ void operf_print_stats(string sessiondir, char * starttime, bool throttled)
 	if (operf_stats[OPERF_RECORD_LOST_SAMPLE]) {
 		fprintf(stderr, "\n\n * * * ATTENTION: The kernel lost %lu samples. * * *\n",
 		        operf_stats[OPERF_RECORD_LOST_SAMPLE]);
+		fprintf(stderr, "Decrease the sampling rate to eliminate (or reduce) lost samples.\n");
 	} else if (throttled) {
 		fprintf(stderr, "* * * * WARNING: Profiling rate was throttled back by the kernel * * * *\n");
-		fprintf(stderr, "The number of samples actually recorded is less than expected.\n");
-	}
-	if (operf_stats[OPERF_RECORD_LOST_SAMPLE] || throttled) {
-		fprintf(stderr, "Try decreasing your sampling rate.\n");
-		fprintf(stderr, "See the %s file for more profiling statistics.\n", operf_log.c_str());
+		fprintf(stderr, "The number of samples actually recorded is less than expected, but is\n");
+		fprintf(stderr, "probably still statistically valid.  Decreasing the sampling rate is the\n");
+		fprintf(stderr, "best option if you want to avoid throttling.");
 	}
+
 	// TODO: handle extended stats
 	//operf_ext_print_stats();
 
+	bool print_log_info_msg = false;
+	for (int i = OPERF_INDEX_OF_FIRST_LOST_STAT; i < OPERF_MAX_STATS; i++) {
+		if (operf_stats[i]) {
+			print_log_info_msg = true;
+			break;
+		}
+	}
+	if (print_log_info_msg)
+		fprintf(stderr, "\nSee the %s file for statistics about lost samples.\n", operf_log.c_str());
+
 	fflush(fp);
 }
diff --git a/libperf_events/operf_stats.h b/libperf_events/operf_stats.h
index 46c236d..48dbc1b 100644
--- a/libperf_events/operf_stats.h
+++ b/libperf_events/operf_stats.h
@@ -31,6 +31,7 @@ enum {	OPERF_SAMPLES, /**< nr. samples */
 	OPERF_RECORD_LOST_SAMPLE, /**<nr. samples lost reported by perf_events kernel */
 	OPERF_MAX_STATS /**< end of stats */
 };
+#define OPERF_INDEX_OF_FIRST_LOST_STAT 3
 
 void operf_print_stats(std::string sampledir, char * starttime, bool throttled);
 
diff --git a/pe_profiling/operf.cpp b/pe_profiling/operf.cpp
index 0cf3778..45290e9 100644
--- a/pe_profiling/operf.cpp
+++ b/pe_profiling/operf.cpp
@@ -113,7 +113,6 @@ struct option long_options [] =
  {"system-wide", no_argument, NULL, 's'},
  {"append", no_argument, NULL, 'a'},
  {"pid", required_argument, NULL, 'p'},
- {"kernel-buffersize-multiplier", required_argument, NULL, 'b'},
  {"events", required_argument, NULL, 'e'},
  {"separate-cpu", no_argument, NULL, 'c'},
  {"separate-thread", no_argument, NULL, 't'},
@@ -123,7 +122,7 @@ struct option long_options [] =
  {NULL, 9, NULL, 0}
 };
 
-const char * short_options = "V:d:k:gsap:b:e:cthuv";
+const char * short_options = "V:d:k:gsap:e:cthuv";
 
 vector<string> verbose_string;
 
@@ -1356,11 +1355,6 @@ static int _process_operf_and_app_args(int argc, char * const argv[])
 			if (endptr == optarg)
 				__print_usage_and_exit("operf: Invalid numeric value for --pid option.");
 			break;
-		case 'b':
-			operf_options::mmap_pages_mult = strtol(optarg, &endptr, 10);
-			if (endptr == optarg)
-				__print_usage_and_exit("operf: Invalid numeric value for --kernel-buffersize-multiplier option.");
-			break;
 		case 'e':
 			event = strtok(optarg, ",");
 			do {
-- 
1.6.2.rc2