linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: usbtest: reduce stack usage in test_queue
@ 2020-07-16  8:27 Bixuan Cui
  2020-07-16 13:47 ` [PATCH -next v2] " Bixuan Cui
  0 siblings, 1 reply; 7+ messages in thread
From: Bixuan Cui @ 2020-07-16  8:27 UTC (permalink / raw)
  To: linux-next
  Cc: linux-kernel, linux-usb, gustavoars, qiang.zhang, stern, gregkh,
	cuibixuan

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
 drivers/usb/misc/usbtest.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..a9b40953d6bc 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	unsigned		i;
 	unsigned long		packets = 0;
 	int			status = 0;
-	struct urb		*urbs[MAX_SGLEN];
+	struct urb		**urbs;

 	if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
 		return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	if (param->sglen > MAX_SGLEN)
 		return -EINVAL;

+	urbs = kcalloc(MAX_SGLEN, sizeof(*urbs), GFP_KERNEL);
+	if (!urbs)
+		return -ENOMEM;
+
 	memset(&context, 0, sizeof(context));
 	context.count = param->iterations * param->sglen;
 	context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	else if (context.errors >
 			(context.is_iso ? context.packet_count / 10 : 0))
 		status = -EIO;
+
+	kfree(urbs);
 	return status;

 fail:
@@ -2144,6 +2150,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 		if (urbs[i])
 			simple_free_urb(urbs[i]);
 	}
+
+	kfree(urbs);
 	return status;
 }

--
2.17.1


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

* [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16  8:27 [PATCH] usb: usbtest: reduce stack usage in test_queue Bixuan Cui
@ 2020-07-16 13:47 ` Bixuan Cui
  2020-07-16 14:26   ` Greg KH
  2020-07-16 15:45   ` Alan Stern
  0 siblings, 2 replies; 7+ messages in thread
From: Bixuan Cui @ 2020-07-16 13:47 UTC (permalink / raw)
  To: linux-next, gustavoars, stern, gregkh
  Cc: linux-kernel, linux-usb, qiang.zhang, Wanghui (John)

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
 drivers/usb/misc/usbtest.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..a9b40953d6bc 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	unsigned		i;
 	unsigned long		packets = 0;
 	int			status = 0;
-	struct urb		*urbs[MAX_SGLEN];
+	struct urb		**urbs;

 	if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
 		return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	if (param->sglen > MAX_SGLEN)
 		return -EINVAL;

+	urbs = kcalloc(MAX_SGLEN, sizeof(*urbs), GFP_KERNEL);
+	if (!urbs)
+		return -ENOMEM;
+
 	memset(&context, 0, sizeof(context));
 	context.count = param->iterations * param->sglen;
 	context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	else if (context.errors >
 			(context.is_iso ? context.packet_count / 10 : 0))
 		status = -EIO;
+
+	kfree(urbs);
 	return status;

 fail:
@@ -2144,6 +2150,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 		if (urbs[i])
 			simple_free_urb(urbs[i]);
 	}
+
+	kfree(urbs);
 	return status;
 }

--
2.17.1


.



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

* Re: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16 13:47 ` [PATCH -next v2] " Bixuan Cui
@ 2020-07-16 14:26   ` Greg KH
  2020-07-17  0:25     ` Bixuan Cui
  2020-07-16 15:45   ` Alan Stern
  1 sibling, 1 reply; 7+ messages in thread
From: Greg KH @ 2020-07-16 14:26 UTC (permalink / raw)
  To: Bixuan Cui
  Cc: linux-next, gustavoars, stern, linux-kernel, linux-usb,
	qiang.zhang, Wanghui (John)

On Thu, Jul 16, 2020 at 09:47:10PM +0800, Bixuan Cui wrote:
> Fix the warning: [-Werror=-Wframe-larger-than=]
> 
> drivers/usb/misc/usbtest.c: In function 'test_queue':
> drivers/usb/misc/usbtest.c:2148:1:
> warning: the frame size of 1232 bytes is larger than 1024 bytes
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
> ---
>  drivers/usb/misc/usbtest.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)

What changed from v1?  Always put that below the --- line.

Please fix up and resend a v2.

thanks,

greg k-h

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

* Re: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16 13:47 ` [PATCH -next v2] " Bixuan Cui
  2020-07-16 14:26   ` Greg KH
@ 2020-07-16 15:45   ` Alan Stern
  2020-07-17  0:22     ` Bixuan Cui
  2020-07-17  0:22     ` Bixuan Cui
  1 sibling, 2 replies; 7+ messages in thread
From: Alan Stern @ 2020-07-16 15:45 UTC (permalink / raw)
  To: Bixuan Cui
  Cc: linux-next, gustavoars, gregkh, linux-kernel, linux-usb,
	qiang.zhang, Wanghui (John)

On Thu, Jul 16, 2020 at 09:47:10PM +0800, Bixuan Cui wrote:
> Fix the warning: [-Werror=-Wframe-larger-than=]
> 
> drivers/usb/misc/usbtest.c: In function 'test_queue':
> drivers/usb/misc/usbtest.c:2148:1:
> warning: the frame size of 1232 bytes is larger than 1024 bytes
> 
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
> ---
>  drivers/usb/misc/usbtest.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
> index 8b220d56647b..a9b40953d6bc 100644
> --- a/drivers/usb/misc/usbtest.c
> +++ b/drivers/usb/misc/usbtest.c
> @@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
>  	unsigned		i;
>  	unsigned long		packets = 0;
>  	int			status = 0;
> -	struct urb		*urbs[MAX_SGLEN];
> +	struct urb		**urbs;
> 
>  	if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
>  		return -EINVAL;
> @@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
>  	if (param->sglen > MAX_SGLEN)
>  		return -EINVAL;
> 
> +	urbs = kcalloc(MAX_SGLEN, sizeof(*urbs), GFP_KERNEL);

Since you know at runtime how many URBs will be needed, why not use that 
information?  Change MAX_SGLEN to param->sglen.

Aside from that,

Acked-by: Alan Stern <stern@rowland.harvard.edu>

Alan Stern

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

* Re: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16 15:45   ` Alan Stern
@ 2020-07-17  0:22     ` Bixuan Cui
  2020-07-17  0:22     ` Bixuan Cui
  1 sibling, 0 replies; 7+ messages in thread
From: Bixuan Cui @ 2020-07-17  0:22 UTC (permalink / raw)
  To: Alan Stern
  Cc: linux-next, gustavoars, gregkh, linux-kernel, linux-usb,
	qiang.zhang, Wanghui (John)

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
v2: Change MAX_SGLEN to param->sglen.

 drivers/usb/misc/usbtest.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..150090ee4ec1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	unsigned		i;
 	unsigned long		packets = 0;
 	int			status = 0;
-	struct urb		*urbs[MAX_SGLEN];
+	struct urb		**urbs;

 	if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
 		return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	if (param->sglen > MAX_SGLEN)
 		return -EINVAL;

+	urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL);
+	if (!urbs)
+		return -ENOMEM;
+
 	memset(&context, 0, sizeof(context));
 	context.count = param->iterations * param->sglen;
 	context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	else if (context.errors >
 			(context.is_iso ? context.packet_count / 10 : 0))
 		status = -EIO;
+
+	kfree(urbs);
 	return status;

 fail:
@@ -2144,6 +2150,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 		if (urbs[i])
 			simple_free_urb(urbs[i]);
 	}
+
+	kfree(urbs);
 	return status;
 }

--
2.17.1


.




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

* [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16 15:45   ` Alan Stern
  2020-07-17  0:22     ` Bixuan Cui
@ 2020-07-17  0:22     ` Bixuan Cui
  1 sibling, 0 replies; 7+ messages in thread
From: Bixuan Cui @ 2020-07-17  0:22 UTC (permalink / raw)
  To: Alan Stern
  Cc: linux-next, gustavoars, gregkh, linux-kernel, linux-usb,
	qiang.zhang, Wanghui (John)

Fix the warning: [-Werror=-Wframe-larger-than=]

drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes

Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
v2: Change MAX_SGLEN to param->sglen.

 drivers/usb/misc/usbtest.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..150090ee4ec1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	unsigned		i;
 	unsigned long		packets = 0;
 	int			status = 0;
-	struct urb		*urbs[MAX_SGLEN];
+	struct urb		**urbs;

 	if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
 		return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	if (param->sglen > MAX_SGLEN)
 		return -EINVAL;

+	urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL);
+	if (!urbs)
+		return -ENOMEM;
+
 	memset(&context, 0, sizeof(context));
 	context.count = param->iterations * param->sglen;
 	context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 	else if (context.errors >
 			(context.is_iso ? context.packet_count / 10 : 0))
 		status = -EIO;
+
+	kfree(urbs);
 	return status;

 fail:
@@ -2144,6 +2150,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
 		if (urbs[i])
 			simple_free_urb(urbs[i]);
 	}
+
+	kfree(urbs);
 	return status;
 }

--
2.17.1


.




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

* Re: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
  2020-07-16 14:26   ` Greg KH
@ 2020-07-17  0:25     ` Bixuan Cui
  0 siblings, 0 replies; 7+ messages in thread
From: Bixuan Cui @ 2020-07-17  0:25 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-next, gustavoars, stern, linux-kernel, linux-usb,
	qiang.zhang, Wanghui (John)



On 2020/7/16 22:26, Greg KH wrote:
>> Reported-by: kbuild test robot <lkp@intel.com>
>> Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
>> ---
>>  drivers/usb/misc/usbtest.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
> What changed from v1?  Always put that below the --- line.
> 
> Please fix up and resend a v2.
Thank you,it's my mistake. I resend a v2.


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

end of thread, other threads:[~2020-07-17  0:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16  8:27 [PATCH] usb: usbtest: reduce stack usage in test_queue Bixuan Cui
2020-07-16 13:47 ` [PATCH -next v2] " Bixuan Cui
2020-07-16 14:26   ` Greg KH
2020-07-17  0:25     ` Bixuan Cui
2020-07-16 15:45   ` Alan Stern
2020-07-17  0:22     ` Bixuan Cui
2020-07-17  0:22     ` Bixuan Cui

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