src/os/linux/vm/os_linux.cpp

changeset 8940
eb9e617d6f64
parent 8619
3a38e441474d
child 8942
9187473df31d
     1.1 --- a/src/os/linux/vm/os_linux.cpp	Wed Jan 25 09:56:19 2017 -0800
     1.2 +++ b/src/os/linux/vm/os_linux.cpp	Tue Jan 31 16:31:09 2017 +0300
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -104,14 +104,6 @@
    1.11  
    1.12  PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
    1.13  
    1.14 -#ifndef _GNU_SOURCE
    1.15 -  #define _GNU_SOURCE
    1.16 -  #include <sched.h>
    1.17 -  #undef _GNU_SOURCE
    1.18 -#else
    1.19 -  #include <sched.h>
    1.20 -#endif
    1.21 -
    1.22  // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling
    1.23  // getrusage() is prepared to handle the associated failure.
    1.24  #ifndef RUSAGE_THREAD
    1.25 @@ -5024,42 +5016,12 @@
    1.26    }
    1.27  };
    1.28  
    1.29 -static int os_cpu_count(const cpu_set_t* cpus) {
    1.30 -  int count = 0;
    1.31 -  // only look up to the number of configured processors
    1.32 -  for (int i = 0; i < os::processor_count(); i++) {
    1.33 -    if (CPU_ISSET(i, cpus)) {
    1.34 -      count++;
    1.35 -    }
    1.36 -  }
    1.37 -  return count;
    1.38 -}
    1.39 -
    1.40 -// Get the current number of available processors for this process.
    1.41 -// This value can change at any time during a process's lifetime.
    1.42 -// sched_getaffinity gives an accurate answer as it accounts for cpusets.
    1.43 -// If anything goes wrong we fallback to returning the number of online
    1.44 -// processors - which can be greater than the number available to the process.
    1.45  int os::active_processor_count() {
    1.46 -  cpu_set_t cpus;  // can represent at most 1024 (CPU_SETSIZE) processors
    1.47 -  int cpus_size = sizeof(cpu_set_t);
    1.48 -  int cpu_count = 0;
    1.49 -
    1.50 -  // pid 0 means the current thread - which we have to assume represents the process
    1.51 -  if (sched_getaffinity(0, cpus_size, &cpus) == 0) {
    1.52 -    cpu_count = os_cpu_count(&cpus);
    1.53 -    if (PrintActiveCpus) {
    1.54 -      tty->print_cr("active_processor_count: sched_getaffinity processor count: %d", cpu_count);
    1.55 -    }
    1.56 -  }
    1.57 -  else {
    1.58 -    cpu_count = ::sysconf(_SC_NPROCESSORS_ONLN);
    1.59 -    warning("sched_getaffinity failed (%s)- using online processor count (%d) "
    1.60 -            "which may exceed available processors", strerror(errno), cpu_count);
    1.61 -  }
    1.62 -
    1.63 -  assert(cpu_count > 0 && cpu_count <= processor_count(), "sanity check");
    1.64 -  return cpu_count;
    1.65 +  // Linux doesn't yet have a (official) notion of processor sets,
    1.66 +  // so just return the number of online processors.
    1.67 +  int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
    1.68 +  assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
    1.69 +  return online_cpus;
    1.70  }
    1.71  
    1.72  void os::set_native_thread_name(const char *name) {

mercurial