mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hoeun Ryu <hoeun.ryu@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Michal Hocko <mhocko@suse.com>, Ingo Molnar <mingo@kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	Kees Cook <keescook@chromium.org>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Mateusz Guzik <mguzik@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	kernel-hardening@lists.openwall.com,
	Hoeun Ryu <hoeun.ryu@gmail.com>
Subject: [PATCH 3/3] fork: allocate vmapped kernel stacks for cache when a cpu is up
Date: Sat,  4 Feb 2017 00:33:21 +0900	[thread overview]
Message-ID: <1486136013-27565-1-git-send-email-hoeun.ryu@gmail.com> (raw)

when a cpu is up, predefined number of stacks are allocated and cached
immediately.

Signed-off-by: Hoeun Ryu <hoeun.ryu@gmail.com>
---
 kernel/fork.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 50de6cf..ee4067d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -194,6 +194,21 @@ static int alloc_vm_stack_cache(unsigned int cpu)
 	vm_stack_cache->cur = 0;
 	vm_stack_cache->nr = 0;
 
+	for (i = 0; i < NR_CACHED_STACKS; i++) {
+		void *stack = __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE,
+						VMALLOC_START, VMALLOC_END,
+						THREADINFO_GFP | __GFP_HIGHMEM,
+						PAGE_KERNEL,
+						0, cpu_to_node(cpu),
+						__builtin_return_address(0));
+		if (!stack)
+			return -ENOMEM;
+
+		vm_stacks[i] = find_vm_area(stack);
+		vm_stack_cache->cur++;
+		vm_stack_cache->nr++;
+	}
+
 	return 0;
 }
 
-- 
2.7.4

                 reply	other threads:[~2017-02-03 15:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1486136013-27565-1-git-send-email-hoeun.ryu@gmail.com \
    --to=hoeun.ryu@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mguzik@redhat.com \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    /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®