Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4925316pxu; Tue, 22 Dec 2020 04:22:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxB3M0P3JzPMcQRvrBbRmmV4hHO8EZCoyJpCehUtm6oFUEWSUjNVVhsegn95HWEE8SShI+A X-Received: by 2002:a17:907:105e:: with SMTP id oy30mr19402592ejb.495.1608639742786; Tue, 22 Dec 2020 04:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608639742; cv=none; d=google.com; s=arc-20160816; b=EnxOwatAnbAQJpNxI+7V5ankiP/toVXv4RQdf+sDhoP0Ums14B5vS0/oSiXcrBrAc4 fvU/0bttMD/WgfWP298eYQtR3Oe1BUiNlAOx0xVh+Qq5t2d8asDcf00BUlbUW0sEefmL GQeqaLMyGiWhBNY0qw5RxeYBmgEUJ88Mqz3bfmRutGPUL86KBkOMrIr3jIBLw/pgLuYA bx1C6rrjheg9S88We3y+EhcLIUHhdVD9zP3w2MxZY1WSJoAnoQisq9VAlRy+2vhrAu0J pPO8BwmgKP1okrsPDjGNsMnIsvuB5oVWXGlhLSes+VsB5Jt/Tu6377DShZ4dLr8BVPwS XL9w== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MSZyi2h29d/pc/zMIRyzuH+lEXfDxQm0cbyH2qdw1U4=; b=qqN3vMwGzXM9SX0/1OeoiuEP285OxA4ayKNdV9x0lXP95ylztYq8nMiIkXBs8DlURA QG9/5+BtyCxpByRwohh0FxEsubElzpz/6/3F2C+slYR64tbhNKVF5fwOiZBJaLnc48Fi q/Kn612jyUn6GetehbSVdGCXr6+xAzzdeaTznEuxTAyUsoT4urGaVckhraKsdq8RWjWx gxsbynM6QkjuagrE8eHoyOpn0y/TKk1D9yy4u+IPAgh/ie583i7cAdqVcGYME/d1B2pP AKRUGMfayH5T4xryVNSldfUXvESCPM2eJYbjDQAKyM8EYfuJepd9l/VySbCtUSoiIHYz 5kcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="jl/5+5wk"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y35si3576846edy.362.2020.12.22.04.21.59; Tue, 22 Dec 2020 04:22:22 -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=pass header.i=@gmail.com header.s=20161025 header.b="jl/5+5wk"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbgLVMUQ (ORCPT + 99 others); Tue, 22 Dec 2020 07:20:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbgLVMUQ (ORCPT ); Tue, 22 Dec 2020 07:20:16 -0500 Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E26ACC0613D3 for ; Tue, 22 Dec 2020 04:19:35 -0800 (PST) Received: by mail-ot1-x331.google.com with SMTP id i6so11750532otr.2 for ; Tue, 22 Dec 2020 04:19:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MSZyi2h29d/pc/zMIRyzuH+lEXfDxQm0cbyH2qdw1U4=; b=jl/5+5wku6WpeCVsW3YLsJk595mxsP2Gdh7aac0/fiEswu+Km8PpqnzR6X9DKyLug2 a180ENrSt0nRr7UbMRER+qh9S804yURja6flvNp6PRp0PKpCSBKZEvvaPaNVHSJ0Ticd ViBbR3Rq3QKEGpLa8F3WqwzDNhsr0rMLGxYO2TAlTrhzHq+UxDYZ+wjysFsF85rqJKN3 H7lsIudB1H3GtEjs2ZIyKGa0IH+6a6EfvF7DHJk29n1VIxqEO1R7WmBFRn+gqpMV/qwz eRvwzmm2Galo4Trb8dtq5M9lR9KsvLXe6gy4ULMrcqxTHFU872kWS8eWaiycemBmZdkY KouQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=MSZyi2h29d/pc/zMIRyzuH+lEXfDxQm0cbyH2qdw1U4=; b=iVI5x8tzTSFkG4vm3Z/FKL3Kbc40P3eVMuel+51ONpgKPOg5lo2f8O311XPWjtoFV6 GPsSo9k46gdMNFcpkmmDt7rD/KAp5aDgAbrPzVNasQBaoLo7fijcElQFqeJhhazBfvEB mrAS1NHwslS7X1zTmsDh9pJecYnfDGREALkAaOgqNYcRFULRK3nv9DGyQ6zVevR0Kaon 1s13mmJP8aXQ5RP/2bqoPYVl97uKR6kT6I/SRcIeVYI5IzSd1dBnx5LJriirh7eXoQzE 0ltTwuoIDNwKQ/SEhg0gWxyaR2slWh1Anhx6kT9a+5owgYAKshkc3jjxV0OSksLlJQb2 z/OQ== X-Gm-Message-State: AOAM533S6oGpC0hpquVwhIMEysdpZwr0Y1Z0pmmHfD3xTUCLYSLzUvcn NV5mXvp5qga2R4XPEJgy47E= X-Received: by 2002:a05:6830:1ac3:: with SMTP id r3mr16155256otc.363.1608639575217; Tue, 22 Dec 2020 04:19:35 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id z14sm4350985oot.5.2020.12.22.04.19.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Dec 2020 04:19:34 -0800 (PST) From: qianjun.kernel@gmail.com To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jun qian Subject: [PATCH 1/1] mm:improve the performance during fork Date: Tue, 22 Dec 2020 20:19:04 +0800 Message-Id: <20201222121904.50845-1-qianjun.kernel@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: jun qian In our project, Many business delays come from fork, so we started looking for the reason why fork is time-consuming. I used the ftrace with function_graph to trace the fork, found that the vm_normal_page will be called tens of thousands and the execution time of this vm_normal_page function is only a few nanoseconds. And the vm_normal_page is not a inline function. So I think if the function is inline style, it maybe reduce the call time overhead. I did the following experiment: I have wrote the c test code, pls ignore the memory leak :) Before fork, I will malloc 4G bytes, then acculate the fork time. int main() { char *p; unsigned long long i=0; float time_use=0; struct timeval start; struct timeval end; for(i=0; i --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index 7d608765932b..a689bb5d3842 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -591,7 +591,7 @@ static void print_bad_pte(struct vm_area_struct *vma, unsigned long addr, * PFNMAP mappings in order to support COWable mappings. * */ -struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, +inline struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, pte_t pte) { unsigned long pfn = pte_pfn(pte); -- 2.18.2