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=-7.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,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 4ED06C433E6 for ; Tue, 5 Jan 2021 18:21:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EDF0522D57 for ; Tue, 5 Jan 2021 18:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDF0522D57 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 3DB758D0092; Tue, 5 Jan 2021 13:21:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F8C58D006E; Tue, 5 Jan 2021 13:21:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14CDB8D0093; Tue, 5 Jan 2021 13:21:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id E98098D006E for ; Tue, 5 Jan 2021 13:21:04 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id B11303626 for ; Tue, 5 Jan 2021 18:21:04 +0000 (UTC) X-FDA: 77672538048.22.legs94_3a06579274db Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 8E23C18038E6A for ; Tue, 5 Jan 2021 18:21:04 +0000 (UTC) X-HE-Tag: legs94_3a06579274db X-Filterd-Recvd-Size: 6344 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Jan 2021 18:21:03 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 105IFaqf155237; Tue, 5 Jan 2021 18:21:02 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-2020-01-29; bh=5PH6ARc22jOXaKH+R37p/s4BpUjd9F6BDZ1uR2NuE7o=; b=z5MHqRsJz6xodZMor/y6TjEj93GrTNmLG4HkUv5YT6hU3ppv5Jj4hOp/fkNeHkNPYvNR XPAu10dNQwI9nF+V9wyIsB4bCxobM4EmYF9Ft4iyNJz4zdruN/bD6z8azbFrz98Cmk1G 0MClQso39KwRjpN4Bpkmz1wgs35t+vd9OwFR8JI+pd8eIgJhFkFBDInpyGU5ZyFhp2wr U+cResf5LJHN/3Fuffpe2isTRD5HNue34rVVwjdUlqreNqrkYzDba3XjcKlxDa7RvaHC q27zae/SMYxOsB1VSda8oFKMKjlmWcoQ4bFc2oFZaA7GfSiJWVR256q3YqwgSdhn8Jez dw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 35tebat69u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 05 Jan 2021 18:21:01 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 105IItwi126245; Tue, 5 Jan 2021 18:21:01 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 35uxnt0q6w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Jan 2021 18:21:00 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 105IKxRF002758; Tue, 5 Jan 2021 18:20:59 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 05 Jan 2021 10:20:59 -0800 Subject: Re: [PATCH] mm/hugetlb.c: fix unnecessary address expansion of pmd sharing To: Li Xinhai , linux-mm@kvack.org Cc: akpm@linux-foundation.org, Peter Xu References: <20201229042125.2663029-1-lixinhai.lxh@gmail.com> <2b6534f5-2ffa-6325-6af1-8c067ba9c0bc@oracle.com> <2d8a7726-b7fb-3dc8-e7bc-54a67d28db24@oracle.com> <2a95c320-4408-2603-f266-8e111a2f1620@gmail.com> <049fb8f0-73c8-b296-7670-7b60fdcc092a@oracle.com> <1617a471-b837-a868-67a0-0b0f17cb3748@gmail.com> <6aaf1556-33e1-c9cd-5f41-11cd96c014f4@oracle.com> <76585d60-f4d7-646e-6e45-2d68368561c4@gmail.com> From: Mike Kravetz Message-ID: <1d29c159-59be-add2-beea-8be6bd670941@oracle.com> Date: Tue, 5 Jan 2021 10:20:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <76585d60-f4d7-646e-6e45-2d68368561c4@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9855 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 spamscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101050107 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9855 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 priorityscore=1501 spamscore=0 mlxscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101050107 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 1/4/21 6:38 PM, Li Xinhai wrote: > > > On 1/5/21 10:10 AM, Li Xinhai wrote: >> >> >> On 1/5/21 2:59 AM, Mike Kravetz wrote: >>> On 1/3/21 11:10 PM, Li Xinhai wrote: >>>> >>>> >>>> On 1/4/21 11:55 AM, Mike Kravetz wrote: >>>>> I believe the only case where your patch produced incorrect results is >>>>> when the range was within a vma that was smaller than PUD_SIZE. Do you >>>>> agree? >>>>> >>>> Not exactly. We need to consider for vma which span at least one >>>> PUD_SIZE after align its vm_start and vm_end. >>>> >>> >>> I know that I provided an incorrect example again. Sorry (again)! >>> >>> Can you provide an example where adding the simple check for vma size less >>> than PUD_SIZE to your original patch will not work. The logic in your V2 >>> patch is correct. However, I am having a hard time finding a problem with >>> this simpler approach. >>> >> >> >> Thanks for checking. An example like this: >> (vm_start, vm_end) = (2G - 6M, 2G+8M), so this vma is bigger than >> PUD_SIZE, and the check for vma size bigger than PUD_SIZE will pass. >> >> With (start, end) = (2G-4M, 2G-2M), the previous patch will not adjust >> start(because adjust it from (2G-4M) to 1G will exceeding vm_start), but >> it will adjust end from (2G-2M) to 2G (because 2G still below vm_end). >> >> The adjustment of end is incorrect, because (2G-6M, 2G) range of vma >> is not allowed for PMD sharing(i.e., that range do not fully occupy >> PUD_SIZE). If we make the wrong adjustment, then we will unnecessarily >> impact to range (2G-2M, 2G). >> >> > sorry, the above example is not correct for vma size, update it as > below: > > (vm_start, vm_end) = (2G - 600M, 2G+800M), so this vma is bigger than > PUD_SIZE, and the check for vma size bigger than PUD_SIZE will pass. > > With (start, end) = (2G-4M, 2G-2M), the previous patch will not adjust > start(because adjust it from (2G-4M) to 1G will exceeding vm_start), but > it will adjust end from (2G-2M) to 2G (because 2G still below vm_end). > > The adjustment of end is incorrect, because (2G-600M, 2G) range of vma > is not allowed for PMD sharing(i.e., that range do not fully occupy > PUD_SIZE). If we make the wrong adjustment, then we will unnecessarily > impact to range (2G-2M, 2G). Thanks you for the example! This routine is conceptually simple, but for some reason there have been multiple problems in the implementation. -- Mike Kravetz