From: David Laight <David.Laight@ACULAB.COM>
To: 'Leon Romanovsky' <leon@kernel.org>, Rui Ma <Rui.Ma@amd.com>
Cc: "helgaas@kernel.org" <helgaas@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
"Alexander.Deucher@amd.com" <Alexander.Deucher@amd.com>,
"bhelgaas@google.com" <bhelgaas@google.com>
Subject: RE: [PATCH] PCI/IOV: Decrease VF memory BAR size to save host memory occupied by PTEs
Date: Tue, 11 Oct 2022 11:48:05 +0000 [thread overview]
Message-ID: <da760d45e4714a289220591a0f2efb97@AcuMS.aculab.com> (raw)
In-Reply-To: <Y0VVXB0XTobClVJo@unreal>
From: Leon Romanovsky
> Sent: 11 October 2022 12:37
>
> On Tue, Oct 11, 2022 at 07:23:25PM +0800, Rui Ma wrote:
> > In some certain SR-IOV scene, when the device physical space(such as Video
> > RAM)is fixed, as the number of VFs increases, some device driver may decrease
> > actual BAR memory space used by each VF. However, the VF BAR memory mapping is
> > always based on the usual BAR probing algorithm in PCIe spec. So do not map this
> > unneeded memory can save host memory which occupied by PTEs. Although each PTE
> > only occupies a few bytes of space on its own, a large number of PTEs can still
> > take up a lot of space.
...
> > + /*
> > + * Some SR-IOV device's BAR map range is larger than they can actually use.
> > + * This extra BAR space occupy too much reverse mapping size(physical page
> > + * back to the PTEs). So add a divisor shift parameter to resize the request
> > + * resource of VF according to num of VFs.
> > + */
> > + u16 shift = 1;
Why u16??
> > + virtfn->resource[i].end = virtfn->resource[i].start + (size >> (shift - 1)) - 1;
The 'shift - 1' may require a mask.
...
> > +struct virtfn_get_shift_methods {
> > + u16 vendor;
> > + u16 device;
> > + u16 (*get_shift)(struct pci_dev *dev, u16 arg, int arg2);
More pointless u16 - they just make the code larger.
...
> > +static inline u16 virtfn_get_shift(struct pci_dev *dev, u16 arg1, int arg2)
> > +{
> > + return (u16)1;
>
> <...>
>
> > + return (u16)1;
>
> Why do you need these casts? You can omit them.
Kill all the u16
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2022-10-11 11:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 11:23 Rui Ma
2022-10-11 11:37 ` Leon Romanovsky
2022-10-11 11:48 ` David Laight [this message]
2022-10-17 6:26 ` Christoph Hellwig
2022-11-09 23:46 ` Bjorn Helgaas
-- strict thread matches above, loose matches on Subject: below --
2022-09-26 8:05 Rui Ma
2022-09-27 22:06 ` Bjorn Helgaas
2022-10-11 11:19 ` Ma, Rui
2022-10-11 14:05 ` Deucher, Alexander
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=da760d45e4714a289220591a0f2efb97@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=Alexander.Deucher@amd.com \
--cc=Rui.Ma@amd.com \
--cc=bhelgaas@google.com \
--cc=helgaas@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@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
Powered by JetHome