public inbox for linux-bcache@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Ferdinand <bcache@mfedv.net>
To: linux-bcache@vger.kernel.org
Subject: meaning of /sys/fs/bcache/<cset-uuid>/congested ?
Date: Mon, 23 Dec 2013 01:07:14 +0100	[thread overview]
Message-ID: <20131223000714.GV16285@teapot> (raw)

Hi,

while watching bcache sysfs values, I noticed that sometimes the
    /sys/fs/bcache/<cset-uuid>/congested
shows non-zero, indicating that my SSD cannot cope with all the
writes.

I tried to understand what this value means (not mentioned in
Documentation/bcache.txt).

Using kernel 3.13-rc3.

In sysfs.c:
    510         sysfs_hprint(congested,
    511                      ((uint64_t) bch_get_congested(c)) << 9);

In request.c:
    464 /* Congested? */
    465 
    466 unsigned bch_get_congested(struct cache_set *c)
    467 {
    468         int i;
    469         long rand;
    470 
    471         if (!c->congested_read_threshold_us &&
    472             !c->congested_write_threshold_us)
    473                 return 0;
    474 
    475         i = (local_clock_us() - c->congested_last_us) / 1024;
    476         if (i < 0)
    477                 return 0;
    478 
    479         i += atomic_read(&c->congested);
    480         if (i >= 0)
    481                 return 0;
    482 
    483         i += CONGESTED_MAX;
    484 
    485         if (i > 0)
    486                 i = fract_exp_two(i, 6);
    487 
    488         rand = get_random_int();
    489         i -= bitmap_weight(&rand, BITS_PER_LONG);
    490 
    491         return i > 0 ? i : 1;
    492 }

Apparently c->congested_last_us is a value in microseconds, i and
c->congested are values in (approx.) milliseconds.

But after line 485 I am completely lost :-)

Line 485 is something like 
    i = int (2 ** (i/64.0));

And then in line 489 a random number <= 64 (or <= 32 on 32 bit) is
subtracted. 

What does it mean? What unit is "congested" in?

Regards
Matthias

                 reply	other threads:[~2013-12-23  0:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20131223000714.GV16285@teapot \
    --to=bcache@mfedv.net \
    --cc=linux-bcache@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox