From: Mike Snitzer <snitzer@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Christoph Hellwig <hch@infradead.org>,
dm-devel@redhat.com, Mikulas Patocka <mpatocka@redhat.com>,
"Alasdair G. Kergon" <agk@redhat.com>
Subject: Re: [PATCH 2/3] block: switch to per-cpu in-flight counters
Date: Fri, 30 Nov 2018 17:04:23 -0500 [thread overview]
Message-ID: <20181130220423.GC15049@redhat.com> (raw)
In-Reply-To: <2a7c33ef-0bd0-d901-6a11-cffca1751b9e@kernel.dk>
On Fri, Nov 30 2018 at 4:52pm -0500,
Jens Axboe <axboe@kernel.dk> wrote:
> On 11/30/18 2:44 PM, Mike Snitzer wrote:
> > On Tue, Nov 27 2018 at 7:42pm -0500,
> > Mikulas Patocka <mpatocka@redhat.com> wrote:
> >
> >> Now when part_round_stats is gone, we can switch to per-cpu in-flight
> >> counters.
> >>
> >> We use the local-atomic type local_t, so that if part_inc_in_flight or
> >> part_dec_in_flight is reentrantly called from an interrupt, the value will
> >> be correct.
> >>
> >> The other counters could be corrupted due to reentrant interrupt, but the
> >> corruption only results in slight counter skew - the in_flight counter
> >> must be exact, so it needs local_t.
> >>
> >> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> >>
> >> ---
> >> block/bio.c | 4 ++--
> >> block/blk-core.c | 4 ++--
> >> block/blk-merge.c | 2 +-
> >> block/genhd.c | 47 +++++++++++++++++++++++++++++++++++------------
> >> drivers/md/dm.c | 4 +---
> >> include/linux/genhd.h | 7 ++++---
> >> 6 files changed, 45 insertions(+), 23 deletions(-)
> >>
> >> Index: linux-block/block/genhd.c
> >> ===================================================================
> >> --- linux-block.orig/block/genhd.c 2018-11-28 00:09:59.000000000 +0100
> >> +++ linux-block/block/genhd.c 2018-11-28 00:09:59.000000000 +0100
> >> @@ -45,53 +45,76 @@ static void disk_add_events(struct gendi
> >> static void disk_del_events(struct gendisk *disk);
> >> static void disk_release_events(struct gendisk *disk);
> >>
> >> -void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
> >> +void part_inc_in_flight(struct request_queue *q, int cpu, struct hd_struct *part, int rw)
> >> {
> >> if (queue_is_mq(q))
> >> return;
> >>
> >> - atomic_inc(&part->in_flight[rw]);
> >> + local_inc(per_cpu_ptr(part->dkstats, cpu)->in_flight);
> >> if (part->partno)
> >> - atomic_inc(&part_to_disk(part)->part0.in_flight[rw]);
> >> + local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
> >> }
> >>
> >> -void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
> >> +void part_dec_in_flight(struct request_queue *q, int cpu, struct hd_struct *part, int rw)
> >> {
> >> if (queue_is_mq(q))
> >> return;
> >>
> >> - atomic_dec(&part->in_flight[rw]);
> >> + local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
> >> if (part->partno)
> >> - atomic_dec(&part_to_disk(part)->part0.in_flight[rw]);
> >> + local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
> >> }
> >
> >
> > The above is wrong, needs this incremental fix:
>
> Should also be using this_cpu_inc/dec instead.
How so? Mikulas is using local_t (original header speaks to why)
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Mikulas Patocka <mpatocka@redhat.com>,
dm-devel@redhat.com, linux-block@vger.kernel.org,
"Alasdair G. Kergon" <agk@redhat.com>,
Christoph Hellwig <hch@infradead.org>
Subject: Re: [PATCH 2/3] block: switch to per-cpu in-flight counters
Date: Fri, 30 Nov 2018 17:04:23 -0500 [thread overview]
Message-ID: <20181130220423.GC15049@redhat.com> (raw)
In-Reply-To: <2a7c33ef-0bd0-d901-6a11-cffca1751b9e@kernel.dk>
On Fri, Nov 30 2018 at 4:52pm -0500,
Jens Axboe <axboe@kernel.dk> wrote:
> On 11/30/18 2:44 PM, Mike Snitzer wrote:
> > On Tue, Nov 27 2018 at 7:42pm -0500,
> > Mikulas Patocka <mpatocka@redhat.com> wrote:
> >
> >> Now when part_round_stats is gone, we can switch to per-cpu in-flight
> >> counters.
> >>
> >> We use the local-atomic type local_t, so that if part_inc_in_flight or
> >> part_dec_in_flight is reentrantly called from an interrupt, the value will
> >> be correct.
> >>
> >> The other counters could be corrupted due to reentrant interrupt, but the
> >> corruption only results in slight counter skew - the in_flight counter
> >> must be exact, so it needs local_t.
> >>
> >> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> >>
> >> ---
> >> block/bio.c | 4 ++--
> >> block/blk-core.c | 4 ++--
> >> block/blk-merge.c | 2 +-
> >> block/genhd.c | 47 +++++++++++++++++++++++++++++++++++------------
> >> drivers/md/dm.c | 4 +---
> >> include/linux/genhd.h | 7 ++++---
> >> 6 files changed, 45 insertions(+), 23 deletions(-)
> >>
> >> Index: linux-block/block/genhd.c
> >> ===================================================================
> >> --- linux-block.orig/block/genhd.c 2018-11-28 00:09:59.000000000 +0100
> >> +++ linux-block/block/genhd.c 2018-11-28 00:09:59.000000000 +0100
> >> @@ -45,53 +45,76 @@ static void disk_add_events(struct gendi
> >> static void disk_del_events(struct gendisk *disk);
> >> static void disk_release_events(struct gendisk *disk);
> >>
> >> -void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
> >> +void part_inc_in_flight(struct request_queue *q, int cpu, struct hd_struct *part, int rw)
> >> {
> >> if (queue_is_mq(q))
> >> return;
> >>
> >> - atomic_inc(&part->in_flight[rw]);
> >> + local_inc(per_cpu_ptr(part->dkstats, cpu)->in_flight);
> >> if (part->partno)
> >> - atomic_inc(&part_to_disk(part)->part0.in_flight[rw]);
> >> + local_inc(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
> >> }
> >>
> >> -void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw)
> >> +void part_dec_in_flight(struct request_queue *q, int cpu, struct hd_struct *part, int rw)
> >> {
> >> if (queue_is_mq(q))
> >> return;
> >>
> >> - atomic_dec(&part->in_flight[rw]);
> >> + local_dec(per_cpu_ptr(part->dkstats, cpu)->in_flight);
> >> if (part->partno)
> >> - atomic_dec(&part_to_disk(part)->part0.in_flight[rw]);
> >> + local_dec(per_cpu_ptr(part_to_disk(part)->part0.dkstats, cpu)->in_flight);
> >> }
> >
> >
> > The above is wrong, needs this incremental fix:
>
> Should also be using this_cpu_inc/dec instead.
How so? Mikulas is using local_t (original header speaks to why)
next prev parent reply other threads:[~2018-11-30 22:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-28 0:42 [PATCH 2/3] block: switch to per-cpu in-flight counters Mikulas Patocka
2018-11-28 0:42 ` Mikulas Patocka
2018-11-29 21:57 ` Mike Snitzer
2018-11-29 21:57 ` Mike Snitzer
2018-11-29 22:05 ` Mikulas Patocka
2018-11-29 22:05 ` Mikulas Patocka
2018-11-29 22:22 ` Jens Axboe
2018-11-29 22:22 ` Jens Axboe
2018-11-30 0:21 ` Mike Snitzer
2018-11-30 0:21 ` Mike Snitzer
2018-11-30 21:44 ` Mike Snitzer
2018-11-30 21:44 ` Mike Snitzer
2018-11-30 21:52 ` Jens Axboe
2018-11-30 21:52 ` Jens Axboe
2018-11-30 22:04 ` Mike Snitzer [this message]
2018-11-30 22:04 ` Mike Snitzer
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=20181130220423.GC15049@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=hch@infradead.org \
--cc=linux-block@vger.kernel.org \
--cc=mpatocka@redhat.com \
/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.