mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
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 <sage@redhat.com>
This commit is contained in:
parent
86af98f42d
commit
39304caf95
@ -66,7 +66,6 @@ set(common_srcs
|
||||
histogram.cc
|
||||
hobject.cc
|
||||
hostname.cc
|
||||
io_priority.cc
|
||||
ipaddr.cc
|
||||
iso_8601.cc
|
||||
linux_version.c
|
||||
|
@ -13,17 +13,30 @@
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __linux__
|
||||
#include <sys/syscall.h> /* 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 <sched.h>
|
||||
#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;
|
||||
|
@ -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);
|
||||
};
|
||||
|
||||
|
@ -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<Mutex> l(_lock);
|
||||
ioprio_class = cls;
|
||||
ioprio_priority = priority;
|
||||
for (set<WorkThread*>::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_),
|
||||
|
@ -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 :
|
||||
|
@ -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 <unistd.h>
|
||||
#if defined(__FreeBSD__) || defined(__APPLE__)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
#include <sys/syscall.h> /* For SYS_xxx definitions */
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
#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;
|
||||
}
|
@ -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 <string>
|
||||
|
||||
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
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 <contact@redhat.com>
|
||||
*
|
||||
* Author: Loic Dachary <loic@dachary.org>
|
||||
*
|
||||
* 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 <errno.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#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:
|
||||
*/
|
Loading…
Reference in New Issue
Block a user