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 B348AC433DB for ; Mon, 29 Mar 2021 12:37:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 44DFB60231 for ; Mon, 29 Mar 2021 12:37:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44DFB60231 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 B93D06B007B; Mon, 29 Mar 2021 08:37:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B1B386B007E; Mon, 29 Mar 2021 08:37:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9914B6B0080; Mon, 29 Mar 2021 08:37:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 7A7466B007B for ; Mon, 29 Mar 2021 08:37:30 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3789B180AD830 for ; Mon, 29 Mar 2021 12:37:30 +0000 (UTC) X-FDA: 77972862660.18.F96E43A Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by imf01.hostedemail.com (Postfix) with ESMTP id E10BD5001526 for ; Mon, 29 Mar 2021 12:37:28 +0000 (UTC) Received: by mail-ot1-f50.google.com with SMTP id k14-20020a9d7dce0000b02901b866632f29so12129705otn.1 for ; Mon, 29 Mar 2021 05:37:29 -0700 (PDT) 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=pK8UIcnRx4QQ3Btv2WqHIXhdKMyfXlhaYgEAW2yfd5Y=; b=EILcPnz2y67mky+A2k5ohkqCxvA12zKUAfHFYSN9F23/xIF70lVOxNXy8VrC6vluLv hEQdTOS7lP3BOlqYtocboPHrfKit+9GQnCtWDULfzb31fRxaMDcqNj6UbKViP6rVaCB9 JCulP+QNoRoVEj4bPWUc+abLCvTd+LUt828YNqtNFeq6zFa/Tx+pVf/FbcMSh6lzkZEX Eo/GDuk1BwoAIPGjruFAMMFlYpgAlrnEbN3NiJLrjArEqdJoZy7+ISdxJFZcPy0WBxvE d9cTfLKu4LYpmEKuGjk85QSq5TnMaILJIan9V6OcKaPgMvbY+4M6mxZFUEKdQNt7D629 toYA== 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=pK8UIcnRx4QQ3Btv2WqHIXhdKMyfXlhaYgEAW2yfd5Y=; b=b3OfDa+nprzTpzjoZbYmV4DdvY6bXsaCng9oXLpQI4mKvuGpRyLFE9/KgtVB00Dior RtJ+fQLi6lg2EKHUYguIqB9PbONIDJRuGzuUfVdjn7Tt3D0XvAvpd9FZXkBBX2B5PoSy YbVMy2wQgiIEaanA5duAE3cf3R2Bnu0IyuZwOn7P0+ooGuYsB50U6M7eSC50mdiQOLnF emeYq+O8AJo6j6fuxOXbX9LU0FHH6Mihz16828YWxJAuBk1ZbQGydCU/A8owZEi1Sjog 1twg9uxtrfMScKvy2cu37eVieduzXhdhJ5AZ0kwUKTkFQyHMI8aB1G/BbLsLvSsfPNzm ajeg== X-Gm-Message-State: AOAM533Abto6Pd2A7V+licjkbyjdpDZg4pIvw9U6LMwCIMvq5aW6C1zd dGNqLroZE2j03uwfufr4uwY= X-Google-Smtp-Source: ABdhPJw3VCk/VUkSPd0TAHStpy7RM1JJZli+Jte7UorebVkvs0o5+yeuVP2OfpBPyDYsqZb/i6e53w== X-Received: by 2002:a9d:6a9:: with SMTP id 38mr23032292otx.365.1617021449067; Mon, 29 Mar 2021 05:37:29 -0700 (PDT) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id m14sm4452271otn.69.2021.03.29.05.37.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Mar 2021 05:37:28 -0700 (PDT) From: qianjun.kernel@gmail.com To: akpm@linux-foundation.org, ast@kernel.org, daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, andriin@fb.com, john.fastabend@gmail.com, kpsingh@chromium.org, linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, jun qian Subject: [PATCH V2 1/1] mm:improve the performance during fork Date: Mon, 29 Mar 2021 20:36:35 +0800 Message-Id: <20210329123635.56915-1-qianjun.kernel@gmail.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: E10BD5001526 X-Stat-Signature: wyk688wpykmoe1869wqngitie1ck1mq9 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-ot1-f50.google.com; client-ip=209.85.210.50 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1617021448-836478 Content-Transfer-Encoding: quoted-printable 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: use the bpftrace tool to trace the fork time : bpftrace -e 'kprobe:_do_fork/comm=3D=3D"redis-server"/ {@st=3Dnsecs;} \ kretprobe:_do_fork /comm=3D=3D"redis-server"/{printf("the fork time \ is %d us\n", (nsecs-@st)/1000)}' no inline vm_normal_page: result: the fork time is 40743 us the fork time is 41746 us the fork time is 41336 us the fork time is 42417 us the fork time is 40612 us the fork time is 40930 us the fork time is 41910 us inline vm_normal_page: result: the fork time is 39276 us the fork time is 38974 us the fork time is 39436 us the fork time is 38815 us the fork time is 39878 us the fork time is 39176 us In the same test environment, we can get 3% to 4% of performance improvement. note:the test data is from the 4.18.0-193.6.3.el8_2.v1.1.x86_64, because my product use this version kernel to test the redis server, If you need to compare the latest version of the kernel test data, you can refer to the version 1 Patch. We need to compare the changes in the size of vmlinux: inline non-inline diff vmlinux size 9709248 bytes 9709824 bytes -576 bytes Signed-off-by: jun qian --- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index eeae590e526a..6ade9748d425 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -592,7 +592,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 ad= dr, +inline struct page *vm_normal_page(struct vm_area_struct *vma, unsigned = long addr, pte_t pte) { unsigned long pfn =3D pte_pfn(pte); --=20 2.18.2