]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: make osd_memory_limit default to .8x the cgroup limit
authorSage Weil <sage@redhat.com>
Fri, 8 Mar 2019 19:16:19 +0000 (13:16 -0600)
committerSage Weil <sage@redhat.com>
Mon, 11 Mar 2019 17:33:49 +0000 (12:33 -0500)
We do this at runtime in _set_cache_sizes so that changes to these values
at runtime will be picked up.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/options.cc
src/os/bluestore/BlueStore.cc

index 93970645f4df962db90fe1b0d6c14312da54af5e..44a83e60ea5394458036794b5d77be8ebd2158e5 100644 (file)
@@ -4013,6 +4013,13 @@ std::vector<Option> get_global_options() {
     .add_see_also("bluestore_cache_autotune")
     .set_description("When tcmalloc and cache autotuning is enabled, try to keep this many bytes mapped in memory."),
 
+    Option("osd_memory_target_cgroup_limit_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
+    .set_default(0.8)
+    .set_min_max(0.0, 1.0)
+    .add_see_also("osd_memory_target")
+    .set_description("Set the default value for osd_memory_target to the cgroup memory limit (if set) times this value")
+    .set_long_description("A value of 0 disables this feature."),
+
     Option("osd_memory_base", Option::TYPE_SIZE, Option::LEVEL_DEV)
     .set_default(768_M)
     .add_see_also("bluestore_cache_autotune")
index 3d1c728c73706df19b91371f48ecbc8a6ed5e889..b2b203ae1c545f00189cda0942f85a0a000fa839 100644 (file)
@@ -26,6 +26,7 @@
 #include "include/intarith.h"
 #include "include/stringify.h"
 #include "include/str_map.h"
+#include "include/util.h"
 #include "common/errno.h"
 #include "common/safe_io.h"
 #include "common/PriorityCache.h"
@@ -4029,6 +4030,7 @@ const char **BlueStore::get_tracked_conf_keys() const
     "bluestore_max_blob_size_ssd",
     "bluestore_max_blob_size_hdd",
     "osd_memory_target",
+    "osd_memory_target_cgroup_limit_ratio",
     "osd_memory_base",
     "osd_memory_cache_min",
     "bluestore_cache_autotune",
@@ -4200,6 +4202,23 @@ void BlueStore::_set_blob_size()
 
 int BlueStore::_set_cache_sizes()
 {
+  // set osd_memory_target *default* based on cgroup limit?
+  // (do this before we fetch the osd_memory_target value!)
+  double cgroup_ratio = cct->_conf.get_val<double>(
+    "osd_memory_target_cgroup_limit_ratio");
+  if (cgroup_ratio > 0.0) {
+    uint64_t cgroup_limit = 0;
+    if (get_cgroup_memory_limit(&cgroup_limit) == 0 &&
+       cgroup_limit) {
+      uint64_t def = cgroup_limit * cgroup_ratio;
+      dout(10) << __func__ << " osd_memory_target_cgroup_limit_ratio "
+              << cgroup_ratio << ", cgroup_limit " << cgroup_limit
+              << ", defaulting osd_memory_target to " << def
+              << dendl;
+      cct->_conf.set_val_default("osd_memory_target", stringify(def));
+    }
+  }
+
   ceph_assert(bdev);
   cache_autotune = cct->_conf.get_val<bool>("bluestore_cache_autotune");
   cache_autotune_interval =