Skip to content

Commit

Permalink
devtmpfs: actually reclaim some init memory
Browse files Browse the repository at this point in the history
Currently gcc seems to inline devtmpfs_setup() into devtmpfsd(), so
its memory footprint isn't reclaimed as intended. Mark it noinline to
make sure it gets put in .init.text.

While here, setup_done can also be put in .init.data: After complete()
releases the internal spinlock, the completion object is never touched
again by that thread, and the waiting thread doesn't proceed until it
observes ->done while holding that spinlock.

This is now the same pattern as for kthreadd_done in init/main.c:
complete() is done in a __ref function, while the corresponding
wait_for_completion() is in an __init function.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20210312103027.2701413-2-linux@rasmusvillemoes.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Rasmus Villemoes authored and Greg Kroah-Hartman committed Mar 23, 2021
1 parent 38f087d commit 01085e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ int __init devtmpfs_mount(void)
return err;
}

static DECLARE_COMPLETION(setup_done);
static __initdata DECLARE_COMPLETION(setup_done);

static int handle(const char *name, umode_t mode, kuid_t uid, kgid_t gid,
struct device *dev)
Expand Down Expand Up @@ -405,7 +405,7 @@ static void __noreturn devtmpfs_work_loop(void)
}
}

static int __init devtmpfs_setup(void *p)
static noinline int __init devtmpfs_setup(void *p)
{
int err;

Expand Down

0 comments on commit 01085e2

Please sign in to comment.