Received: by 10.223.176.46 with SMTP id f43csp4198372wra; Tue, 23 Jan 2018 05:58:10 -0800 (PST) X-Google-Smtp-Source: AH8x226bfx1kCDJspE2k7xZ/vi1qy5h0DitXoxCEZX7hhs7rt/wlU0XFOiEqW3wfAmm08lIb7nw9 X-Received: by 10.101.91.140 with SMTP id i12mr8650391pgr.297.1516715890290; Tue, 23 Jan 2018 05:58:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715890; cv=none; d=google.com; s=arc-20160816; b=qh4xhgPzoxKFczZu8U/SoUH9egUGBjGErtXQreLTcwURZ1ybrzsjIvj4JRNWuIg3LH 7WEu6Phto2nkuYewHgqutQljnm0tH5dkcvnY7Iz3Gb8ao4zQ7KHEhKZhLZTI10cyCu5X xJUn0r5YlcRPci/SwAQHjqxglq8z3xf/sA/giqIgVb63aNR2oq04ySsP6elN4Z+zaWaU f8fTI2IvCsI4OOciQug3RkgMoxu00V0+utl1OgLojLIF4buQ5ppxJgTP55azNEsglcB6 Z6svkxS8vNUR/80M3fDOzY3VPAYmj00Bp+TDAnEwRx+X9nVZJNRK330ojnltkqQLdOSe I+sQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:from:subject:dkim-signature :arc-authentication-results; bh=pu1FWFXTuZf01TJXWitlVUuuHt30UantJLa27mKG0ZQ=; b=WMKJEcCY0ZfDsvD/ZWUJD9Fc8ZkeOGHlmWbe5Z/YZEmSqYaCD1y1MiXezyJtDTUcye MbcqVk0TmPoTQFEdL7zt8IaZqMP4T4wl2ByyYcx2YgXGt5xAWSJMJAuMNd8pE1IN6N77 sPPBX/mO6pXt9j/yMBrhusrXEc2F6bmBqDTofc6M3fgNRXhRp2nR7shTbs6XqW+cVf/4 gnPEEECTH8G7bcHUm4Pi0hDns5EO4UnWqH8gCdQxo0T0vBkFvF49jI1j01mFQlbthaun +8wl7IKxpUE2patZi/a1+EAnnU6R5xZ/aneDdD5EHE84JYYxhiV0u1cNhyx2IjTLMuCK n+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=pjgLF2ML; 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 v70si1514658pfa.405.2018.01.23.05.57.54; Tue, 23 Jan 2018 05:58:10 -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=pjgLF2ML; 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 S1751663AbeAWN53 (ORCPT + 99 others); Tue, 23 Jan 2018 08:57:29 -0500 Received: from forwardcorp1g.cmail.yandex.net ([87.250.241.190]:60727 "EHLO forwardcorp1g.cmail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751562AbeAWN52 (ORCPT ); Tue, 23 Jan 2018 08:57:28 -0500 Received: from smtpcorp1p.mail.yandex.net (smtpcorp1p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:10]) by forwardcorp1g.cmail.yandex.net (Yandex) with ESMTP id E38292173C; Tue, 23 Jan 2018 16:57:25 +0300 (MSK) Received: from smtpcorp1p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtpcorp1p.mail.yandex.net (Yandex) with ESMTP id E13B66E40A56; Tue, 23 Jan 2018 16:57:25 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:b010:d007::1:55]) by smtpcorp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 5B0u3Vhmsh-vNLqT8dD; Tue, 23 Jan 2018 16:57:25 +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=1516715845; bh=pu1FWFXTuZf01TJXWitlVUuuHt30UantJLa27mKG0ZQ=; h=Subject:From:To:References:Message-ID:Date:In-Reply-To; b=pjgLF2MLZtIk1dv0o7yvQNVWscBKL/g7b2BPnsvuX+Udt5kV6VyyQIuyERofvtYZ9 4R585aeNSEi+4w+WYrJBGz1fVwmB/k3UwdYoZs1EiXVgJLOwhI4cbqg4Cx/qyV5ljX IfPPPIPzR+e0Fteb+UcfrfskwdbyCNhYNlTIeW2k= Authentication-Results: smtpcorp1p.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Subject: Re: [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 References: <151670492223.658225.4605377710524021456.stgit@buzz> <151670492913.658225.2758351129158778856.stgit@buzz> Message-ID: <5c19630f-7466-676d-dbbc-a5668c91cbcd@yandex-team.ru> Date: Tue, 23 Jan 2018 16:57:21 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <151670492913.658225.2758351129158778856.stgit@buzz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: ru-RU Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org # stress-ng --clone 100 -t 10s --metrics-brief at 32-core machine shows boost 35000 -> 36000 bogo ops Patch 4/4 is a kind of RFC. Actually per-cpu cache of preallocated stacks works faster than buddy allocator thus performance boots for it happens only at completely insane rate of clones. On 23.01.2018 13:55, Konstantin Khlebnikov wrote: > 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); >