linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: avoid call vmalloc if init size is zero
@ 2012-01-27  7:19 Dmitry Antipov
  2012-01-27 11:21 ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Antipov @ 2012-01-27  7:19 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel, linaro-dev, patches, Dmitry Antipov

For the architectures with it's own module_alloc(), if module init
size is zero, avoiding module_alloc_update_bounds() and memset()
no-op calls also eliminates warn_alloc_failed() zero-size warning
in __vmalloc_node_range().

Signed-off-by: Dmitry Antipov <dmitry.antipov@linaro.org>
---
 kernel/module.c |   31 +++++++++++++++++--------------
 1 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 2c93276..bbe1c5b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2644,20 +2644,23 @@ static int move_module(struct module *mod, struct load_info *info)
 	memset(ptr, 0, mod->core_size);
 	mod->module_core = ptr;
 
-	ptr = module_alloc_update_bounds(mod->init_size);
-	/*
-	 * The pointer to this block is stored in the module structure
-	 * which is inside the block. This block doesn't need to be
-	 * scanned as it contains data and code that will be freed
-	 * after the module is initialized.
-	 */
-	kmemleak_ignore(ptr);
-	if (!ptr && mod->init_size) {
-		module_free(mod, mod->module_core);
-		return -ENOMEM;
-	}
-	memset(ptr, 0, mod->init_size);
-	mod->module_init = ptr;
+	if (mod->init_size) {
+		ptr = module_alloc_update_bounds(mod->init_size);
+		/*
+		 * The pointer to this block is stored in the module structure
+		 * which is inside the block. This block doesn't need to be
+		 * scanned as it contains data and code that will be freed
+		 * after the module is initialized.
+		 */
+		kmemleak_ignore(ptr);
+		if (!ptr) {
+			module_free(mod, mod->module_core);
+			return -ENOMEM;
+		}
+		memset(ptr, 0, mod->init_size);
+		mod->module_init = ptr;
+	} else
+		mod->module_init = NULL;
 
 	/* Transfer each section which specifies SHF_ALLOC */
 	pr_debug("final section addresses:\n");
-- 
1.7.7.5


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

* Re: [PATCH] module: avoid call vmalloc if init size is zero
  2012-01-27  7:19 [PATCH] module: avoid call vmalloc if init size is zero Dmitry Antipov
@ 2012-01-27 11:21 ` Rusty Russell
  2012-01-30  7:28   ` Dmitry Antipov
  0 siblings, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2012-01-27 11:21 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: linux-kernel, linaro-dev, patches, Dmitry Antipov

On Fri, 27 Jan 2012 11:19:16 +0400, Dmitry Antipov <dmitry.antipov@linaro.org> wrote:
> For the architectures with it's own module_alloc(), if module init
> size is zero, avoiding module_alloc_update_bounds() and memset()
> no-op calls also eliminates warn_alloc_failed() zero-size warning
> in __vmalloc_node_range().
> 
> Signed-off-by: Dmitry Antipov <dmitry.antipov@linaro.org>

Please fix __vmalloc_node_range() instead to return ZERO_SIZE_PTR.
And of course, vfree() to use ZERO_OR_NULL_PTR().

Thanks,
Rusty.

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

* Re: [PATCH] module: avoid call vmalloc if init size is zero
  2012-01-27 11:21 ` Rusty Russell
@ 2012-01-30  7:28   ` Dmitry Antipov
  2012-01-30  7:54     ` Rusty Russell
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Antipov @ 2012-01-30  7:28 UTC (permalink / raw)
  To: Rusty Russell; +Cc: linux-kernel, linaro-dev

On 01/27/2012 03:21 PM, Rusty Russell wrote:

> Please fix __vmalloc_node_range() instead to return ZERO_SIZE_PTR.
> And of course, vfree() to use ZERO_OR_NULL_PTR().

For the convenience and uniformity, should {alloc,free}_percpu() be
also modified in that way?

Dmitry

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

* Re: [PATCH] module: avoid call vmalloc if init size is zero
  2012-01-30  7:28   ` Dmitry Antipov
@ 2012-01-30  7:54     ` Rusty Russell
  0 siblings, 0 replies; 4+ messages in thread
From: Rusty Russell @ 2012-01-30  7:54 UTC (permalink / raw)
  To: Dmitry Antipov; +Cc: linux-kernel, linaro-dev

On Mon, 30 Jan 2012 11:28:12 +0400, Dmitry Antipov <dmitry.antipov@linaro.org> wrote:
> On 01/27/2012 03:21 PM, Rusty Russell wrote:
> 
> > Please fix __vmalloc_node_range() instead to return ZERO_SIZE_PTR.
> > And of course, vfree() to use ZERO_OR_NULL_PTR().
> 
> For the convenience and uniformity, should {alloc,free}_percpu() be
> also modified in that way?

Yep!

Thanks,
Rusty.

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

end of thread, other threads:[~2012-01-30  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-27  7:19 [PATCH] module: avoid call vmalloc if init size is zero Dmitry Antipov
2012-01-27 11:21 ` Rusty Russell
2012-01-30  7:28   ` Dmitry Antipov
2012-01-30  7:54     ` Rusty Russell

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