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=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham 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 ACF11C433E9 for ; Mon, 4 Jan 2021 18:59:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 420FA2068D for ; Mon, 4 Jan 2021 18:59:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 420FA2068D 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 4C7D48D001F; Mon, 4 Jan 2021 13:59:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 427278D001C; Mon, 4 Jan 2021 13:59:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 315928D001F; Mon, 4 Jan 2021 13:59:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 178448D001C for ; Mon, 4 Jan 2021 13:59:13 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C44661EE6 for ; Mon, 4 Jan 2021 18:59:12 +0000 (UTC) X-FDA: 77669005344.21.sea75_4c0716e274d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 70BF4180442C4 for ; Mon, 4 Jan 2021 18:59:12 +0000 (UTC) X-HE-Tag: sea75_4c0716e274d2 X-Filterd-Recvd-Size: 5358 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 4 Jan 2021 18:59:11 +0000 (UTC) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 104IjJQ3114667; Mon, 4 Jan 2021 18:59:09 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=2ytxwKpW1OSG60ARd+qKhPLLDUgXi6eLlsN3Exb+dco=; b=P72lZcv4dj4X2Z43QpDY9sVzx4nJvaxxpbJ8zA0H4QDiRsxRPPJRYJUm6oLLG8t0AGcw Cnpi+7Y7B16+/LYLjzT4cinzjx5IBO811Ch1NK9GfxxWG0EjWo9JSy/HYNh34BdoNPip QtGwPs/Hl2cIQ7Fkwzs2Mg4sd4NEnkpEo3pBAIOzayCWIjpdoNfP6qgek7+kHCTqc/cG 3lpv0V0DzNZiTCwz1/rVMrEGrfOhMuGxTfaM92l1C4iuRDsZxC0djCxC1H7ZzuU2jM/S i0asFrGsc3J1Y8dtfA5HSWguU36igTFr70v0UOcKaZTM95gI2GsQhQpDQlf60Vsogi2l 7w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 35tg8qwr74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 04 Jan 2021 18:59:08 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 104IjIDf090248; Mon, 4 Jan 2021 18:59:08 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3030.oracle.com with ESMTP id 35v2axjwth-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Jan 2021 18:59:08 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 104Ix7fG010612; Mon, 4 Jan 2021 18:59:07 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Jan 2021 10:59:07 -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> From: Mike Kravetz Message-ID: <6aaf1556-33e1-c9cd-5f41-11cd96c014f4@oracle.com> Date: Mon, 4 Jan 2021 10:59:05 -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: <1617a471-b837-a868-67a0-0b0f17cb3748@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=9854 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 malwarescore=0 adultscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101040120 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9854 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 phishscore=0 bulkscore=0 spamscore=0 impostorscore=0 suspectscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101040120 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/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. -- Mike Kravetz >> If that is the case, then how about just adding the following to your patch? >> I think this is simpler and faster than the 'range_in_vma' checking I proposed. >> >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c >> index 49990c0a02a3..716d1e58a7ae 100644 >> --- a/mm/hugetlb.c >> +++ b/mm/hugetlb.c >> @@ -5261,7 +5261,9 @@ void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, >> { >> unsigned long a_start, a_end; >> - if (!(vma->vm_flags & VM_MAYSHARE)) >> + /* Quick check for vma capable of pmd sharing */ >> + if (!(vma->vm_flags & VM_MAYSHARE) || >> + (vma->vm_start - vma->vm_end) < PUD_SIZE) >> return; >> /* Extend the range to be PUD aligned for a worst case scenario */ > > Your suggestion is good, we are able to simplify the code a bit, with > less comparison, and maybe easier to follow. I will send a new patch to > review.