Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2950887imm; Thu, 24 May 2018 19:44:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrjgHfnxBtZR/egclRlrZVMPpXBQxDbR34R6q5PzITHgybr0ByKfV0I7GGkRTYx8gU2+qSX X-Received: by 2002:a17:902:5e3:: with SMTP id f90-v6mr620232plf.175.1527216288643; Thu, 24 May 2018 19:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527216288; cv=none; d=google.com; s=arc-20160816; b=WfyOxB9jYUoG7S0zbQRk+MCQrXj1HyO60tSD5pYJZOYhiKOrgigKnB3//srIKnqI9V PGVFUYBy9tjIj1YLjfMv3ZIb1jlg3e+xUlkFhWQ4FIlEn8bIIccgTttPfJspNnODEvYR +qs9T/vOb58ELdgs2ehpv111lX2ZewB3fr+3k1IhVe1TwRba5+eR42hjtzEUJ+/eyXlW HrZNf9O8PFQ5ir8szaYRfaNrHYMv1X1nNAoKW+Hd1qySdzg2S7foktulEw+eKSpr2Kha O8rUtYMnUtE+Vbe+hMiY0j+0IEy6pjHYCJJ8I8wywBIuY6x5a04jpaz4mvX7rB7P0F+U 37HQ== 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=42S1IQUg3YiHrbV98M4pVKiEALS9fmBawT2rtEcjmuE=; b=KWi+x8owD9hN+QFPd1CNHs8NT6D3ARvgMBeQk5iko4aoTncPTYOj/Q3xvlbI+8V4sS C40v3BSHi7gkVeWvBlGTSdu1PBcEwkeubaskvKpGoVYHFDfC7EsDHJsD3oeHKKk/36+X XwpM6n5d3i/OTz1AvRkQRDAqJuktwm7i3qmmFhhCKkfiqndzYnqmBVZpsKH8GVadOidd DEfOhe7qW/cNvbybrceG6IC0kmF8rkzoRmGwYaSk82Aja3eeRHgraF7Lj6dRskXrIGc9 WQdurKQv8EzIwg9duxLUG+1eCJy1Gpy/5C3kk6MRkM3rqMTr79hQuDaflLJf1fpGZ3lq Zg4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=CDeKsacR; 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 e125-v6si12689873pgc.128.2018.05.24.19.44.34; Thu, 24 May 2018 19:44:48 -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=CDeKsacR; 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 S1161495AbeEXVnC (ORCPT + 99 others); Thu, 24 May 2018 17:43:02 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:56590 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161485AbeEXVnA (ORCPT ); Thu, 24 May 2018 17:43:00 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4OLec36031547; Thu, 24 May 2018 21:42:19 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=42S1IQUg3YiHrbV98M4pVKiEALS9fmBawT2rtEcjmuE=; b=CDeKsacR2CmHtUCbV6ZDY3XbO72NPu8/muryXN7DeMB/q/9CsNZZwYxV3wsV6i9mnhEB SitjwXAXpn0VNIv8DAd7iJDpexwaYoj06cyfueBunotllv//+lz3nW2PlbLmz07X5TAV wdF2q6/aSNOmP8uv6nsqLLYqE+w+smz9Me4YjyJZhQua8ggSJqzzKdNj+Zb0hdXV4COq uCu7Jt1yT5YrOr06M1l4uN6NBFSmufLDZgprvI0VOU5M9YEswxdfJ3RtXKwa1m6MkU3D fmRSqDuOBXD7N4IJfOLN+Z4VM4pvnaTWG/p1J/SjmjBVtCQrdGEyIaHXpqQ/L+31lXid 4A== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2j62sw8ryc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 21:42:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w4OLgH3K012525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 May 2018 21:42:17 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w4OLgFQL010479; Thu, 24 May 2018 21:42:15 GMT Received: from [192.168.1.164] (/50.38.38.67) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 24 May 2018 14:42:15 -0700 Subject: Re: [PATCH -V2 -mm 3/4] mm, hugetlbfs: Rename address to haddr in hugetlb_cow() To: "Huang, Ying" , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, 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 , Michal Hocko References: <20180524005851.4079-1-ying.huang@intel.com> <20180524005851.4079-4-ying.huang@intel.com> From: Mike Kravetz Message-ID: <4e569170-9f4e-eb12-d10d-fe9b7fcdfc9d@oracle.com> Date: Thu, 24 May 2018 14:42:13 -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-4-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-1805240245 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 > > To take better advantage of general huge page copying optimization, > the target subpage address will be passed to hugetlb_cow(), then > copy_user_huge_page(). So we will use both target subpage address and > huge page size aligned address in hugetlb_cow(). To distinguish > between them, "haddr" is used for huge page size aligned address to be > consistent with Transparent Huge Page naming convention. > > Now, only huge page size aligned address is used in hugetlb_cow(), so > the "address" is renamed to "haddr" in hugetlb_cow() in this patch. > Next patch will use target subpage address in hugetlb_cow() too. > > The patch is just code cleanup without any functionality changes. > > Signed-off-by: "Huang, Ying" > Suggested-by: Mike Kravetz > Suggested-by: Michal Hocko I believe Kirill may have been the one who suggested using haddr to be consistent with usage in huge_memory.c. > 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 | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 696befffe6f7..ad3bec2ed269 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 address, pte_t *ptep, > + unsigned long haddr, pte_t *ptep, > struct page *pagecache_page, spinlock_t *ptl) > { > pte_t pte; > @@ -3518,7 +3518,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > * and just make the page writable */ > if (page_mapcount(old_page) == 1 && PageAnon(old_page)) { > page_move_anon_rmap(old_page, vma); > - set_huge_ptep_writable(vma, address, ptep); > + set_huge_ptep_writable(vma, haddr, ptep); > return 0; > } > > @@ -3542,7 +3542,7 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > * be acquired again before returning to the caller, as expected. > */ > spin_unlock(ptl); > - new_page = alloc_huge_page(vma, address, outside_reserve); > + new_page = alloc_huge_page(vma, haddr, outside_reserve); > > if (IS_ERR(new_page)) { > /* > @@ -3555,11 +3555,10 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > if (outside_reserve) { > put_page(old_page); > BUG_ON(huge_pte_none(pte)); > - unmap_ref_private(mm, vma, old_page, address); > + unmap_ref_private(mm, vma, old_page, haddr); > BUG_ON(huge_pte_none(pte)); > spin_lock(ptl); > - ptep = huge_pte_offset(mm, address & huge_page_mask(h), > - huge_page_size(h)); > + ptep = huge_pte_offset(mm, haddr, huge_page_size(h)); Ha! The name change points out an obviously unnecessary conversion in the existing code. Yes, hugetlb_cow is always passed a hpage aligned address today. > if (likely(ptep && > pte_same(huge_ptep_get(ptep), pte))) > goto retry_avoidcopy; > @@ -3584,12 +3583,12 @@ 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, address, vma, > + copy_user_huge_page(new_page, old_page, haddr, vma, > pages_per_huge_page(h)); > __SetPageUptodate(new_page); > set_page_huge_active(new_page); > > - mmun_start = address & huge_page_mask(h); > + mmun_start = haddr; And another one. > mmun_end = mmun_start + huge_page_size(h); > mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); > > @@ -3598,25 +3597,24 @@ static int hugetlb_cow(struct mm_struct *mm, struct vm_area_struct *vma, > * before the page tables are altered > */ > spin_lock(ptl); > - ptep = huge_pte_offset(mm, address & huge_page_mask(h), > - huge_page_size(h)); > + ptep = huge_pte_offset(mm, haddr, huge_page_size(h)); And yet another. Reviewed-by: Mike Kravetz -- Mike Kravetz > if (likely(ptep && pte_same(huge_ptep_get(ptep), pte))) { > ClearPagePrivate(new_page); > > /* Break COW */ > - huge_ptep_clear_flush(vma, address, ptep); > + huge_ptep_clear_flush(vma, haddr, ptep); > mmu_notifier_invalidate_range(mm, mmun_start, mmun_end); > - set_huge_pte_at(mm, address, ptep, > + set_huge_pte_at(mm, haddr, ptep, > make_huge_pte(vma, new_page, 1)); > page_remove_rmap(old_page, true); > - hugepage_add_new_anon_rmap(new_page, vma, address); > + hugepage_add_new_anon_rmap(new_page, vma, haddr); > /* Make the old page be freed below */ > new_page = old_page; > } > spin_unlock(ptl); > mmu_notifier_invalidate_range_end(mm, mmun_start, mmun_end); > out_release_all: > - restore_reserve_on_error(h, vma, address, new_page); > + restore_reserve_on_error(h, vma, haddr, new_page); > put_page(new_page); > out_release_old: > put_page(old_page); >