Linux-HyperV Archive mirror
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Michael Kelley <mhklinux@outlook.com>
Cc: "haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	 "wei.liu@kernel.org" <wei.liu@kernel.org>,
	 "decui@microsoft.com" <decui@microsoft.com>,
	 "lpieralisi@kernel.org" <lpieralisi@kernel.org>,
	 "kw@linux.com" <kw@linux.com>,
	"robh@kernel.org" <robh@kernel.org>,
	 "bhelgaas@google.com" <bhelgaas@google.com>,
	 "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	 LKML <linux-kernel@vger.kernel.org>,
	 "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: RE: [PATCH v2 1/1] PCI: hv: Fix ring buffer size calculation
Date: Mon, 19 Feb 2024 12:47:33 +0200 (EET)	[thread overview]
Message-ID: <0a680c72-0c30-d3e7-5c67-a0aefe752be2@linux.intel.com> (raw)
In-Reply-To: <SN6PR02MB415749788D7DEA3D1D792913D44C2@SN6PR02MB4157.namprd02.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 3140 bytes --]

On Fri, 16 Feb 2024, Michael Kelley wrote:

> From: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Sent: Friday, February 16, 2024 6:46 AM
> > 
> > On Wed, 14 Feb 2024, mhkelley58@gmail.com wrote:
> > >
> > > For a physical PCI device that is passed through to a Hyper-V guest VM,
> > > current code specifies the VMBus ring buffer size as 4 pages.  But this
> > > is an inappropriate dependency, since the amount of ring buffer space
> > > needed is unrelated to PAGE_SIZE. For example, on x86 the ring buffer
> > > size ends up as 16 Kbytes, while on ARM64 with 64 Kbyte pages, the ring
> > > size bloats to 256 Kbytes. The ring buffer for PCI pass-thru devices
> > > is used for only a few messages during device setup and removal, so any
> > > space above a few Kbytes is wasted.
> > >
> > > Fix this by declaring the ring buffer size to be a fixed 16 Kbytes.
> > > Furthermore, use the VMBUS_RING_SIZE() macro so that the ring buffer
> > > header is properly accounted for, and so the size is rounded up to a
> > > page boundary, using the page size for which the kernel is built. While
> > > w/64 Kbyte pages this results in a 64 Kbyte ring buffer header plus a
> > > 64 Kbyte ring buffer, that's the smallest possible with that page size.
> > > It's still 128 Kbytes better than the current code.
> > >
> > > Cc: <stable@vger.kernel.org> # 5.15.x
> > > Signed-off-by: Michael Kelley <mhklinux@outlook.com>
> > > Reviewed-by: Kuppuswamy Sathyanarayanan
> > <sathyanarayanan.kuppuswamy@linux.intel.com>
> > > ---
> > > Changes in v2:
> > > * Use SZ_16K instead of 16 * 1024
> > > ---
> > >  drivers/pci/controller/pci-hyperv.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-
> > hyperv.c
> > > index 1eaffff40b8d..baadc1e5090e 100644
> > > --- a/drivers/pci/controller/pci-hyperv.c
> > > +++ b/drivers/pci/controller/pci-hyperv.c
> > > @@ -465,7 +465,7 @@ struct pci_eject_response {
> > >  	u32 status;
> > >  } __packed;
> > >
> > > -static int pci_ring_size = (4 * PAGE_SIZE);
> > > +static int pci_ring_size = VMBUS_RING_SIZE(SZ_16K);
> > >
> > >  /*
> > >   * Driver specific state.
> > >
> > 
> > Hi,
> > 
> > You forgot to add #include <linux/sizes.h> for it.
> > 
> > With that fixed:
> > 
> > Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > 
> 
> Fixed in v3.  I mis-interpreted your previous comment about
> adding the #include "if needed".  It's not needed to compile
> correctly, as sizes.h is indirectly included through some other
> #include.  But it's better to directly #include what's needed
> lest some unrelated change cause a failure.

Yes, we try include the headers we use in the .c file. I used "if needed" 
because I didn't check if it was already among the #includes in the file.

Our tools are lacking to enforce/check a file has correct set of #includes 
so it's currently based mostly on reviewers noticing something is wrong 
with #includes, hopefully some time in the future, the tools also catch 
up.


-- 
 i.

      reply	other threads:[~2024-02-19 10:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-15  7:48 [PATCH v2 1/1] PCI: hv: Fix ring buffer size calculation mhkelley58
2024-02-16 14:46 ` Ilpo Järvinen
2024-02-16 20:28   ` Michael Kelley
2024-02-19 10:47     ` Ilpo Järvinen [this message]

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=0a680c72-0c30-d3e7-5c67-a0aefe752be2@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kw@linux.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=robh@kernel.org \
    --cc=wei.liu@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 read-only IMAP folder(s) and NNTP newsgroup(s).