linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
@ 2016-11-10  7:17 Dexuan Cui
  2016-11-10 16:27 ` Jake Oshins
  2016-11-14 22:58 ` KY Srinivasan
  0 siblings, 2 replies; 5+ messages in thread
From: Dexuan Cui @ 2016-11-10  7:17 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, devel
  Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Jake Oshins, Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw,
	olaf, linux-kernel

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
  2016-11-10  7:17 [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Dexuan Cui
@ 2016-11-10 16:27 ` Jake Oshins
  2016-11-10 16:52   ` Dexuan Cui
  2016-11-14 22:58 ` KY Srinivasan
  1 sibling, 1 reply; 5+ messages in thread
From: Jake Oshins @ 2016-11-10 16:27 UTC (permalink / raw)
  To: Dexuan Cui, Bjorn Helgaas, linux-pci, devel
  Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
	linux-kernel

> -----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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
  2016-11-10 16:27 ` Jake Oshins
@ 2016-11-10 16:52   ` Dexuan Cui
  2016-11-10 17:05     ` Jake Oshins
  0 siblings, 1 reply; 5+ messages in thread
From: Dexuan Cui @ 2016-11-10 16:52 UTC (permalink / raw)
  To: Jake Oshins, Bjorn Helgaas, linux-pci, devel
  Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
	linux-kernel

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
  2016-11-10 16:52   ` Dexuan Cui
@ 2016-11-10 17:05     ` Jake Oshins
  0 siblings, 0 replies; 5+ messages in thread
From: Jake Oshins @ 2016-11-10 17:05 UTC (permalink / raw)
  To: Dexuan Cui, Bjorn Helgaas, linux-pci, devel
  Cc: gregkh, KY Srinivasan, Haiyang Zhang, Stephen Hemminger,
	Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
	linux-kernel

> -----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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device()
  2016-11-10  7:17 [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Dexuan Cui
  2016-11-10 16:27 ` Jake Oshins
@ 2016-11-14 22:58 ` KY Srinivasan
  1 sibling, 0 replies; 5+ messages in thread
From: KY Srinivasan @ 2016-11-14 22:58 UTC (permalink / raw)
  To: Dexuan Cui, Bjorn Helgaas, linux-pci, devel
  Cc: gregkh, Haiyang Zhang, Stephen Hemminger, Jake Oshins,
	Hadden Hoppert, Vitaly Kuznetsov, jasowang, apw, olaf,
	linux-kernel



> -----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>

Thanks Dexuan.

Acked-by: K. Y. Srinivasan <kys@microsoft.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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-14 23:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10  7:17 [PATCH 1/3] PCI: hv: use the correct buffer size in new_pcichild_device() Dexuan Cui
2016-11-10 16:27 ` Jake Oshins
2016-11-10 16:52   ` Dexuan Cui
2016-11-10 17:05     ` Jake Oshins
2016-11-14 22:58 ` KY Srinivasan

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 NNTP newsgroup(s).