From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752601AbdLHAPt (ORCPT ); Thu, 7 Dec 2017 19:15:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:59624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbdLHAPp (ORCPT ); Thu, 7 Dec 2017 19:15:45 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D150B21869 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: jeyu@kernel.org, rusty@rustcorp.com.au Cc: keescook@chromium.org, tixxdz@gmail.com, mbenes@suse.cz, atomlin@redhat.com, pmladek@suse.com, hare@suse.com, james.l.morris@oracle.com, ebiederm@xmission.com, davem@davemloft.net, akpm@linux-foundation.org, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH 0/3] module: minor allocation optimization Date: Thu, 7 Dec 2017 16:15:37 -0800 Message-Id: <20171208001540.23696-1-mcgrof@kernel.org> X-Mailer: git-send-email 2.13.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Long ago I was debugging kernel/module.c and kernel/kmod.c and had implemented a sanity check to avoid allocating much of the needed struct module from what user passes on finit_module() too early, ie, before checking if the module was actually loaded. I had disregarded this work as I had bundled it up with some aliasing work I had done, so incorrectly thought this depended on the alias work. Upon a second look it does not. The module name set on userspace on info->name is not the alias but the proper module name, as such using finished_loading() should suffice once to avoid allocating the module if its already present. I've tested this with kmod.sh and found no regressions, the few minor enhancements are documented in patch 3 in detail. I'll let 0-day hammer on it as we review the patches [0] [1] but no build issues so far. [0] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git/log/?h=20171207-avoid-bogus-layout_and_allocate [1] https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux-next.git/log/?h=20171207-avoid-bogus-layout_and_allocate Luis R. Rodriguez (3): module: add an early early_mod_check() module: move finished_loading() module: avoid allocation if module is already present and ready kernel/module.c | 81 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 32 deletions(-) -- 2.15.0