From patchwork Tue Oct 16 13:47:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 10643577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B9CF109C for ; Tue, 16 Oct 2018 13:47:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC96329F72 for ; Tue, 16 Oct 2018 13:47:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E03DD29FB1; Tue, 16 Oct 2018 13:47:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D09829F72 for ; Tue, 16 Oct 2018 13:47:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FED6B0003; Tue, 16 Oct 2018 09:47:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5017C6B0005; Tue, 16 Oct 2018 09:47:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 416876B0006; Tue, 16 Oct 2018 09:47:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 02F7F6B0003 for ; Tue, 16 Oct 2018 09:47:24 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id e6-v6so17169218pge.5 for ; Tue, 16 Oct 2018 06:47:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id; bh=pIL2yTvnYzsocOUuFFF7m7x4MuB8f2/1g1qTkJ/1lTE=; b=A+P0gcH+3SoLhD1SuWpAAU5FmGwSgzv4+GEaz7B9j6L+p0H5oZKVsLbgNCukGQovaq Frr6SCyYnjZ8CAdt5lTtW2I4W11V19HFlGA4fO4ca/TIdwLS5PmtZrRCMfMifRhwv2la 9vaBQ+dfhLLbMNFbbbICXtyGQHI9cHbXGo7DOgkkbDFq5kYk+cYz1A5ZaCQEQBbpGCin ZDLU+ankfCgg7m7mSPMIJdU5liFq6OE5Kf3+Xt7TpnHLIt+t0E52oEoNMKjP0TIbklsd ZmoKb6zHVzM1M6DS8sN3BpbnjAqeOe24s5o18KYyrQKPjxHxlnQanBlBuDNYY/xZ8vZq RTWg== X-Gm-Message-State: ABuFfoizG+W7xdsFRutYy413BXxQWBAM4EybDlqeaV4HVVPvLxpRlh1Z bgXUTobjtrfQ1w6y7kKGL0Ts36Go/VFzibnuYuZC8scDpuDzSPde0Rfy4nPwkvzhuxbVyMueYHS p0r/rBnJUptt3S0Cq3etO8Je3lO+6F2UZ3Aj3TY1HIdZjr1zctUnbljdpVVc1zfouBh7yvXGM7I +4yKSge5G3EtKRZejp83PaTEE3mWPTUNncOLAIhHb/tmt4QUv47KGGgAWHsCYTrahBg3g9bqoV/ erYjqn2vLwEnV5u4X7BR0BhrCQjRWlXc+meq1U/HSbFa4Mt2WvTUlKQHY6SdY6MHWzSG6hlzWR7 70EC8JhFYuOflP+RYQzdzlSEriJ7mg1kdz7857q4S+GRMEBTcQg6azkuMsLu/rNVhEshzcDJeNG T X-Received: by 2002:a65:5147:: with SMTP id g7-v6mr20625985pgq.252.1539697643665; Tue, 16 Oct 2018 06:47:23 -0700 (PDT) X-Received: by 2002:a65:5147:: with SMTP id g7-v6mr20625936pgq.252.1539697642790; Tue, 16 Oct 2018 06:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539697642; cv=none; d=google.com; s=arc-20160816; b=cGW/BCGUKbW8AWOKWEtuz4r7MdES426o4+uByLS2VemoEhnzhbhw/yHpTh9reWShxh FrJC6yf1lLFaJL2PaYq/x/7ZjrEWOpsICBW4kjdRvFNh44c3H/UYLHVZqg/kxYpNFUbv eHvhiwlfw73SWb+RgtaE5LfVxTUC4xW0zbaEfBzhUBc35iC6Jfi8vTEXLc/4qhYP3ja/ wHt0MLhRFMuw4fIdYBztuv6qwuZ3r9CJmNw3zMCkO3O5D2HzM3BCKqIYMj3vue+XBiVe rUg/Y+nAVKQW3tSONyDGx3ySIPY8GPY2rsQ2aWFrwhPLfQLLcUrjrqgltO9ZrYak82pi AcqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=pIL2yTvnYzsocOUuFFF7m7x4MuB8f2/1g1qTkJ/1lTE=; b=S4DK0+f23XxYKlkSu/YejWVMFFDdZ2pOQ1qmp/RC0AMundSrOpqqqyt7yoRM7g2iaL XLbHdnistqQkWGLDduxH17lxvnHf5mkRpae6Idob4i3WuzqtxOdA/2chvRyqizjDHuQl ZPLZASwN8C9mnt/4i9ZPIuHKPVNPFG601+WAQoJaaafGYIIMYGiiMGPcg63YfScqgrGP wLh/kGuGh0LZwDQdjCuHatLYZxuqgNxk1BrEzc5eT5IcOttFJFfS871M1NsOdig1bC9o 4F0IlmMSb1n3gGc4bdTTdXCcEYGXPcAiPMbHZt6Jpv8a5KoY1qxAeCrE8wbeoEDMNX4r SfIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HOgVfsda; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d5-v6sor4764384pgj.70.2018.10.16.06.47.22 for (Google Transport Security); Tue, 16 Oct 2018 06:47:22 -0700 (PDT) Received-SPF: pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HOgVfsda; spf=pass (google.com: domain of richard.weiyang@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=richard.weiyang@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=pIL2yTvnYzsocOUuFFF7m7x4MuB8f2/1g1qTkJ/1lTE=; b=HOgVfsda8IDShcj+4xARk4wGUHpUN3WcPNz6XQ23HV7xrRFKET1QDoOQUqz5E1JrT1 DLNM4FlOXoyXFvypVedc7ojuexZ/JOf/QD9lCknuXvyCFaHj3V6tk4nSgEBvH/Q8qgR6 pM/IiDdu5mNpJDfXcg2hWFJ1MXKihtOu7fSOUwrgUfUeLjbBZctkV4pmCDQwWmQhk86+ PnxOpEh0Hf3vBn009sLhKjH23ir+aiANyh/kYlhLbULfIPN212p3c7gs7yg/4A+E2eUq dBXkSDq1tMxOs8UxouXJBaQPoMY68z36Ds1T0fuB89CeBgE1vUr5NP+c/BUzkUi1RFox r24A== X-Google-Smtp-Source: ACcGV60mw39r+5+ZqsVmUU2w/yaxcCOcdOhlthZd84S6vYONEZdxNTqrESE8XIM0Nl/hZaSnwgrNcA== X-Received: by 2002:a63:a441:: with SMTP id c1-v6mr20453784pgp.49.1539697642024; Tue, 16 Oct 2018 06:47:22 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id t69-v6sm19563874pgd.43.2018.10.16.06.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 06:47:21 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, dan.j.williams@intel.com, mhocko@suse.com Cc: linux-mm@kvack.org, Wei Yang Subject: [RFC PATCH] mm: add a vma to vmacache when addr overlaps the vma range Date: Tue, 16 Oct 2018 21:47:12 +0800 Message-Id: <20181016134712.18123-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.15.1 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: X-Virus-Scanned: ClamAV using ClamSMTP vmacache will cache the latest visited vma to improve the performance of find_vma(). While current implementation would cache a vma even its range doesn't overlap with addr. This entry in vmacache will be a dummy entry, since the vmacache_find() only returns a vma when its range overlap with addr. This patch avoid to add a vma to vmacache when the range doesn't overlap. Signed-off-by: Wei Yang --- Based on my understanding, this change would put more accurate vma entry in the cache, which means reduce unnecessary vmacache update and vmacache find. But the test result is not as expected. From the original changelog, I don't see the explanation to add this non-overlap entry into the vmacache, so curious about why this performs a little better than putting an overlapped entry. Below is the test result for building kernel in two cases: make -j4 make -j8 base-line: real 6m15.947s real 5m11.684s user 21m14.481s user 27m23.471s sys 2m34.407s sys 3m13.233s real 6m16.089s real 5m11.445s user 21m18.295s user 27m24.045s sys 2m35.551s sys 3m13.443s real 6m16.239s real 5m11.218s user 21m17.590s user 27m19.133s sys 2m35.252s sys 3m12.684s patched: real 6m15.416s real 5m10.810s user 21m21.800s user 27m25.223s sys 2m33.398s sys 3m14.784s real 6m15.114s real 5m12.285s user 21m19.986s user 27m32.055s sys 2m34.718s sys 3m13.107s real 6m16.206s real 5m11.509s user 21m22.557s user 27m28.265s sys 2m35.637s sys 3m12.747s --- mm/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mmap.c b/mm/mmap.c index 2e0daf666f42..dda495d84862 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2214,7 +2214,7 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) rb_node = rb_node->rb_right; } - if (vma) + if (vma && vma->vm_start <= addr) vmacache_update(addr, vma); return vma; }