From patchwork Fri Jan 27 07:19:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 6421 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 92E7623F8D for ; Fri, 27 Jan 2012 07:19:23 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id 57802A184E5 for ; Fri, 27 Jan 2012 07:19:23 +0000 (UTC) Received: by bkar19 with SMTP id r19so1528369bka.11 for ; Thu, 26 Jan 2012 23:19:23 -0800 (PST) Received: by 10.205.127.17 with SMTP id gy17mr2437681bkc.110.1327648763020; Thu, 26 Jan 2012 23:19:23 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs64572bks; Thu, 26 Jan 2012 23:19:22 -0800 (PST) Received: by 10.205.131.135 with SMTP id hq7mr2390441bkc.133.1327648762278; Thu, 26 Jan 2012 23:19:22 -0800 (PST) Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id b15si3619330bke.49.2012.01.26.23.19.21 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 26 Jan 2012 23:19:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of dmitry.antipov@linaro.org) smtp.mail=dmitry.antipov@linaro.org Received: by mail-bk0-f50.google.com with SMTP id zu5so1550358bkb.37 for ; Thu, 26 Jan 2012 23:19:21 -0800 (PST) Received: by 10.204.153.195 with SMTP id l3mr2521677bkw.123.1327648761664; Thu, 26 Jan 2012 23:19:21 -0800 (PST) Received: from localhost.localdomain ([78.153.153.8]) by mx.google.com with ESMTPS id d2sm14335976bky.11.2012.01.26.23.19.19 (version=SSLv3 cipher=OTHER); Thu, 26 Jan 2012 23:19:20 -0800 (PST) From: Dmitry Antipov To: Rusty Russell Cc: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org, Dmitry Antipov Subject: [PATCH] module: avoid call vmalloc if init size is zero Date: Fri, 27 Jan 2012 11:19:16 +0400 Message-Id: <1327648756-22255-1-git-send-email-dmitry.antipov@linaro.org> X-Mailer: git-send-email 1.7.7.5 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 --- 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");