Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2728049pxb; Mon, 31 Jan 2022 03:03:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJztbSLPKHOFHE5XGbF4P1nFJsgmHwSR+CysR25TMLPilcAX2SanZIQjCMcSL2bLcubXxcQa X-Received: by 2002:a17:902:d34c:: with SMTP id l12mr19983821plk.106.1643627014066; Mon, 31 Jan 2022 03:03:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643627014; cv=none; d=google.com; s=arc-20160816; b=JTbeakLZt0SB6xyMQ7oS2dvopdYDMrXbOPJpcAFnVGhEAjWxEdLEbTLJ9iUrA4N6Z8 bCsX4FoScXW8i9JdmVoF5wS2mV/4lJqlxqkqLpTJxkC0W8Ba0hiz02JezQIrxbQ+8coo yAio9ZGqsPSHmO4exNvdkoiVD2FkZBjp6xtASPPMbs9ewIFtG3QvdvvlOmunpumoCBlg 3sBEvOL83hZQz2r9rXwycDAvutrXwGq4FK3n9oFhFS5b6YFGbqSPytxdZ++Ntf143kMD uJ5wDuUp3s4gTWPMlmrHqoWTZ7dZm2nobr51/bLTD2LGuX2l7ruILrm+MdLaQEmUap0W ysVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=WKv5bmQRqPHdZUO4LXo+QEVU5+AgH+NzFasQ6BtkXFM=; b=x90omCtnvUS/CEuR3cumt1v8xWHac8jfbrIb2xQh7AZey3atRqzPFU7igXeJWhuhXM 7cgpAiP8WB+dMoM3HOfHHmKXvcUi4lpgnB13RrOk24vt+FMY0ZPU9JqP3jlZwu5jTVVa T8OiWA6JAsPK7bWe96yqpZNgaFYkb23EBUWTOzcFduD78uMuqZi8I+mfYsYPIZyLwCmK RgRQ6ZeM4a3D+AlqTmZBC0xY+nS9Pfju7BE2+IRQ6zTZbEt1XZI8znYbvV0wr09ZqteG qoz7XYqNhcGRIHICkcAWQK3bFW1efiZpr30pR/aX+zvWymx8wYOiYxMwh3hg/Ctu7CyJ HV8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=isSEOn+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id br2si9780228pjb.6.2022.01.31.03.03.23; Mon, 31 Jan 2022 03:03:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=neutral (no key) header.i=@lespinasse.org; dkim=pass (test mode) header.i=@lespinasse.org header.s=srv-52-rsa header.b=isSEOn+q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lespinasse.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348957AbiA1NU1 (ORCPT + 99 others); Fri, 28 Jan 2022 08:20:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348754AbiA1NTL (ORCPT ); Fri, 28 Jan 2022 08:19:11 -0500 Received: from server.lespinasse.org (server.lespinasse.org [IPv6:2001:470:82ab::100:0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED46DC061747 for ; Fri, 28 Jan 2022 05:19:08 -0800 (PST) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-ed; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=WKv5bmQRqPHdZUO4LXo+QEVU5+AgH+NzFasQ6BtkXFM=; b=/llg3A/maOZyNvvtAsqPMT8BSicLcbnbTOgrCs9XoOeH6gnm+d0cUa1QPJAqq4O8MYZk+ 73okmSGTVaB7uXOAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lespinasse.org; i=@lespinasse.org; q=dns/txt; s=srv-52-rsa; t=1643375407; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : from; bh=WKv5bmQRqPHdZUO4LXo+QEVU5+AgH+NzFasQ6BtkXFM=; b=isSEOn+qW7HslS9ExCPC4SWo6ixC3JaQtA/XDcgOW/HSjp235iI6dbuuhQWVnRuW3C4VC uRo57aSyhVd7UxYlHuifDAq7xC7OAJVnykW+5LpOPvsqHyO0fvzHtEyGaSJUUSc7CqFFm/Y f1UKBDtJAXBGHOuTmsMGu6qrs5b+pNzdA1bQ34JZYbkQLf44t13EMFyrga+f9AXa9GS7G53 enzvE6DnD84v9hHe1ky+dyUTlXSOY08Oer0XUwqyqHSkurysfooyCTMjsrS5KRj/PVI3i+v tIRp6oX2lYonjB00oQJKO6OFfmuobq1OxPPYGWKNhfaNDoAx3E7ifbr3/sew== Received: from zeus.lespinasse.org (zeus.lespinasse.org [10.0.0.150]) by server.lespinasse.org (Postfix) with ESMTPS id 36C7E160AC7; Fri, 28 Jan 2022 05:10:07 -0800 (PST) Received: by zeus.lespinasse.org (Postfix, from userid 1000) id 1CA4E2023B; Fri, 28 Jan 2022 05:10:07 -0800 (PST) From: Michel Lespinasse To: Linux-MM , linux-kernel@vger.kernel.org, Andrew Morton Cc: kernel-team@fb.com, Laurent Dufour , Jerome Glisse , Peter Zijlstra , Michal Hocko , Vlastimil Babka , Davidlohr Bueso , Matthew Wilcox , Liam Howlett , Rik van Riel , Paul McKenney , Song Liu , Suren Baghdasaryan , Minchan Kim , Joel Fernandes , David Rientjes , Axel Rasmussen , Andy Lutomirski , Michel Lespinasse Subject: [PATCH v2 29/35] mm: disable rcu safe vma freeing for single threaded user space Date: Fri, 28 Jan 2022 05:10:00 -0800 Message-Id: <20220128131006.67712-30-michel@lespinasse.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220128131006.67712-1-michel@lespinasse.org> References: <20220128131006.67712-1-michel@lespinasse.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Performance tuning: as single threaded userspace does not use speculative page faults, it does not require rcu safe vma freeing. Turn this off to avoid the related (small) extra overheads. For multi threaded userspace, we often see a performance benefit from the rcu safe vma freeing - even in tests that do not have any frequent concurrent page faults ! This is because rcu safe vma freeing prevents recently released vmas from being immediately reused in a new thread. Signed-off-by: Michel Lespinasse --- kernel/fork.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index db92e42d0087..34600fe86743 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -384,10 +384,12 @@ void vm_area_free(struct vm_area_struct *vma) { free_vma_anon_name(vma); #ifdef CONFIG_SPECULATIVE_PAGE_FAULT - call_rcu(&vma->vm_rcu, __vm_area_free); -#else - kmem_cache_free(vm_area_cachep, vma); + if (atomic_read(&vma->vm_mm->mm_users) > 1) { + call_rcu(&vma->vm_rcu, __vm_area_free); + return; + } #endif + kmem_cache_free(vm_area_cachep, vma); } static void account_kernel_stack(struct task_struct *tsk, int account) -- 2.20.1