From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Julien Grall <julien.grall@arm.com>
Cc: Jan Beulich <JBeulich@suse.com>, Jens Axboe <axboe@kernel.dk>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
<linux-kernel@vger.kernel.org>, <linux-block@vger.kernel.org>,
xen-devel <xen-devel@lists.xenproject.org>,
zhong jiang <zhongjiang@huawei.com>
Subject: Re: [Xen-devel] [PATCH] drivers/block/xen-blkback/common.h: use DIV_ROUND_UP instead of reimplementing its function
Date: Wed, 12 Sep 2018 12:29:08 +0200 [thread overview]
Message-ID: <20180912102908.4ls7vts55n2zfkdz@mac.bytemobile.com> (raw)
In-Reply-To: <364bad2c-708e-6406-7b52-7bfef9d5dbe1@arm.com>
On Wed, Sep 12, 2018 at 10:48:42AM +0100, Julien Grall wrote:
> Hi,
>
> On 09/12/2018 10:16 AM, Roger Pau Monné wrote:
> > On Wed, Sep 12, 2018 at 11:13:50AM +0200, Roger Pau Monné wrote:
> > > Adding Julien how did the work to support XEN_PAGE_SIZE != PAGE_SIZE.
> > >
> > > On Wed, Sep 12, 2018 at 02:14:26AM -0600, Jan Beulich wrote:
> > > > > > > On 12.09.18 at 07:45, <zhongjiang@huawei.com> wrote:
> > > > > --- a/drivers/block/xen-blkback/common.h
> > > > > +++ b/drivers/block/xen-blkback/common.h
> > > > > @@ -65,7 +65,7 @@
> > > > > (XEN_PAGES_PER_INDIRECT_FRAME / XEN_PAGES_PER_SEGMENT)
> > > > > #define MAX_INDIRECT_PAGES \
> > > > > - ((MAX_INDIRECT_SEGMENTS + SEGS_PER_INDIRECT_FRAME - 1)/SEGS_PER_INDIRECT_FRAME)
> > > > > + DIV_ROUND_UP(MAX_INDIRECT_SEGMENTS, SEGS_PER_INDIRECT_FRAME)
> > > > > #define INDIRECT_PAGES(_segs) DIV_ROUND_UP(_segs, XEN_PAGES_PER_INDIRECT_FRAME)
> > > >
> > > > My first reaction was to suggest
> > > >
> > > > #define MAX_INDIRECT_PAGES INDIRECT_PAGES(MAX_INDIRECT_SEGMENTS)
> > > >
> > > > but that wouldn't match what's there currently (note the two different
> > > > divisors). I can't really decide whether that's just unfortunate naming
> > > > of the two macros, or an actual bug.
> > >
> > > I think there's indeed a bug here.
> > >
> > > AFAICT, MAX_INDIRECT_PAGES should use XEN_PAGES_PER_INDIRECT_FRAME and
> > > then it could be changed as Jan suggested.
>
> The problem is SEGS_PER_INDIRECT_FRAME has been miscalculated. So I think it
> would be fine to use XEN_PAGES_PER_INDIRECT_FRAME in MAX_INDIRECT_PAGES.
>
> However the naming for XEN_PAGES_PER_INDIRECT_FRAME is misnamed. We return
> number of a for segments per indirect frame. So I would rename to
> SEGS_PER_INDIRECT_FRAME.
I don't think I agree with this last part, SEGS_PER_INDIRECT_FRAME
would have to take into account XEN_PAGES_PER_SEGMENT, and
XEN_PAGES_PER_INDIRECT_FRAME doesn't.
XEN_PAGES_PER_INDIRECT_FRAME currently returns the number of grant
references per indirect page, but as I understand it a segment can use
more than one grant reference, if for example the guest page size is
64KB.
>
> > >
> > > Current MAX_INDIRECT_PAGES is misnamed and should instead be
> > > MAX_INDIRECT_SEGS (which on x86 is exactly the same because PAGE_SIZE
> > > == XEN_PAGE_SIZE).
>
> Looking at the usage:
>
> j = min(MAX_INDIRECT_PAGES, INDIRECT_PAGES(nr_segments))
>
> Where j is used as the number of grant ref. So I don't think the variable is
> misnamed here.
Right, I agree that MAX_INDIRECT_PAGE/INDIRECT_PAGES is correct.
Thanks, Roger.
next prev parent reply other threads:[~2018-09-12 10:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-12 5:45 zhong jiang
2018-09-12 8:14 ` [Xen-devel] " Jan Beulich
2018-09-12 9:13 ` Roger Pau Monné
2018-09-12 9:16 ` Roger Pau Monné
2018-09-12 9:48 ` Julien Grall
2018-09-12 10:29 ` Roger Pau Monné [this message]
2018-09-24 13:28 ` Julien Grall
2018-10-02 7:43 ` Roger Pau Monné
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=20180912102908.4ls7vts55n2zfkdz@mac.bytemobile.com \
--to=roger.pau@citrix.com \
--cc=JBeulich@suse.com \
--cc=axboe@kernel.dk \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
--cc=zhongjiang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®