Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2951761imm; Thu, 24 May 2018 19:45:51 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqKhdQb9qJxM4tNV5ULXa5efggAyssQ5wSPuKrdX98f7Gt/fE2GZNlHKhHrSZQw3JFUd14R X-Received: by 2002:a17:902:6b09:: with SMTP id o9-v6mr651495plk.256.1527216351294; Thu, 24 May 2018 19:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216351; cv=none; d=google.com; s=arc-20160816; b=XNvqkRGm6glVtCHzeBlceXLuYy9UzynpE71ieVdsBBfyZO14UTKBEc6IwyMWr2MnGW qwyXFOe3mMQmnv+E0zHlVz+2EdHWsGwC+eO2NJEaRE/dTtCbGDZ8pekM3ekT0Jm0VZAN iq2aBQDWtzEgJUCAhXLUTTLTAmVQrX/kXY9uJT8/XFLkp6FDrGyUzGkCZDQzKlinJnj1 gB2D59VVAiWTfNqlXDNWogvTqr5DexrGBnClqFrxzBJql5m8ReuGYJU/3xWeHNM6mSBI cvMxFYccxvH7tmxpxHyo8cG/swUq/cELY/bwjH0LmrbYfNardUV0t7jSjWmklOpEx45O iyBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=OEQE+nqn5k0wzFMJb8yI1JP2euW2UF+lLLiZRjh9R3k=; b=q022E+T/Q0Zs6MWhBFCwEKiSqYy4c1wf66Z+yO88ZDRqtKgvLLwB4K5uWJu+uM3xK/ rHCNxAvMC1Pn8O2z3P5eodW6lxVEJ+L2BBZXMYHBn4ZeyDtBuHAw3mGtCxNWrDkCXGCL 4boycghnLitKlC9LZ2FKutWOJMdpiUlWq1B7F0N5AU/OLAHgtdD3D5NrS2Q1aVpXk5Xg nVaYIEgOFddA84ySBCYmW+z2zVHZC0c+BBmDFMeBWeeHWSTUGA/wJL9kBYM0tv8Ik9yO IG89x/sLJO7L2HtDmmaS4VAzucNeM2gG6W0tgX8CljWc6mQ1WLu7XhWbSxisx1s6CIaP xqsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=p1IrFO1B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k17-v6si22445701pfj.310.2018.05.24.19.45.37; Thu, 24 May 2018 19:45:51 -0700 (PDT) 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=@oracle.com header.s=corp-2017-10-26 header.b=p1IrFO1B; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034738AbeEXW2O (ORCPT + 99 others); Thu, 24 May 2018 18:28:14 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37646 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033218AbeEXW2N (ORCPT ); Thu, 24 May 2018 18:28:13 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4OMLVAs167347; Thu, 24 May 2018 22:27:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2017-10-26; bh=OEQE+nqn5k0wzFMJb8yI1JP2euW2UF+lLLiZRjh9R3k=; b=p1IrFO1BO/7D+bMwXMmB94BU1OK4Im3oNbrYCGw/feu10YAexcGk7ZosBHYXcF2R3FhD Fggqf71qQn3sf174ZgSKc/GTKxdQApeHP2C069F28FtKVSNmGnwIodc+8BZr4m9ze0Fg vveLnzEbu5+kCDn9cT5epO6eVLix7xPZT9Kuz4t47ur84KSWUyFYheiIo6PWHJt5cF6T 8YulA1pMG80lov3ZsXVnrjI9t24dUiM4YmPEXpUs1z70K7fGaW+LhNvzU+F7Hl66ge1L +Ot0Y/hCSnCc2WJYO2W9+6YhsHSwfQaxOCKvCpXvxX5ym2TDqnYVChG8dQKq5nN4b7KQ 2w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2j62sw8w14-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 22:27:36 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4OMRajl010712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 22:27:36 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w4OMRY9R014847; Thu, 24 May 2018 22:27:34 GMT Received: from [192.168.1.164] (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 May 2018 15:27:34 -0700 Subject: Re: [PATCH -V2 -mm 4/4] mm, hugetlbfs: Pass fault address to cow handler To: "Huang, Ying" , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Michal Hocko , David Rientjes , Andrea Arcangeli , "Kirill A. Shutemov" , Andi Kleen , Jan Kara , Matthew Wilcox , Hugh Dickins , Minchan Kim , Shaohua Li , Christopher Lameter , "Aneesh Kumar K.V" , Punit Agrawal , Anshuman Khandual References: <20180524005851.4079-1-ying.huang@intel.com> <20180524005851.4079-5-ying.huang@intel.com> From: Mike Kravetz Message-ID: Date: Thu, 24 May 2018 15:27:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180524005851.4079-5-ying.huang@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8903 signatures=668700 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1805240253 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/23/2018 05:58 PM, Huang, Ying wrote: > From: Huang Ying > > This is to take better advantage of the general huge page copying > optimization. Where, the target subpage will be copied last to avoid > the cache lines of target subpage to be evicted when copying other > subpages. This works better if the address of the target subpage is > available when copying huge page. So hugetlbfs page fault handlers > are changed to pass that information to hugetlb_cow(). This will > benefit workloads which don't access the begin of the hugetlbfs huge > page after the page fault under heavy cache contention. > > Signed-off-by: "Huang, Ying" Reviewed-by: Mike Kravetz -- Mike Kravetz > Cc: Mike Kravetz > Cc: Michal Hocko > Cc: David Rientjes > Cc: Andrea Arcangeli > Cc: "Kirill A. Shutemov" > Cc: Andi Kleen > Cc: Jan Kara > Cc: Matthew Wilcox > Cc: Hugh Dickins > Cc: Minchan Kim > Cc: Shaohua Li > Cc: Christopher Lameter > Cc: "Aneesh Kumar K.V" > Cc: Punit Agrawal > Cc: Anshuman Khandual > --- > mm/hugetlb.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index ad3bec2ed269..1df974af34c1 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -3500,7 +3500,7 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma, > * Keep the pte_same checks anyway to make transition from the mutex easier. > */ > static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > - unsigned long haddr, pte_t *ptep, > + unsigned long address, pte_t *ptep, > struct page *pagecache_page, spinlock_t *ptl) > { > pte_t pte; > @@ -3509,6 +3509,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > int ret = 0, outside_reserve = 0; > unsigned long mmun_start; /* For mmu_notifiers */ > unsigned long mmun_end; /* For mmu_notifiers */ > + unsigned long haddr = address & huge_page_mask(h); > > pte = huge_ptep_get(ptep); > old_page = pte_page(pte); > @@ -3583,7 +3584,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > goto out_release_all; > } > > - copy_user_huge_page(new_page, old_page, haddr, vma, > + copy_user_huge_page(new_page, old_page, address, vma, > pages_per_huge_page(h)); > __SetPageUptodate(new_page); > set_page_huge_active(new_page); > @@ -3817,7 +3818,7 @@ static int hugetlb_no_page(struct mm_struct *mm, struct vm_area_struct *vma, > hugetlb_count_add(pages_per_huge_page(h), mm); > if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) { > /* Optimization, do the COW without a second fault */ > - ret = hugetlb_cow(mm, vma, haddr, ptep, page, ptl); > + ret = hugetlb_cow(mm, vma, address, ptep, page, ptl); > } > > spin_unlock(ptl); > @@ -3971,7 +3972,7 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, > > if (flags & FAULT_FLAG_WRITE) { > if (!huge_pte_write(entry)) { > - ret = hugetlb_cow(mm, vma, haddr, ptep, > + ret = hugetlb_cow(mm, vma, address, ptep, > pagecache_page, ptl); > goto out_put_page; > } >