From: "Jürgen Groß" <jgross@suse.com>
To: "Roger Pau Monné" <roger.pau@citrix.com>
Cc: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Stefano Stabellini <sstabellini@kernel.org>,
Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH] xen/blkfront: fix ring info addressing
Date: Thu, 5 Mar 2020 12:04:27 +0100 [thread overview]
Message-ID: <20915d12-665e-bd23-2685-d2ec7e015679@suse.com> (raw)
In-Reply-To: <20200305104935.GU24458@Air-de-Roger.citrite.net>
On 05.03.20 11:49, Roger Pau Monné wrote:
> On Thu, Mar 05, 2020 at 11:03:31AM +0100, Juergen Gross wrote:
>> Commit 0265d6e8ddb890 ("xen/blkfront: limit allocated memory size to
>> actual use case") made struct blkfront_ring_info size dynamic. This is
>> fine when running with only one queue, but with multiple queues the
>> addressing of the single queues has to be adapted as the structs are
>> allocated in an array.
>
> Thanks, and sorry for not catching this during review.
>
>>
>> Fixes: 0265d6e8ddb890 ("xen/blkfront: limit allocated memory size to actual use case")
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> ---
>> drivers/block/xen-blkfront.c | 82 ++++++++++++++++++++++++--------------------
>> 1 file changed, 45 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
>> index e2ad6bba2281..a8d4a3838e5d 100644
>> --- a/drivers/block/xen-blkfront.c
>> +++ b/drivers/block/xen-blkfront.c
>> @@ -213,6 +213,7 @@ struct blkfront_info
>> struct blk_mq_tag_set tag_set;
>> struct blkfront_ring_info *rinfo;
>> unsigned int nr_rings;
>> + unsigned int rinfo_size;
>> /* Save uncomplete reqs and bios for migration. */
>> struct list_head requests;
>> struct bio_list bio_list;
>> @@ -259,6 +260,21 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo);
>> static void blkfront_gather_backend_features(struct blkfront_info *info);
>> static int negotiate_mq(struct blkfront_info *info);
>>
>> +#define rinfo_ptr(rinfo, off) \
>> + (struct blkfront_ring_info *)((unsigned long)(rinfo) + (off))
> ^ void * would seem more natural IMO.
>
> Also if you use void * you don't need the extra (struct
> blkfront_ring_info *) cast I think?
Yes, can change that.
> I however think this macro is kind of weird, since it's just doing an
> addition. I would rather have that calculation in get_rinfo and code
> for_each_rinfo on top of that.
I wanted to avoid the multiplication in the rather common
for_each_rinfo() usage.
>
> I agree this might be a question of taste, so I'm not going to insist
> but that would reduce the number of helpers from 3 to 2.
>
>> +
>> +#define for_each_rinfo(info, rinfo, idx) \
>> + for (rinfo = info->rinfo, idx = 0; \
>> + idx < info->nr_rings; \
>> + idx++, rinfo = rinfo_ptr(rinfo, info->rinfo_size))
>
> I think the above is missing proper parentheses around macro
> parameters.
rinfo and idx are simple variables, so I don't think they need
parentheses. info maybe. But just seeing it now: naming the
parameter "rinfo" and trying to access info->rinfo isn't a good
idea. It is working only as I always use "rinfo" as the pointer.
>
>> +
>> +static struct blkfront_ring_info *get_rinfo(struct blkfront_info *info,
>> + unsigned int i)
>
> inline attribute might be appropriate here.
See "the inline disease" in the kernel's coding style.
Juergen
next prev parent reply other threads:[~2020-03-05 11:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 10:03 [PATCH] xen/blkfront: fix ring info addressing Juergen Gross
2020-03-05 10:49 ` Roger Pau Monné
2020-03-05 11:04 ` Jürgen Groß [this message]
2020-03-05 11:40 ` 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=20915d12-665e-bd23-2685-d2ec7e015679@suse.com \
--to=jgross@suse.com \
--cc=axboe@kernel.dk \
--cc=boris.ostrovsky@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.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