Received: by 10.223.176.46 with SMTP id f43csp4018360wra; Tue, 23 Jan 2018 02:58:58 -0800 (PST) X-Google-Smtp-Source: AH8x225nlitHJmVCpf/QaYxgVMmU7oR9dxZwYw+otz9pF/MsGymLb3Ge0wIWaKPJjAhM8gI1yj5R X-Received: by 2002:a17:902:bb0a:: with SMTP id l10-v6mr1375168pls.130.1516705138878; Tue, 23 Jan 2018 02:58:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516705138; cv=none; d=google.com; s=arc-20160816; b=FKOzExU+PgCD91pMwB5ggbQb2/4gsnjPB1Z4/adCS9yO+ru71gfl5afIokeYZOvjQK ynRfP9CFUzUNg7fzc/0xc9V0nfNS3sg6ac0qxttRkJJ8fvQiTMXo4WSx0LvU7V9z2ert Bk/E5H/hoMlfqEuO/an0HKA9JMtL4Z+mP6P5mUz0MUnWyLnhIsd3151+21WjOswPlFcc +boDFkhtjTzI2BWMmuiRjhYJvgZ0KFJNwUw6RIJ41nSGy+NDtdYbNUaLnHVHKMeLlclb 49lbGETJturpPeMuijzbKC9Dawwwt7g88bVLQ41Uj8ReHXp8t/WHXXsEAs6GmGjrqvoX gfCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=AD+7rdiaW5GQeQxZlkMonACk0KL/bdxy853ynNdZKSI=; b=nEC6Vk0ee3flQr4GRsYM5Ung7TPw1geUSGfmqEvn0NcTkBbdICuzJQfnFRdUtO0cNS ucJsF6Ybv26C6lDRItOFdIY0VsFx7rlv8LJ8jZNOzY8/XtZI0Uy844HU84P/aPj1GunB xPytbLPihQ8ulhrhq8G5jtPwFtAynLc7sCcLh5T7N3lC5+fW17q1kziGEbAdfiUhWmtT JF++wOwqg2vr28ZHDzCFrsoSYjif5GlQO0yFoPH7eMmpS3QrQ9dCFZ9qTdYwd4JgicF8 QKqWEUMW3aFNK4pgb4CWCxcMUm5PrL+bFV84AZVKTdHAppCt43cBu5IeGhd0mBnWym2M YZGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Pw/L7J/N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w13si4521887pgq.199.2018.01.23.02.58.45; Tue, 23 Jan 2018 02:58:58 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=Pw/L7J/N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex-team.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751636AbeAWK4e (ORCPT + 99 others); Tue, 23 Jan 2018 05:56:34 -0500 Received: from forwardcorp1g.cmail.yandex.net ([87.250.241.190]:59434 "EHLO forwardcorp1g.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751457AbeAWKzd (ORCPT ); Tue, 23 Jan 2018 05:55:33 -0500 Received: from smtpcorp1o.mail.yandex.net (smtpcorp1o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::30]) by forwardcorp1g.cmail.yandex.net (Yandex) with ESMTP id 855D7202F5; Tue, 23 Jan 2018 13:55:31 +0300 (MSK) Received: from smtpcorp1o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1o.mail.yandex.net (Yandex) with ESMTP id 7E7702440DAB; Tue, 23 Jan 2018 13:55:31 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:40c:b4b7:f0f3:4b10:5639]) by smtpcorp1o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id S0QS7mZUqe-tVGGjpUo; Tue, 23 Jan 2018 13:55:31 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1516704931; bh=AD+7rdiaW5GQeQxZlkMonACk0KL/bdxy853ynNdZKSI=; h=Subject:From:To:Date:Message-ID:In-Reply-To:References; b=Pw/L7J/NCk0KLlO1ko6tvdMzt9BcBQ8xTcEjjsq3Jte0IslWw1oIYUVE9GaTJZDTH +TNS2/N7rYAH+UTvJug9nesE+WYZ7u6JuSJjKHmz8DpWmlciijVL5rB6j3j76lm28U g+P0TIg5/WbnRliZoRTcw4AcCt0j2l4NYpVib6RQ= Authentication-Results: smtpcorp1o.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: [PATCH 3/4] kernel/fork: switch vmapped stack callation to __vmalloc_area() From: Konstantin Khlebnikov To: Dave Hansen , linux-kernel@vger.kernel.org, Christoph Hellwig , linux-mm@kvack.org, Andy Lutomirski , Andrew Morton Date: Tue, 23 Jan 2018 13:55:29 +0300 Message-ID: <151670492913.658225.2758351129158778856.stgit@buzz> In-Reply-To: <151670492223.658225.4605377710524021456.stgit@buzz> References: <151670492223.658225.4605377710524021456.stgit@buzz> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This gives as pointer vm_struct without calling find_vm_area(). And fix comment about that task holds cache of vm area: this cache used for retrieving actual stack pages, freeing is done by vfree_deferred(). Signed-off-by: Konstantin Khlebnikov --- kernel/fork.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 2295fc69717f..457c9151f3c8 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -204,39 +204,32 @@ static int free_vm_stack_cache(unsigned int cpu) static unsigned long *alloc_thread_stack_node(struct task_struct *tsk, int node) { #ifdef CONFIG_VMAP_STACK - void *stack; + struct vm_struct *stack; int i; for (i = 0; i < NR_CACHED_STACKS; i++) { - struct vm_struct *s; - - s = this_cpu_xchg(cached_stacks[i], NULL); - - if (!s) + stack = this_cpu_xchg(cached_stacks[i], NULL); + if (!stack) continue; #ifdef CONFIG_DEBUG_KMEMLEAK /* Clear stale pointers from reused stack. */ - memset(s->addr, 0, THREAD_SIZE); + memset(stack->addr, 0, THREAD_SIZE); #endif - tsk->stack_vm_area = s; - return s->addr; + tsk->stack_vm_area = stack; + return stack->addr; } - stack = __vmalloc_node_range(THREAD_SIZE, THREAD_ALIGN, - VMALLOC_START, VMALLOC_END, - THREADINFO_GFP, - PAGE_KERNEL, - 0, node, __builtin_return_address(0)); + stack = __vmalloc_area(THREAD_SIZE, THREAD_ALIGN, + VMALLOC_START, VMALLOC_END, + THREADINFO_GFP, PAGE_KERNEL, + 0, node, __builtin_return_address(0)); + if (unlikely(!stack)) + return NULL; - /* - * We can't call find_vm_area() in interrupt context, and - * free_thread_stack() can be called in interrupt context, - * so cache the vm_struct. - */ - if (stack) - tsk->stack_vm_area = find_vm_area(stack); - return stack; + /* Cache the vm_struct for stack to page conversions. */ + tsk->stack_vm_area = stack; + return stack->addr; #else struct page *page = alloc_pages_node(node, THREADINFO_GFP, THREAD_SIZE_ORDER);