All of lore.kernel.org
 help / color / mirror / Atom feed
From: Loic Dachary <loic@dachary.org>
To: Ceph Development <ceph-devel@vger.kernel.org>
Subject: Throttle::wait use case clarification
Date: Sun, 20 Jan 2013 14:39:48 +0100	[thread overview]
Message-ID: <50FBF3A4.4010200@dachary.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 1898 bytes --]

Hi,

While working on unit tests for Throttle.{cc,h} I tried to figure out a use case related to the Throttle::wait method but couldn't

https://github.com/ceph/ceph/pull/34/files#L3R258

Although it was not a blocker and I managed to reach 100% coverage anyway, it got me curious and I would very much appreciate pointers to understand the rationale.

wait() can be called to set a new maximum before waiting for all pending threads to get get what they asked for. Since the maximum has changed, wait() wakes up the first thread : the conditions under which it decided to go to sleep have changed and the conclusion may be different.

However, it only does so when the new maximum is less than current one. For instance

A) decision does not change

  max = 10, current 9
  thread 1 tries to get 5 but only 1 is available, it goes to sleep
  wait(8)
  max = 8, current 9
  wakes up thread 1
  thread 1 tries to get 5 but current is already beyond the maximum, it goes to sleep

B) decision changes

  max = 10, current 1
  thread 1 tries to get 10 but only 9 is available, it goes to sleep
  wait(9)
  max = 9, current 1
  wakes up thread 1
  thread 1 tries to get 10 which is above the maximum : it succeeds because current is below the new maximum

It will not wake up a thread if the maximum increases, for instance:

  max = 10, current 9
  thread 1 tries to get 5 but only 1 is available, it goes to sleep
  wait(20)
  max = 20, current 9
  does *not* wake up thread 1
  keeps waiting until another thread put(N) with N >= 0 although there now is 11 available and it would allow it to get 5 out of it

Why is it not desirable for thread 1 to wake up in this case ? When debugging a real world situation, I think it would show as a thread blocked although the throttle it is waiting on has enough to satisfy its request. What am I missing ?

Cheers


[-- Attachment #1.2: loic.vcf --]
[-- Type: text/x-vcard, Size: 342 bytes --]

begin:vcard
fn:Loic Dachary
n:Dachary;Loic
org:Artisan Logiciel Libre
adr:;;12 bd Magenta;Paris;;75010;France
email;internet:loic@dachary.org
title:Senior Developer
tel;work:+33 4 84 25 08 05
tel;home:+33 9 51 18 43 38
tel;cell:+33 6 64 03 29 07
note:Born 131414404 before EPOCH.
url:http://dachary.org/
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

             reply	other threads:[~2013-01-20 13:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-20 13:39 Loic Dachary [this message]
2013-01-20 23:02 ` Throttle::wait use case clarification Gregory Farnum
2013-01-21 13:44   ` Loic Dachary
2013-01-22 18:01     ` Gregory Farnum
2013-02-05  0:22     ` Gregory Farnum
2013-02-05  0:30       ` Loic Dachary
2013-02-05 19:10       ` Loic Dachary
2013-02-05 19:14         ` Gregory Farnum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50FBF3A4.4010200@dachary.org \
    --to=loic@dachary.org \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.