Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp18594211ybl; Fri, 3 Jan 2020 05:28:12 -0800 (PST) X-Google-Smtp-Source: APXvYqx1W44VSkeBrOP42kosPh2P1Xm/HhZz/CWWN9fQoIc0fpldnTLeAjrPUVXOc5mcazn7pM54 X-Received: by 2002:a9d:6857:: with SMTP id c23mr82290438oto.351.1578058091955; Fri, 03 Jan 2020 05:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578058091; cv=none; d=google.com; s=arc-20160816; b=vt9yHtY1PFLtkZEsspubS4EYIScWMpOpk7Z+hhnUE5eIBR4gcjADW5KVdm3x5CwGkZ YJmsAIK7bAWGM+ZmemS+YDKffUex1PKlo+ATDvzrkpsOFZvJyqSjVJx8s/XZJ41Auvsc 5Ci1iOdUK93T1VCKf86YiS2QNcj9WO4XqjudEjqXJscDjF4kh5Ql4UBx0xxqfXituD3f n2cMLnoKLZXPu/2khsH9iyMPO+JvI6dSqm1gooNZM1QwZO5576PY5vwgtp9dRM1XYs85 bBs4SBp1basL07lArmzQoHBANI2mzTYZ8HVX7cE+dyo4TNsYlra4CD++aFMJI/30n9oX 77Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Asw7w06stGi1IWr+2nLUSF6dsNpGXIgVywOg4XUTixQ=; b=hiYULNFzEpH09mqr1oqZg4hq0FPvg+SZh/tSa7nJ1pnUTM5miH/Y3JYifiUVG9FSrc Tc2NeyMC5/dR9IxfFZjWw7vnOgwvyqPimSW67wqZQUKkwDM9XC62Gw+S5WtGmxe/rc8D 1UHB+A8D7rkGcvrkRL2e0ezQOA8j94fi5DqQ3OGIL2ojACQ6hp3Yt9gGG+OLuCC5iKJc kbti7hedYBk8czjoW77eKFP3wMXN4Y4cVW73o8YZVZRLTnEOHYxcVImYDOJ6077Oiy+b ip84YaYg9mlSJL+692mJ7vNxQmBkGbsPyUrfbhCAVMk14S/c8hZocVIIQOGCbcCCM+Fn Hf7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=dM9v8enp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si27072573oif.122.2020.01.03.05.27.59; Fri, 03 Jan 2020 05:28:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=dM9v8enp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727723AbgACN0w (ORCPT + 99 others); Fri, 3 Jan 2020 08:26:52 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42345 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgACN0w (ORCPT ); Fri, 3 Jan 2020 08:26:52 -0500 Received: by mail-lj1-f196.google.com with SMTP id y4so29520913ljj.9 for ; Fri, 03 Jan 2020 05:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Asw7w06stGi1IWr+2nLUSF6dsNpGXIgVywOg4XUTixQ=; b=dM9v8enpv7GyuZ2hsrNesEW4s7o5vYQXBktWha+pyqwORaOfWN1pg7me9woOGhvBq6 au78hLXhQBpbBaHb16xN67Bo0mD6TRiqX725rlHyLWbH5Klx13nmITqgiuKSqGFNzEKM Gux4vCMbriKaiouV96/w7A5L/Chh1GaaaXbp5JtqxeAAd8uNfe/+0l5+zKWoJHw1JpUj IB8MCisXkiCBYQXIlt0f8lKKgXCIgyKOXkUBtS/wy2+hNfQVNSybR3IuIb0uYzPmfTdx 1ngQnQTm0+wX3j+oW/fHu46/AwmKnHRyhvolxZYDvLNU5FHlJyXwCiJku1exmiJQ7Wbf VByg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Asw7w06stGi1IWr+2nLUSF6dsNpGXIgVywOg4XUTixQ=; b=naHG3CNo2ycMoA/0Ro2YmUNHBnSVOlfdp1mdvef1nE1tdTY/acLAFqrjgUIh6l8BVy 8lg6mj0/KQzWAHhLOIf7ErdLdV95nSNLhyrlpIKCi02T/1+lFfajifgn72M98y1X/LR3 8hCuKDeLwlfLVpdxI4TK6HATVlVydmvOkTUG/6zNpoLAt8v+0qWydsOulrnesCZCCbBF +6ZGCMOgeoGxMZodDORsAuxd11UEO9SNurxrz2cwgRf4WJS2i6fGa7tvElZr1mmapUIZ 0HGlfdwZt/jgH1JKNwBQc8x+6N2OkiLQ9oTfEiNx6+4sdXeanNHa0PsPwjGblHbMr09T prsQ== X-Gm-Message-State: APjAAAVDSNwqpCY9eBtXWj13LoPJJoKaY0sJeNa4CwQDViEkgoE4Rb94 TT5Tm4r+GRVQj+R7LxVhG1jwmg== X-Received: by 2002:a2e:7816:: with SMTP id t22mr52552757ljc.161.1578058010531; Fri, 03 Jan 2020 05:26:50 -0800 (PST) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id h24sm24490515ljl.80.2020.01.03.05.26.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2020 05:26:49 -0800 (PST) Received: by box.localdomain (Postfix, from userid 1000) id A7B40100741; Fri, 3 Jan 2020 16:26:50 +0300 (+03) Date: Fri, 3 Jan 2020 16:26:50 +0300 From: "Kirill A. Shutemov" To: Wei Yang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, willy@infradead.org Subject: Re: [Patch v2] mm/rmap.c: split huge pmd when it really is Message-ID: <20200103132650.jlyd37k6fcvycmy7@box> References: <20191223222856.7189-1-richardw.yang@linux.intel.com> <20200103071846.GA16057@richard> <20200103130554.GA20078@richard> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200103130554.GA20078@richard> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 03, 2020 at 09:05:54PM +0800, Wei Yang wrote: > On Fri, Jan 03, 2020 at 03:18:46PM +0800, Wei Yang wrote: > >On Tue, Dec 24, 2019 at 06:28:56AM +0800, Wei Yang wrote: > >>When page is not NULL, function is called by try_to_unmap_one() with > >>TTU_SPLIT_HUGE_PMD set. There are two cases to call try_to_unmap_one() > >>with TTU_SPLIT_HUGE_PMD set: > >> > >> * unmap_page() > >> * shrink_page_list() > >> > >>In both case, the page passed to try_to_unmap_one() is PageHead() of the > >>THP. If this page's mapping address in process is not HPAGE_PMD_SIZE > >>aligned, this means the THP is not mapped as PMD THP in this process. > >>This could happen when we do mremap() a PMD size range to an un-aligned > >>address. > >> > >>Currently, this case is handled by following check in __split_huge_pmd() > >>luckily. > >> > >> page != pmd_page(*pmd) > >> > >>This patch checks the address to skip some work. > > > >I am sorry to forget address Kirill's comment in 1st version. > > > >The first one is the performance difference after this change for a PTE > >mappged THP. > > > >Here is the result:(in cycle) > > > > Before Patched > > > > 963 195 > > 988 40 > > 895 78 > > > >Average 948 104 > > > >So the change reduced 90% time for function split_huge_pmd_address(). Right. But do we have a scenario, where the performance of split_huge_pmd_address() matters? I mean, it it called as part of rmap walk, attempt to split huge PMD where we don't have huge PMD should be within noise. > >For the 2nd comment, the vma check. Let me take a further look to analysis. > > > >Thanks for Kirill's suggestion. > > > > For 2nd comment, check vma could hold huge page. > > You mean do this check ? > > vma->vm_start <= address && vma->vm_end >= address + HPAGE_PMD_SIZE > > This happens after munmap a partial of the THP range? After doing so, we can > skip split_pmd for this case. Okay, you are right. This kind of check would not be safe as we split_huge_pmd_address() after adjusting VMA with expectation of splitting PMD on boundary of the VMA. -- Kirill A. Shutemov