[ovs-dev,2/3] token-bucket: Add token_bucket_wait_at().
diff mbox

Message ID 1474067451-78603-3-git-send-email-jarno@ovn.org
State Accepted
Delegated to: Ben Pfaff
Headers show

Commit Message

Jarno Rajahalme Sept. 16, 2016, 11:10 p.m. UTC
Having the caller of token_bucket_wait() indicated in the log messages
makes debugging easier.

Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
---
 include/openvswitch/token-bucket.h | 5 ++++-
 lib/token-bucket.c                 | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

Comments

Ben Pfaff Sept. 20, 2016, 12:19 a.m. UTC | #1
On Fri, Sep 16, 2016 at 04:10:50PM -0700, Jarno Rajahalme wrote:
> Having the caller of token_bucket_wait() indicated in the log messages
> makes debugging easier.
> 
> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
Jarno Rajahalme Sept. 20, 2016, 6:45 p.m. UTC | #2
> On Sep 19, 2016, at 5:19 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> On Fri, Sep 16, 2016 at 04:10:50PM -0700, Jarno Rajahalme wrote:
>> Having the caller of token_bucket_wait() indicated in the log messages
>> makes debugging easier.
>> 
>> Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
> 
> Acked-by: Ben Pfaff <blp@ovn.org>

Applied to master and branch-2.6.

  Jarno

Patch
diff mbox

diff --git a/include/openvswitch/token-bucket.h b/include/openvswitch/token-bucket.h
index bbcde84..6bb6040 100644
--- a/include/openvswitch/token-bucket.h
+++ b/include/openvswitch/token-bucket.h
@@ -37,6 +37,9 @@  void token_bucket_init(struct token_bucket *,
 void token_bucket_set(struct token_bucket *,
                        unsigned int rate, unsigned int burst);
 bool token_bucket_withdraw(struct token_bucket *, unsigned int n);
-void token_bucket_wait(struct token_bucket *, unsigned int n);
+void token_bucket_wait_at(struct token_bucket *, unsigned int n,
+                          const char *where);
+#define token_bucket_wait(bucket, n)                    \
+    token_bucket_wait_at(bucket, n, OVS_SOURCE_LOCATOR)
 
 #endif /* token-bucket.h */
diff --git a/lib/token-bucket.c b/lib/token-bucket.c
index be90453..29f5165 100644
--- a/lib/token-bucket.c
+++ b/lib/token-bucket.c
@@ -85,12 +85,13 @@  token_bucket_withdraw(struct token_bucket *tb, unsigned int n)
 /* Causes the poll loop to wake up when at least 'n' tokens will be available
  * for withdrawal from 'tb'. */
 void
-token_bucket_wait(struct token_bucket *tb, unsigned int n)
+token_bucket_wait_at(struct token_bucket *tb, unsigned int n,
+                     const char *where)
 {
     if (tb->tokens >= n) {
-        poll_immediate_wake();
+        poll_immediate_wake_at(where);
     } else {
         unsigned int need = n - tb->tokens;
-        poll_timer_wait_until(tb->last_fill + need / tb->rate + 1);
+        poll_timer_wait_until_at(tb->last_fill + need / tb->rate + 1, where);
     }
 }