kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [4/4] incubator-kudu git commit: KUDU-1316. Fix parsing of available CPUs on single-core machines
Date Tue, 26 Jan 2016 17:14:02 GMT
KUDU-1316. Fix parsing of available CPUs on single-core machines

This also changes the startup process to FATAL if procfs is unavailable.
Previously, we could continue but would probably just crash in the
parts of code where we depend on the CPU count.

Change-Id: I0dda1aab4735edeb4ebff901db627427d44ef555
Reviewed-on: http://gerrit.cloudera.org:8080/1908
Reviewed-by: Jean-Daniel Cryans
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/f0902543
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/f0902543
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/f0902543

Branch: refs/heads/master
Commit: f090254322c5445f0d1d7098cadb279ad78250e0
Parents: 242e5da
Author: Todd Lipcon <todd@apache.org>
Authored: Tue Jan 26 08:46:18 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Tue Jan 26 17:13:16 2016 +0000

----------------------------------------------------------------------
 src/kudu/gutil/sysinfo.cc | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/f0902543/src/kudu/gutil/sysinfo.cc
----------------------------------------------------------------------
diff --git a/src/kudu/gutil/sysinfo.cc b/src/kudu/gutil/sysinfo.cc
index 73afa27..6006b6d 100644
--- a/src/kudu/gutil/sysinfo.cc
+++ b/src/kudu/gutil/sysinfo.cc
@@ -148,7 +148,13 @@ static bool ReadIntFromFile(const char *file, int *value) {
 static int ReadMaxCPUIndex() {
   char buf[1024];
   CHECK(SlurpSmallTextFile("/sys/devices/system/cpu/present", buf, arraysize(buf)));
-  // 'buf' should contain a string like '0-7'.
+
+  // On a single-core machine, 'buf' will contain the string '0' with a newline.
+  if (strcmp(buf, "0\n") == 0) {
+    return 0;
+  }
+
+  // On multi-core, it will have a CPU range like '0-7'.
   CHECK_EQ(0, memcmp(buf, "0-", 2)) << "bad list of possible CPUs: " << buf;
 
   char* max_cpu_str = &buf[2];
@@ -216,11 +222,7 @@ static void InitializeSystemInfo() {
   const char* pname = "/proc/cpuinfo";
   int fd = open(pname, O_RDONLY);
   if (fd == -1) {
-    perror(pname);
-    if (!saw_mhz) {
-      cpuinfo_cycles_per_second = EstimateCyclesPerSecond(1000);
-    }
-    return;          // TODO: use generic tester instead?
+    PLOG(FATAL) << "Unable to read CPU info from /proc. procfs must be mounted.";
   }
 
   double bogo_clock = 1.0;


Mime
View raw message