mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Phillip Lougher <phillip@lougher.demon.co.uk>,
	Arnd Bergmann <arnd@arndb.de>, Al Viro <viro@zeniv.linux.org.uk>,
	linux-kernel@vger.kernel.org
Subject: [RFC v2 PATCH 3/3] init: introduce CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE
Date: Mon, 30 Aug 2010 02:28:48 +0900	[thread overview]
Message-ID: <1283102928-3051-4-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1283102928-3051-1-git-send-email-namhyung@gmail.com>

Add new config option USE_INIT_SYSCALL_AS_KERNEL_ROUTINE. This makes
some of kern_sys_*() functions call internal kernel routines directly
instead of calling syscall routine so that it can get rid of
user/kernel address space handling.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
 init/Makefile      |    2 +
 init/sys-wrapper.h |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 usr/Kconfig        |    7 ++++++
 3 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/init/Makefile b/init/Makefile
index 0bf677a..296e5ab 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -15,6 +15,8 @@ mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
 mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
 mounts-$(CONFIG_BLK_DEV_MD)	+= do_mounts_md.o
 
+obj-$(CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE) += sys-wrapper.o
+
 # dependencies on generated files need to be listed explicitly
 $(obj)/version.o: include/generated/compile.h
 
diff --git a/init/sys-wrapper.h b/init/sys-wrapper.h
index e4227f9..38f9ec6 100644
--- a/init/sys-wrapper.h
+++ b/init/sys-wrapper.h
@@ -28,6 +28,8 @@
 #include <linux/syscalls.h>
 
 
+#ifndef CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE
+
 /* These macro are called just before/after actual syscalls. */
 #define KSYS_PREPARE				\
 	mm_segment_t old_fs = get_fs();		\
@@ -244,3 +246,60 @@ static inline int kern_sys_getdents64(unsigned int fd,
 
 #undef KSYS_PREPARE
 #undef KSYS_RESTORE
+
+#else /* !CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE */
+
+int kern_sys_link(const char *oldname, const char *newname);
+int kern_sys_unlink(const char *pathname);
+int kern_sys_newlstat(const char *filename, struct stat *statbuf);
+int kern_sys_mkdir(const char *pathname, int mode);
+int kern_sys_rmdir(const char *pathname);
+int kern_sys_mknod(const char *filename, int mode, unsigned dev);
+int kern_sys_chown(const char *filename, uid_t user, gid_t group);
+int kern_sys_chmod(const char *filename, mode_t mode);
+int kern_sys_open(const char *filename, int flags, int mode);
+
+static inline int kern_sys_fchown(unsigned int fd, uid_t user, gid_t group)
+{
+	return sys_fchown(fd, user, group);
+}
+
+static inline int kern_sys_fchmod(unsigned int fd, mode_t mode)
+{
+	return sys_fchmod(fd, mode);
+}
+
+static inline int kern_sys_ftruncate(unsigned int fd, unsigned long length)
+{
+	return sys_ftruncate(fd, length);
+}
+
+static inline int kern_sys_read(unsigned int fd, char *buf, size_t count)
+{
+	return sys_read(fd, (char __user __force *) buf, count);
+}
+
+static inline int kern_sys_write(unsigned int fd, const char *buf,
+				 size_t count)
+{
+	return sys_write(fd, (const char __user __force *) buf, count);
+}
+
+static inline int kern_sys_close(unsigned int fd)
+{
+	return sys_close(fd);
+}
+
+int kern_sys_symlink(const char *oldname, const char *newname);
+int kern_sys_lchown(const char *filename, uid_t user, gid_t group);
+
+static inline int kern_sys_getdents64(unsigned int fd,
+				      struct linux_dirent64 *dirent,
+				      unsigned int count)
+{
+	return sys_getdents64(fd,
+			      (struct linux_dirent64 __user __force *) dirent,
+			      count);
+}
+
+#endif /* !CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE */
diff --git a/usr/Kconfig b/usr/Kconfig
index e2721f5..2a914eb 100644
--- a/usr/Kconfig
+++ b/usr/Kconfig
@@ -148,3 +148,10 @@ config INITRAMFS_COMPRESSION_LZO
 	  (both compression and decompression) is the fastest.
 
 endchoice
+
+config USE_INIT_SYSCALL_AS_KERNEL_ROUTINE
+        bool "Don't call syscalls on init code"
+	depends on BLK_DEV_INITRD
+	default n
+	help
+	  replace syscalls to kernel functions in init code.
-- 
1.7.2.2


  parent reply	other threads:[~2010-08-29 17:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-29 17:28 [RFC v2 PATCH 0/3] initramfs: cleanups Namhyung Kim
2010-08-29 17:28 ` [RFC v2 PATCH 1/3] init: add sys-wrapper.h Namhyung Kim
2010-08-30 12:11   ` Arnd Bergmann
2010-08-30 14:17     ` Namhyung Kim
2010-08-29 17:28 ` [RFC v2 PATCH 2/3] initramfs: use kern_sys_* wrappers instead of syscall Namhyung Kim
2010-08-29 17:28 ` Namhyung Kim [this message]
2010-08-30 12:02 ` [RFC v2 PATCH 0/3] initramfs: cleanups Arnd Bergmann
2010-08-30 14:05   ` Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1283102928-3051-4-git-send-email-namhyung@gmail.com \
    --to=namhyung@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=phillip@lougher.demon.co.uk \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®