[RFC PATCH 5/6] common/Throttle: make get() report number of waiters on entry/exit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use get() arguments rather than an accessor function to minimize confusion
from inconsistent reporting caused by racing on the Throttle mutex.

Signed-off-by: Jim Schutt <jaschut@xxxxxxxxxx>
---
 src/common/Throttle.h      |    7 ++++++-
 src/msg/SimpleMessenger.cc |    5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/common/Throttle.h b/src/common/Throttle.h
index 2f74f4a..dd74730 100644
--- a/src/common/Throttle.h
+++ b/src/common/Throttle.h
@@ -86,12 +86,15 @@ public:
   }
 
   void get(int64_t c = 1, int64_t m = 0,
-	   uint64_t *sleep_seq = NULL, uint64_t *wake_seq = NULL) {
+	   uint64_t *sleep_seq = NULL, uint64_t *wake_seq = NULL,
+	   int *sleep_waiters = NULL, int *wake_waiters = NULL) {
     assert(c >= 0);
     Mutex::Locker l(lock);
     sseq++;
     if (sleep_seq)
       *sleep_seq = sseq;
+    if (sleep_waiters)
+      *sleep_waiters = cond.size();
     if (m) {
       assert(m > 0);
       max = m;
@@ -101,6 +104,8 @@ public:
     wseq++;
     if (wake_seq)
       *wake_seq = wseq;
+    if (wake_waiters)
+      *wake_waiters = cond.size();
   }
 
   /* Returns true if it successfully got the requested amount,
diff --git a/src/msg/SimpleMessenger.cc b/src/msg/SimpleMessenger.cc
index 259d3b7..3167749 100644
--- a/src/msg/SimpleMessenger.cc
+++ b/src/msg/SimpleMessenger.cc
@@ -1899,10 +1899,11 @@ int SimpleMessenger::Pipe::read_message(Message **pm)
 	       << policy.throttler->get_current() << "/"
 	       << policy.throttler->get_max() << dendl;
       uint64_t sseq, wseq;
-      policy.throttler->get(message_size, 0, &sseq, &wseq);
+      int swait, wwait;
+      policy.throttler->get(message_size, 0, &sseq, &wseq, &swait, &wwait);
       ldout(msgr->cct,10) << "reader got " << message_size << " from policy throttler "
 	     <<  policy.throttler->get_current() << "/" << policy.throttler->get_max()
-	     << " " << sseq << "/" << wseq << dendl;
+	     << " seq " << sseq << "/" << wseq  << " waiters " << swait << "/" << wwait << dendl;
     }
 
     // throttle total bytes waiting for dispatch.  do this _after_ the
-- 
1.7.1


--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [CEPH Users]     [Ceph Large]     [Information on CEPH]     [Linux BTRFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux