linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Shaohua Li <shli@kernel.org>
Cc: "Matias Bjørling" <m@bjorling.me>,
	"Sam Bradshaw (sbradshaw)" <sbradshaw@micron.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] block: per-cpu counters for in-flight IO accounting
Date: Wed, 04 Jun 2014 20:42:59 -0600	[thread overview]
Message-ID: <538FD933.5000202@kernel.dk> (raw)
In-Reply-To: <20140605023334.GB22826@kernel.org>

On 2014-06-04 20:33, Shaohua Li wrote:
> On Wed, Jun 04, 2014 at 08:16:32PM -0600, Jens Axboe wrote:
>> On 2014-06-04 20:09, Shaohua Li wrote:
>>> On Wed, Jun 04, 2014 at 02:08:46PM -0600, Jens Axboe wrote:
>>>> On 06/04/2014 05:29 AM, Matias Bjørling wrote:
>>>>> It's in
>>>>>
>>>>> blk_io_account_start
>>>>>    part_round_stats
>>>>>      part_round_state_single
>>>>>        part_in_flight
>>>>>
>>>>> I like the granularity idea.
>>>>
>>>> And similarly from blk_io_account_done() - which makes it even worse,
>>>> since it at both ends of the IO chain.
>>>
>>> But part_round_state_single is supposed to only call part_in_flight every
>>> jiffery. Maybe we need something below:
>>> 1. set part->stamp immediately
>>> 2. fixed granularity
>>> Untested though.
>>>
>>>
>>> diff --git a/block/blk-core.c b/block/blk-core.c
>>> index 40d6548..5f0acaa 100644
>>> --- a/block/blk-core.c
>>> +++ b/block/blk-core.c
>>> @@ -1270,17 +1270,19 @@ static void part_round_stats_single(int cpu, struct hd_struct *part,
>>>   				    unsigned long now)
>>>   {
>>>   	int inflight;
>>> +	unsigned long old_stamp;
>>>
>>> -	if (now == part->stamp)
>>> +	if (time_before(now, part->stamp + msecs_to_jiffies(10)))
>>>   		return;
>>> +	old_stamp = part->stamp;
>>> +	part->stamp = now;
>>>
>>>   	inflight = part_in_flight(part);
>>>   	if (inflight) {
>>>   		__part_stat_add(cpu, part, time_in_queue,
>>> -				inflight * (now - part->stamp));
>>> -		__part_stat_add(cpu, part, io_ticks, (now - part->stamp));
>>> +				inflight * (now - old_stamp));
>>> +		__part_stat_add(cpu, part, io_ticks, (now - old_stamp));
>>>   	}
>>> -	part->stamp = now;
>>>   }
>>>
>>>   /**
>>
>> It'd be a good improvement, and one we should be able to do without
>> screwing anything up. It'd be identical to anyone running at HZ==100
>> right now.
>>
>> So the above we can easily do, and arguably should just do. We wont
>> see real scaling in the IO stats path before we fixup the hd_struct
>> referencing as well, however.
>
> That's true. maybe a percpu_ref works here.

Maybe, but it would require more than a direct replacement. The 
hd_struct stuff currently relies on things like atomic_inc_not_zero(), 
which would not be cheap to do. And this does happen for every new IO, 
so can't be amortized over time like the part stats rounding.

-- 
Jens Axboe


  reply	other threads:[~2014-06-05  2:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-09  9:17 [PATCH] block: small performance optimization Matias Bjørling
2014-05-09  9:17 ` [PATCH] block: per-cpu counters for in-flight IO accounting Matias Bjørling
2014-05-09 14:12   ` Jens Axboe
2014-05-09 16:41     ` Jens Axboe
2014-05-30 12:11       ` Shaohua Li
2014-05-30 13:49         ` Jens Axboe
2014-06-04 10:39           ` Shaohua Li
2014-06-04 11:29             ` Matias Bjørling
2014-06-04 20:08               ` Jens Axboe
2014-06-05  2:09                 ` Shaohua Li
2014-06-05  2:16                   ` Jens Axboe
2014-06-05  2:33                     ` Shaohua Li
2014-06-05  2:42                       ` Jens Axboe [this message]
2014-06-04 14:29             ` Jens Axboe

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=538FD933.5000202@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m@bjorling.me \
    --cc=sbradshaw@micron.com \
    --cc=shli@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;
as well as URLs for NNTP newsgroup(s).