[PATCH v2 0/8] fs: don't use module helpers in non-modular code

From: Paul Gortmaker
Date: Thu Dec 17 2015 - 14:14:22 EST


This series of commits is a slice of a larger project to ensure
people don't needlessly use modular support functions in non-modular
code. Overall there was roughly 5k lines of unused _exit code and
".remove" functions in the kernel due to this. So far we've fixed
several areas, like tty, x86, net, etc. and we continue here in fs/

There are several reasons to not use module helpers for code that can
never be built as a module, but the big ones are:

(1) it is easy to accidentally code up an unused module_exit function
(2) it can be misleading when reading the source, thinking it can be
modular when the Makefile and/or Kconfig prohibit it
(3) it requires the include of the module.h header file which in turn
includes nearly everything else, thus increasing CPP overhead.

Fortunately the code here is core fs code and not strictly a driver
in the sense that a UART or GPIO driver is. So we don't have a lot
of unused code to remove, and mainly gain in avoiding #2 and #3 above.

Here we convert some module_init() calls into fs_initcall(). In doing
so we must note that this changes the init ordering slightly, since
module_init() becomes device_initcall() in the non-modular case, and
that comes after fs_initcall().

We could have used device_initcall here to strictly preserve the old
ordering, and that largely makes sense for drivers/* dirs. But using
device_initcall in the fs/ dir just seems wrong when we have the staged
initcall system and a fs_initcall bucket in that tiered system.

The hugetlb patch warrants special mention. It has code in both the
fs dir and the mm dir, with initcalls in each. There is an implicit
requirement that the mm one be executed prior to the fs one, else
the runtime will splat. Currently we achieve that only by luck of the
link order. With the changes made here, we use our existing initcall
buckets properly to guarantee that ordering.

Since I have a large queue, I'm hoping to get as many of these as
possible in via maintainers, so that I'm not left someday asking
Linus to pull a giant series.

[v1 --> v2: drop 2 patches merged elsewhere, combine mm & fs chunks
of hugetlb patch into one & update log accordingly.]

---

Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: David Howells <dhowells@xxxxxxxxxx>
Cc: Davidlohr Bueso <dave@xxxxxxxxxxxx>
Cc: David Rientjes <rientjes@xxxxxxxxxx>
Cc: Eric Paris <eparis@xxxxxxxxxxxxxx>
Cc: Hillf Danton <hillf.zj@xxxxxxxxxxxxxxx>
Cc: "J. Bruce Fields" <bfields@xxxxxxxxxxxx>
Cc: Jeff Layton <jlayton@xxxxxxxxxxxxxxx>
Cc: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
Cc: Nadia Yvette Chambers <nyc@xxxxxxxxxxxxxx>
Cc: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
Cc: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx

The following changes since commit 9f9499ae8e6415cefc4fe0a96ad0e27864353c89:

Linux 4.4-rc5 (2015-12-13 17:42:58 -0800)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux.git fs_initcall

for you to fetch changes up to 7763d3b42ca62dc967cc56218df8007401e63cd0:

fs: make binfmt_elf.c explicitly non-modular (2015-12-17 12:11:19 -0500)

----------------------------------------------------------------

Paul Gortmaker (8):
hugetlb: make mm and fs code explicitly non-modular
fs: make notify dnotify.c explicitly non-modular
fs: make fcntl.c explicitly non-modular
fs: make filesystems.c explicitly non-modular
fs: make locks.c explicitly non-modular
fs: make direct-io.c explicitly non-modular
fs: make devpts/inode.c explicitly non-modular
fs: make binfmt_elf.c explicitly non-modular

fs/binfmt_elf.c | 11 +----------
fs/devpts/inode.c | 3 +--
fs/direct-io.c | 4 ++--
fs/fcntl.c | 4 +---
fs/filesystems.c | 2 +-
fs/hugetlbfs/inode.c | 27 ++-------------------------
fs/locks.c | 3 +--
fs/notify/dnotify/dnotify.c | 4 +---
mm/hugetlb.c | 39 +--------------------------------------
9 files changed, 11 insertions(+), 86 deletions(-)

--
2.6.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/