summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Moreira Zinsly <rzinsly@linux.vnet.ibm.com>2014-04-08 17:44:08 -0300
committerAliaksey Kandratsenka <alk@tut.by>2014-04-12 11:14:43 -0700
commit8deea9ff2a3e6eef8af64ea0727d6cb840c13769 (patch)
tree3d3c3e8953c646acc8995ccaa83200246423cd67
parent9d5e1a0aa5a6ad1c7af18b65016fa5c9b7fccb47 (diff)
downloadgperftools-8deea9ff2a3e6eef8af64ea0727d6cb840c13769.tar.gz
VDSOsupport cleanup
This patch cleans up unused VDSO getcpu racking from VDSOsupport class, since the code is not used anywhere in gperftools and symbol name is not architecture independent.
-rw-r--r--src/base/vdso_support.cc46
-rw-r--r--src/base/vdso_support.h23
2 files changed, 0 insertions, 69 deletions
diff --git a/src/base/vdso_support.cc b/src/base/vdso_support.cc
index 767ee5f..730df30 100644
--- a/src/base/vdso_support.cc
+++ b/src/base/vdso_support.cc
@@ -57,7 +57,6 @@ using base::subtle::MemoryBarrier;
namespace base {
const void *VDSOSupport::vdso_base_ = ElfMemImage::kInvalidBase;
-VDSOSupport::GetCpuFn VDSOSupport::getcpu_fn_ = &InitAndGetCPU;
VDSOSupport::VDSOSupport()
// If vdso_base_ is still set to kInvalidBase, we got here
// before VDSOSupport::Init has been called. Call it now.
@@ -81,14 +80,12 @@ const void *VDSOSupport::Init() {
// Valgrind zapping. So we check for Valgrind separately.
if (RunningOnValgrind()) {
vdso_base_ = NULL;
- getcpu_fn_ = &GetCPUViaSyscall;
return NULL;
}
int fd = open("/proc/self/auxv", O_RDONLY);
if (fd == -1) {
// Kernel too old to have a VDSO.
vdso_base_ = NULL;
- getcpu_fn_ = &GetCPUViaSyscall;
return NULL;
}
ElfW(auxv_t) aux;
@@ -106,20 +103,6 @@ const void *VDSOSupport::Init() {
vdso_base_ = NULL;
}
}
- GetCpuFn fn = &GetCPUViaSyscall; // default if VDSO not present.
- if (vdso_base_) {
- VDSOSupport vdso;
- SymbolInfo info;
- if (vdso.LookupSymbol("__vdso_getcpu", "LINUX_2.6", STT_FUNC, &info)) {
- // Casting from an int to a pointer is not legal C++. To emphasize
- // this, we use a C-style cast rather than a C++-style cast.
- fn = (GetCpuFn)(info.address);
- }
- }
- // Subtle: this code runs outside of any locks; prevent compiler
- // from assigning to getcpu_fn_ more than once.
- base::subtle::MemoryBarrier();
- getcpu_fn_ = fn;
return vdso_base_;
}
@@ -128,8 +111,6 @@ const void *VDSOSupport::SetBase(const void *base) {
const void *old_base = vdso_base_;
vdso_base_ = base;
image_.Init(base);
- // Also reset getcpu_fn_, so GetCPU could be tested with simulated VDSO.
- getcpu_fn_ = &InitAndGetCPU;
return old_base;
}
@@ -145,33 +126,6 @@ bool VDSOSupport::LookupSymbolByAddress(const void *address,
return image_.LookupSymbolByAddress(address, info_out);
}
-// NOLINT on 'long' because this routine mimics kernel api.
-long VDSOSupport::GetCPUViaSyscall(unsigned *cpu, void *, void *) { // NOLINT
-#if defined(__NR_getcpu)
- return sys_getcpu(cpu, NULL, NULL);
-#else
- // x86_64 never implemented sys_getcpu(), except as a VDSO call.
- errno = ENOSYS;
- return -1;
-#endif
-}
-
-// Use fast __vdso_getcpu if available.
-long VDSOSupport::InitAndGetCPU(unsigned *cpu, void *x, void *y) { // NOLINT
- Init();
- CHECK_NE(getcpu_fn_, &InitAndGetCPU); // << "Init() did not set getcpu_fn_";
- return (*getcpu_fn_)(cpu, x, y);
-}
-
-// This function must be very fast, and may be called from very
-// low level (e.g. tcmalloc). Hence I avoid things like
-// GoogleOnceInit() and ::operator new.
-int GetCPU(void) {
- unsigned cpu;
- int ret_code = (*VDSOSupport::getcpu_fn_)(&cpu, NULL, NULL);
- return ret_code == 0 ? cpu : ret_code;
-}
-
// We need to make sure VDSOSupport::Init() is called before
// the main() runs, since it might do something like setuid or
// chroot. If VDSOSupport
diff --git a/src/base/vdso_support.h b/src/base/vdso_support.h
index b97ab25..c1209a4 100644
--- a/src/base/vdso_support.h
+++ b/src/base/vdso_support.h
@@ -122,32 +122,9 @@ class VDSOSupport {
// page-aligned.
static const void *vdso_base_;
- // NOLINT on 'long' because these routines mimic kernel api.
- // The 'cache' parameter may be used by some versions of the kernel,
- // and should be NULL or point to a static buffer containing at
- // least two 'long's.
- static long InitAndGetCPU(unsigned *cpu, void *cache, // NOLINT 'long'.
- void *unused);
- static long GetCPUViaSyscall(unsigned *cpu, void *cache, // NOLINT 'long'.
- void *unused);
- typedef long (*GetCpuFn)(unsigned *cpu, void *cache, // NOLINT 'long'.
- void *unused);
-
- // This function pointer may point to InitAndGetCPU,
- // GetCPUViaSyscall, or __vdso_getcpu at different stages of initialization.
- static GetCpuFn getcpu_fn_;
-
- friend int GetCPU(void); // Needs access to getcpu_fn_.
-
DISALLOW_COPY_AND_ASSIGN(VDSOSupport);
};
-// Same as sched_getcpu() on later glibc versions.
-// Return current CPU, using (fast) __vdso_getcpu@LINUX_2.6 if present,
-// otherwise use syscall(SYS_getcpu,...).
-// May return -1 with errno == ENOSYS if the kernel doesn't
-// support SYS_getcpu.
-int GetCPU();
} // namespace base
#endif // HAVE_ELF_MEM_IMAGE