Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1518753 > unrolled thread
| Started by | Dexuan Cui <decui@microsoft.com> |
|---|---|
| First post | 2016-11-10 10:00 +0100 |
| Last post | 2016-11-10 21:10 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Dexuan Cui <decui@microsoft.com> - 2016-11-10 10:00 +0100
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Dexuan Cui <decui@microsoft.com> - 2016-11-10 18:00 +0100
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Jake Oshins <jakeo@microsoft.com> - 2016-11-10 18:20 +0100
RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Jake Oshins <jakeo@microsoft.com> - 2016-11-10 21:10 +0100
| From | Dexuan Cui <decui@microsoft.com> |
|---|---|
| Date | 2016-11-10 10:00 +0100 |
| Subject | [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() |
| Message-ID | <sBTnb-3hK-15@gated-at.bofh.it> |
We don't really need such a big on-stack buffer.
vmbus_sendpacket() here only uses sizeof(struct pci_child_message).
Signed-off-by: Dexuan Cui <decui@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
Cc: KY Srinivasan <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
---
drivers/pci/host/pci-hyperv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 763ff87..93ed64a 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1271,9 +1271,9 @@ static struct hv_pci_dev *new_pcichild_device(struct hv_pcibus_device *hbus,
struct hv_pci_dev *hpdev;
struct pci_child_message *res_req;
struct q_res_req_compl comp_pkt;
- union {
- struct pci_packet init_packet;
- u8 buffer[0x100];
+ struct {
+ struct pci_packet init_packet;
+ u8 buffer[sizeof(struct pci_child_message)];
} pkt;
unsigned long flags;
int ret;
--
2.7.4
[toc] | [next] | [standalone]
| From | Dexuan Cui <decui@microsoft.com> |
|---|---|
| Date | 2016-11-10 18:00 +0100 |
| Message-ID | <sC0RH-ke-1@gated-at.bofh.it> |
| In reply to | #1518753 |
> From: Jake Oshins
> > From: Dexuan Cui
> > Sent: Wednesday, November 9, 2016 11:18 PM
> > We don't really need such a big on-stack buffer.
> > vmbus_sendpacket() here only uses sizeof(struct pci_child_message).
> >
> > @@ -1271,9 +1271,9 @@ static struct hv_pci_dev
> > *new_pcichild_device(struct hv_pcibus_device *hbus,
> > struct hv_pci_dev *hpdev;
> > struct pci_child_message *res_req;
> > struct q_res_req_compl comp_pkt;
> > - union {
> > - struct pci_packet init_packet;
> > - u8 buffer[0x100];
> > + struct {
> > + struct pci_packet init_packet;
> > + u8 buffer[sizeof(struct pci_child_message)];
> > } pkt;
> > unsigned long flags;
> > int ret;
>
> This change seems good to me, in that it's always a bad idea to use too much
> stack. But this won't fix the problem with VMAP_STACK. The buffer could still
> end up spanning two pages and the physical addresses of those pages would
> possibly be discontiguous. Do you want to just refactor this so that it uses a
> fixed buffer, one that will work with VMAP_STACK? Or is that coming in a future
> patch?
Hi Jake, I think the VMAP_STACK issue you mentioned should be another different
issue fixed by Long Li: https://patchwork.ozlabs.org/patch/692447/.
The VMAP_STACK issue is only an issue when we pass the buffer's physical address
to the hypercall.
Here the buffer is not passed to any hypercall. We just use vmbus_sendpacket()
to memcpy the buffer into the per-channel ringbuffer.
Thanks,
-- Dexuan
[toc] | [prev] | [next] | [standalone]
| From | Jake Oshins <jakeo@microsoft.com> |
|---|---|
| Date | 2016-11-10 18:20 +0100 |
| Message-ID | <sC1b4-FQ-11@gated-at.bofh.it> |
| In reply to | #1519146 |
> -----Original Message-----
>
> > From: Jake Oshins
> > > From: Dexuan Cui
> > > Sent: Wednesday, November 9, 2016 11:18 PM
> > > We don't really need such a big on-stack buffer.
> > > vmbus_sendpacket() here only uses sizeof(struct pci_child_message).
> > >
> > > @@ -1271,9 +1271,9 @@ static struct hv_pci_dev
> > > *new_pcichild_device(struct hv_pcibus_device *hbus,
> > > struct hv_pci_dev *hpdev;
> > > struct pci_child_message *res_req;
> > > struct q_res_req_compl comp_pkt;
> > > - union {
> > > - struct pci_packet init_packet;
> > > - u8 buffer[0x100];
> > > + struct {
> > > + struct pci_packet init_packet;
> > > + u8 buffer[sizeof(struct pci_child_message)];
> > > } pkt;
> > > unsigned long flags;
> > > int ret;
> >
> > This change seems good to me, in that it's always a bad idea to use too
> much
> > stack. But this won't fix the problem with VMAP_STACK. The buffer could
> still
> > end up spanning two pages and the physical addresses of those pages
> would
> > possibly be discontiguous. Do you want to just refactor this so that it uses
> a
> > fixed buffer, one that will work with VMAP_STACK? Or is that coming in a
> future
> > patch?
>
> Hi Jake, I think the VMAP_STACK issue you mentioned should be another
> different
> issue fixed by Long Li: https://patchwork.ozlabs.org/patch/692447/.
>
> The VMAP_STACK issue is only an issue when we pass the buffer's physical
> address
> to the hypercall.
>
> Here the buffer is not passed to any hypercall. We just use
> vmbus_sendpacket()
> to memcpy the buffer into the per-channel ringbuffer.
>
> Thanks,
> -- Dexuan
Yes, you're right. This patch looks fine to me. Sorry for confusing the two issues.
-- Jake
[toc] | [prev] | [next] | [standalone]
| From | Jake Oshins <jakeo@microsoft.com> |
|---|---|
| Date | 2016-11-10 21:10 +0100 |
| Message-ID | <sC0RH-ke-3@gated-at.bofh.it> |
| In reply to | #1518753 |
> -----Original Message-----
> From: Dexuan Cui
> Sent: Wednesday, November 9, 2016 11:18 PM
> To: Bjorn Helgaas <bhelgaas@google.com>; linux-pci@vger.kernel.org;
> devel@linuxdriverproject.org
> Cc: gregkh@linuxfoundation.org; KY Srinivasan <kys@microsoft.com>;
> Haiyang Zhang <haiyangz@microsoft.com>; Stephen Hemminger
> <sthemmin@microsoft.com>; Jake Oshins <jakeo@microsoft.com>; Hadden
> Hoppert <haddenh@microsoft.com>; Vitaly Kuznetsov
> <vkuznets@redhat.com>; jasowang@redhat.com; apw@canonical.com;
> olaf@aepfle.de; linux-kernel@vger.kernel.org
> Subject: [PATCH 1/3] PCI: hv: use the correct buffer size in
> new_pcichild_device()
>
> We don't really need such a big on-stack buffer.
> vmbus_sendpacket() here only uses sizeof(struct pci_child_message).
>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> CC: Jake Oshins <jakeo@microsoft.com>
> Cc: KY Srinivasan <kys@microsoft.com>
> CC: Haiyang Zhang <haiyangz@microsoft.com>
> CC: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> drivers/pci/host/pci-hyperv.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
> index 763ff87..93ed64a 100644
> --- a/drivers/pci/host/pci-hyperv.c
> +++ b/drivers/pci/host/pci-hyperv.c
> @@ -1271,9 +1271,9 @@ static struct hv_pci_dev
> *new_pcichild_device(struct hv_pcibus_device *hbus,
> struct hv_pci_dev *hpdev;
> struct pci_child_message *res_req;
> struct q_res_req_compl comp_pkt;
> - union {
> - struct pci_packet init_packet;
> - u8 buffer[0x100];
> + struct {
> + struct pci_packet init_packet;
> + u8 buffer[sizeof(struct pci_child_message)];
> } pkt;
> unsigned long flags;
> int ret;
> --
> 2.7.4
This change seems good to me, in that it's always a bad idea to use too much stack. But this won't fix the problem with VMAP_STACK. The buffer could still end up spanning two pages and the physical addresses of those pages would possibly be discontiguous. Do you want to just refactor this so that it uses a fixed buffer, one that will work with VMAP_STACK? Or is that coming in a future patch?
-- Jake Oshins
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web