From patchwork Tue Dec 22 12:19:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jun qian X-Patchwork-Id: 11986443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1DADC433DB for ; Tue, 22 Dec 2020 12:19:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 70C0F20639 for ; Tue, 22 Dec 2020 12:19:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 70C0F20639 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C73558D0008; Tue, 22 Dec 2020 07:19:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C23BF8D0007; Tue, 22 Dec 2020 07:19:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B39118D0008; Tue, 22 Dec 2020 07:19:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 9D87A8D0007 for ; Tue, 22 Dec 2020 07:19:36 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 680981E19 for ; Tue, 22 Dec 2020 12:19:36 +0000 (UTC) X-FDA: 77620823952.22.voice89_1b135b02745f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 4652718038E6C for ; Tue, 22 Dec 2020 12:19:36 +0000 (UTC) X-HE-Tag: voice89_1b135b02745f X-Filterd-Recvd-Size: 5394 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Dec 2020 12:19:35 +0000 (UTC) Received: by mail-ot1-f49.google.com with SMTP id w3so11672114otp.13 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=mlei9VEAIXdjZMoAqrbyYoWDLoJQmRRX3SjyPRFFBW3IJWngxc1guQ8/7Y8ixETdMp ntwU9yiZaCRqiMc9UnNH1mU0B4NhFMzsdREuTdes5wo5WOIcqI5Dm/4Ei/6lXYkWM6Dj n+5fF5Sq9vyNjlJfI8LlszaCeOO0Yqu4DT8iAhQfJyV4KxwVSsVyN3Cx83mkeh5kLeEq /VJTvUB1rXWzNL+tquvqbQp1QQpbAkKoG4QIJ57/k7edGeR+0zRSb8oMp6pPI6hw3hib K9FZyUW33dqiDrbhkOH0QVeUz/D9wFMeqEVG1FxXDIPgyMHm12FBxpJkErdVFbXpJbpj eToA== X-Gm-Message-State: AOAM533efkRJWTqsUlpmmM+b6DTB0f0zYObs6bP7EGAxorWkpi5t0kTH okNHsMaISo+PrfIaJ4o6hmw= X-Google-Smtp-Source: ABdhPJzZpP1vlG4raT6ssXYp9jHbcTrMu/sjKBenhHMuFdnNde7uG0JADT3NS/4ELZ3FPAa8U0cb+A== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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);