]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make promote_probability_millis atomic_t 7465/head
authorSage Weil <sage@redhat.com>
Thu, 10 Mar 2016 22:00:53 +0000 (17:00 -0500)
committerSage Weil <sage@redhat.com>
Thu, 10 Mar 2016 22:00:53 +0000 (17:00 -0500)
This is almost always read, so it should be cheap.

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index 9c7c636f31d9717f1055e8a54235de71bbc0a889..d73bee9da8792769fb4c751c2ff01451919ffe99 100644 (file)
@@ -604,7 +604,7 @@ void OSDService::promote_throttle_recalibrate()
   utime_t now = ceph_clock_now(NULL);
   double dur = now - last_recalibrate;
   last_recalibrate = now;
-  unsigned prob = promote_probability_millis;
+  unsigned prob = promote_probability_millis.read();
 
   uint64_t target_obj_sec = g_conf->osd_tier_promote_max_objects_sec;
   uint64_t target_bytes_sec = g_conf->osd_tier_promote_max_bytes_sec;
@@ -660,9 +660,9 @@ void OSDService::promote_throttle_recalibrate()
   dout(10) << __func__ << "  actual " << actual
           << ", actual/prob ratio " << ratio
           << ", adjusted new_prob " << new_prob
-          << ", prob " << promote_probability_millis << " -> " << prob
+          << ", prob " << promote_probability_millis.read() << " -> " << prob
           << dendl;
-  promote_probability_millis = prob;
+  promote_probability_millis.set(prob);
 
   // set hard limits for this interval to mitigate stampedes
   promote_max_objects = target_obj_sec * OSD::OSD_TICK_INTERVAL * 2;
index cf6370aeaca60cec1a58a1552790c435d76de7a4..ea2552ed533f7d67b1066ee834a5d981c424fb2b 100644 (file)
@@ -782,7 +782,7 @@ public:
   }
 
   /// throttle promotion attempts
-  unsigned promote_probability_millis; ///< probability thousands. one word.
+  atomic_t promote_probability_millis; ///< probability thousands. one word.
   PromoteCounter promote_counter;
   utime_t last_recalibrate;
   unsigned long promote_max_objects, promote_max_bytes;
@@ -790,7 +790,7 @@ public:
   bool promote_throttle() {
     // NOTE: lockless!  we rely on the probability being a single word.
     promote_counter.attempt();
-    if ((unsigned)rand() % 1000 > promote_probability_millis)
+    if ((unsigned)rand() % 1000 > promote_probability_millis.read())
       return true;  // yes throttle (no promote)
     if (promote_max_objects &&
        promote_counter.objects.read() > promote_max_objects)