From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 38F76C47404 for ; Mon, 7 Oct 2019 22:55:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ECB5020867 for ; Mon, 7 Oct 2019 22:55:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="rQKJzyzl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ECB5020867 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 853308E0005; Mon, 7 Oct 2019 18:55:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 803478E0003; Mon, 7 Oct 2019 18:55:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F1928E0005; Mon, 7 Oct 2019 18:55:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 48AD78E0003 for ; Mon, 7 Oct 2019 18:55:33 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id DD09D824CA3F for ; Mon, 7 Oct 2019 22:55:32 +0000 (UTC) X-FDA: 76018496904.24.fifth01_87ac46cfef314 X-HE-Tag: fifth01_87ac46cfef314 X-Filterd-Recvd-Size: 5934 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Oct 2019 22:55:32 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x97MrinP149048; Mon, 7 Oct 2019 22:55:30 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-2019-08-05; bh=0pS9Gdmw9RfkoyyDG7jIHELM+WI3VzZVpWkHVP/VRDM=; b=rQKJzyzl4Fx6gqE0jtZyrkgWv9zj5I3JrGwPG+gGV4s/C4K6udKRa6u0divRkUy73mIP x4roBBsJ7QoOu1Cc9ZIP9uGgHjpS1OvCh4IKgKUcOfj5atBH/JkkFqi+KGSHJLt0NzeP UqXgeMN/TFsFBpkGKlzC2MLJRGzm2zpKdAwfFPAbPuHq706xDbfWSwVZ3YNGEMrkaGji SVb4euILfFLwUZnbgHnFj6EraRtIju6A26BM0rS29XgknmL5EuwzUj/UuPMz4ZDVTcZj I5nOCfNvtYtAvA1h4u90Xl2IxeqjUhrIjX9APZvWS8JLmKnRWAW5JnbAUsVRJY7raKKq TA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2vejku9uv7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Oct 2019 22:55:29 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x97MrhGl173972; Mon, 7 Oct 2019 22:55:29 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2vg1yut8sg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Oct 2019 22:55:28 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x97MtRjC018406; Mon, 7 Oct 2019 22:55:27 GMT Received: from [192.168.1.222] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Oct 2019 15:55:27 -0700 Subject: Re: [PATCH v2 1/3] userfaultfd: use vma_pagesize for all huge page size calculation To: Wei Yang , Andrew Morton Cc: aarcange@redhat.com, hughd@google.com, linux-mm@kvack.org References: <20190927070032.2129-1-richardw.yang@linux.intel.com> <20190927151033.aad57472652a0b3a6948df6e@linux-foundation.org> <20190929004507.GA11770@richard> From: Mike Kravetz Message-ID: Date: Mon, 7 Oct 2019 15:55:21 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 MIME-Version: 1.0 In-Reply-To: <20190929004507.GA11770@richard> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9403 signatures=668684 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-1908290000 definitions=main-1910070204 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9403 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910070204 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: On 9/28/19 5:45 PM, Wei Yang wrote: > On Fri, Sep 27, 2019 at 03:10:33PM -0700, Andrew Morton wrote: >> On Fri, 27 Sep 2019 15:00:30 +0800 Wei Yang wrote: >> >>> In function __mcopy_atomic_hugetlb, we use two variables to deal with >>> huge page size: vma_hpagesize and huge_page_size. >>> >>> Since they are the same, it is not necessary to use two different >>> mechanism. This patch makes it consistent by all using vma_hpagesize. >>> >>> --- a/mm/userfaultfd.c >>> +++ b/mm/userfaultfd.c >>> @@ -262,7 +262,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, >>> pte_t dst_pteval; >>> >>> BUG_ON(dst_addr >= dst_start + len); >>> - VM_BUG_ON(dst_addr & ~huge_page_mask(h)); >>> + VM_BUG_ON(dst_addr & (vma_hpagesize - 1)); >>> >>> /* >>> * Serialize via hugetlb_fault_mutex >>> @@ -273,7 +273,7 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, >>> mutex_lock(&hugetlb_fault_mutex_table[hash]); >>> >>> err = -ENOMEM; >>> - dst_pte = huge_pte_alloc(dst_mm, dst_addr, huge_page_size(h)); >>> + dst_pte = huge_pte_alloc(dst_mm, dst_addr, vma_hpagesize); >>> if (!dst_pte) { >>> mutex_unlock(&hugetlb_fault_mutex_table[hash]); >>> goto out_unlock; >>> @@ -300,7 +300,8 @@ static __always_inline ssize_t __mcopy_atomic_hugetlb(struct mm_struct *dst_mm, >>> >>> err = copy_huge_page_from_user(page, >>> (const void __user *)src_addr, >>> - pages_per_huge_page(h), true); >>> + vma_hpagesize / PAGE_SIZE, >>> + true); >>> if (unlikely(err)) { >>> err = -EFAULT; >>> goto out; >> >> Looks right. >> >> We could go ahead and remove local variable `h', given that >> hugetlb_fault_mutex_hash() doesn't actually use its first arg.. > > Oops, haven't imagine h is not used in the function. > > > Any historical reason to pass h in hugetlb_fault_mutex_hash()? Neither these > two definition use it. See 1b426bac66e6 ("hugetlb: use same fault hash key for shared and private mappings"). Prior to that change, the hash key for private mappings was created by: key[0] = (unsigned long) mm; key[1] = address >> huge_page_shift(h); When removing that code, I should have removed 'h'. -- Mike Kravetz