From: Sage Weil Date: Thu, 18 Oct 2018 16:25:26 +0000 (-0500) Subject: common: remove unused ioprio thread/wq infrastructure X-Git-Tag: v14.1.0~1103^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F24665%2Fhead;p=ceph.git common: remove unused ioprio thread/wq infrastructure This is all now obsolete, with no remaining users. Move ceph_gettid into Thread.{cc,h} Signed-off-by: Sage Weil --- diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 06b251a26e1b..39821472fa1f 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -66,7 +66,6 @@ set(common_srcs histogram.cc hobject.cc hostname.cc - io_priority.cc ipaddr.cc iso_8601.cc linux_version.c diff --git a/src/common/Thread.cc b/src/common/Thread.cc index b9e13dc93d5f..edbd7d34c874 100644 --- a/src/common/Thread.cc +++ b/src/common/Thread.cc @@ -13,17 +13,30 @@ */ #include +#include +#ifdef __linux__ +#include /* For SYS_xxx definitions */ +#endif #include "common/Thread.h" #include "common/code_environment.h" #include "common/debug.h" #include "common/signal.h" -#include "common/io_priority.h" #ifdef HAVE_SCHED #include #endif + +pid_t ceph_gettid(void) +{ +#ifdef __linux__ + return syscall(SYS_gettid); +#else + return -ENOSYS; +#endif +} + static int _set_affinity(int id) { #ifdef HAVE_SCHED @@ -45,8 +58,6 @@ static int _set_affinity(int id) Thread::Thread() : thread_id(0), pid(0), - ioprio_class(-1), - ioprio_priority(-1), cpuid(-1), thread_name(NULL) { @@ -66,13 +77,6 @@ void *Thread::entry_wrapper() int p = ceph_gettid(); // may return -ENOSYS on other platforms if (p > 0) pid = p; - if (pid && - ioprio_class >= 0 && - ioprio_priority >= 0) { - ceph_ioprio_set(IOPRIO_WHO_PROCESS, - pid, - IOPRIO_PRIO_VALUE(ioprio_class, ioprio_priority)); - } if (pid && cpuid >= 0) _set_affinity(cpuid); @@ -179,18 +183,6 @@ int Thread::detach() return pthread_detach(thread_id); } -int Thread::set_ioprio(int cls, int prio) -{ - // fixme, maybe: this can race with create() - ioprio_class = cls; - ioprio_priority = prio; - if (pid && cls >= 0 && prio >= 0) - return ceph_ioprio_set(IOPRIO_WHO_PROCESS, - pid, - IOPRIO_PRIO_VALUE(cls, prio)); - return 0; -} - int Thread::set_affinity(int id) { int r = 0; diff --git a/src/common/Thread.h b/src/common/Thread.h index 8e7cadd14c3b..bc32755c30e8 100644 --- a/src/common/Thread.h +++ b/src/common/Thread.h @@ -24,11 +24,12 @@ #include "include/compat.h" +extern pid_t ceph_gettid(); + class Thread { private: pthread_t thread_id; pid_t pid; - int ioprio_class, ioprio_priority; int cpuid; const char *thread_name; @@ -57,7 +58,6 @@ class Thread { void create(const char *name, size_t stacksize = 0); int join(void **prval = 0); int detach(); - int set_ioprio(int cls, int prio); int set_affinity(int cpuid); }; diff --git a/src/common/WorkQueue.cc b/src/common/WorkQueue.cc index 094d4e411de5..0c64af848fc2 100644 --- a/src/common/WorkQueue.cc +++ b/src/common/WorkQueue.cc @@ -28,8 +28,6 @@ ThreadPool::ThreadPool(CephContext *cct_, string nm, string tn, int n, const cha _stop(false), _pause(0), _draining(0), - ioprio_class(-1), - ioprio_priority(-1), _num_threads(n), processing(0) { @@ -158,11 +156,6 @@ void ThreadPool::start_threads() _threads.insert(wt); wt->create(thread_name.c_str()); - - int r = wt->set_ioprio(ioprio_class, ioprio_priority); - if (r < 0) - lderr(cct) << " set_ioprio got " << cpp_strerror(r) << dendl; - } } @@ -261,24 +254,6 @@ void ThreadPool::drain(WorkQueue_* wq) _lock.unlock(); } -void ThreadPool::set_ioprio(int cls, int priority) -{ - std::lock_guard l(_lock); - ioprio_class = cls; - ioprio_priority = priority; - for (set::iterator p = _threads.begin(); - p != _threads.end(); - ++p) { - ldout(cct,10) << __func__ - << " class " << cls << " priority " << priority - << " pid " << (*p)->get_pid() - << dendl; - int r = (*p)->set_ioprio(cls, priority); - if (r < 0) - lderr(cct) << " set_ioprio got " << cpp_strerror(r) << dendl; - } -} - ShardedThreadPool::ShardedThreadPool(CephContext *pcct_, string nm, string tn, uint32_t pnum_threads): cct(pcct_), diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index c30e493be034..66696d01a8f0 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -36,7 +36,6 @@ class ThreadPool : public md_config_obs_t { int _pause; int _draining; Cond _wait_cond; - int ioprio_class, ioprio_priority; public: class TPHandle { @@ -528,9 +527,6 @@ public: * If it is not NULL, blocks until the given work queue does not have * any items left to process. */ void drain(WorkQueue_* wq = 0); - - /// set io priority - void set_ioprio(int cls, int priority); }; class GenContextWQ : diff --git a/src/common/io_priority.cc b/src/common/io_priority.cc deleted file mode 100644 index 3e9712508c99..000000000000 --- a/src/common/io_priority.cc +++ /dev/null @@ -1,56 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2012 Red Hat - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#include -#if defined(__FreeBSD__) || defined(__APPLE__) -#include -#endif -#ifdef __linux__ -#include /* For SYS_xxx definitions */ -#endif -#include - -#include "io_priority.h" - -pid_t ceph_gettid(void) -{ -#ifdef __linux__ - return syscall(SYS_gettid); -#else - return -ENOSYS; -#endif -} - -int ceph_ioprio_set(int whence, int who, int ioprio) -{ -#ifdef __linux__ - return syscall(SYS_ioprio_set, whence, who, ioprio); -#else - return -ENOSYS; -#endif -} - -int ceph_ioprio_string_to_class(const std::string& s) -{ - std::string l = s; - std::transform(l.begin(), l.end(), l.begin(), ::tolower); - - if (l == "idle") - return IOPRIO_CLASS_IDLE; - if (l == "be" || l == "besteffort" || l == "best effort") - return IOPRIO_CLASS_BE; - if (l == "rt" || l == "realtime" || l == "real time") - return IOPRIO_CLASS_RT; - return -EINVAL; -} diff --git a/src/common/io_priority.h b/src/common/io_priority.h deleted file mode 100644 index 91ebf42fb2a2..000000000000 --- a/src/common/io_priority.h +++ /dev/null @@ -1,44 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2012 Red Hat - * - * This is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software - * Foundation. See file COPYING. - * - */ - -#ifndef CEPH_COMMON_IO_PRIORITY_H -#define CEPH_COMMON_IO_PRIORITY_H - -#include - -extern pid_t ceph_gettid(); - -#ifndef IOPRIO_WHO_PROCESS -# define IOPRIO_WHO_PROCESS 1 -#endif -#ifndef IOPRIO_PRIO_VALUE -# define IOPRIO_CLASS_SHIFT 13 -# define IOPRIO_PRIO_VALUE(class, data) \ - (((class) << IOPRIO_CLASS_SHIFT) | (data)) -#endif -#ifndef IOPRIO_CLASS_RT -# define IOPRIO_CLASS_RT 1 -#endif -#ifndef IOPRIO_CLASS_BE -# define IOPRIO_CLASS_BE 2 -#endif -#ifndef IOPRIO_CLASS_IDLE -# define IOPRIO_CLASS_IDLE 3 -#endif - -extern int ceph_ioprio_set(int whence, int who, int ioprio); - -extern int ceph_ioprio_string_to_class(const std::string& s); - -#endif diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index 609e63465b21..bc9a89396141 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -39,7 +39,6 @@ add_library(crimson-common STATIC ${PROJECT_SOURCE_DIR}/src/common/hobject.cc ${PROJECT_SOURCE_DIR}/src/common/hostname.cc ${PROJECT_SOURCE_DIR}/src/common/ipaddr.cc - ${PROJECT_SOURCE_DIR}/src/common/io_priority.cc ${PROJECT_SOURCE_DIR}/src/common/lockdep.cc ${PROJECT_SOURCE_DIR}/src/common/mutex_debug.cc ${PROJECT_SOURCE_DIR}/src/common/mempool.cc diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 19b91f7a6d19..104e94046212 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -38,7 +38,6 @@ #include "common/errno.h" #include "common/debug.h" #include "common/perf_counters.h" -#include "common/io_priority.h" #include "NVMEDevice.h" diff --git a/src/test/common/CMakeLists.txt b/src/test/common/CMakeLists.txt index 21a54aeb677a..df314be94895 100644 --- a/src/test/common/CMakeLists.txt +++ b/src/test/common/CMakeLists.txt @@ -133,13 +133,6 @@ add_executable(unittest_lru add_ceph_unittest(unittest_lru) target_link_libraries(unittest_lru ceph-common) -# unittest_io_priority -add_executable(unittest_io_priority - test_io_priority.cc - ) -add_ceph_unittest(unittest_io_priority) -target_link_libraries(unittest_io_priority ceph-common) - # unittest_crc32c add_executable(unittest_crc32c test_crc32c.cc diff --git a/src/test/common/test_io_priority.cc b/src/test/common/test_io_priority.cc deleted file mode 100644 index b2d4e2601164..000000000000 --- a/src/test/common/test_io_priority.cc +++ /dev/null @@ -1,51 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab -/* - * Ceph - scalable distributed file system - * - * Copyright (C) 2014 Red Hat - * - * Author: Loic Dachary - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - */ - -#include -#include - -#include "common/io_priority.h" - -TEST(io_priority, ceph_ioprio_string_to_class) { - ASSERT_EQ(IOPRIO_CLASS_IDLE, ceph_ioprio_string_to_class("idle")); - ASSERT_EQ(IOPRIO_CLASS_IDLE, ceph_ioprio_string_to_class("IDLE")); - - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("be")); - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("BE")); - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("besteffort")); - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("BESTEFFORT")); - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("best effort")); - ASSERT_EQ(IOPRIO_CLASS_BE, ceph_ioprio_string_to_class("BEST EFFORT")); - - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("rt")); - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("RT")); - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("realtime")); - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("REALTIME")); - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("real time")); - ASSERT_EQ(IOPRIO_CLASS_RT, ceph_ioprio_string_to_class("REAL TIME")); - - ASSERT_EQ(-EINVAL, ceph_ioprio_string_to_class("invalid")); -} - -/* - * Local Variables: - * compile-command: "cd ../.. ; - * make -j4 unittest_io_priority && - * libtool --mode=execute valgrind --tool=memcheck --leak-check=full \ - * ./unittest_io_priority - * " - * End: - */