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 1F69CC32771 for ; Thu, 16 Jan 2020 00:40:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D5DA3222C3 for ; Thu, 16 Jan 2020 00:40:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="DS68sV/1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D5DA3222C3 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 6F4AF8E0015; Wed, 15 Jan 2020 19:40:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6A5108E0003; Wed, 15 Jan 2020 19:40:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5937C8E0015; Wed, 15 Jan 2020 19:40:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4500C8E0003 for ; Wed, 15 Jan 2020 19:40:36 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id D984E181AEF07 for ; Thu, 16 Jan 2020 00:40:35 +0000 (UTC) X-FDA: 76381641630.11.trail67_2240431f4c208 X-HE-Tag: trail67_2240431f4c208 X-Filterd-Recvd-Size: 5824 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Thu, 16 Jan 2020 00:40:35 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 00G0dB7v174282; Thu, 16 Jan 2020 00:40:31 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=fev9WoB1nf5eBXbvmGzN+SkOpapAxYKjJjZ0c3TseZ8=; b=DS68sV/1izOcGHtFB+HjSKeBngReNzcYZdTbhykJabOniUbKPvS/hR94v+05sZOVl4Kg rKqhQMCYt5nASuFXzdNNFuOCTZbh9ZIgeGl/ojCxDmC4QJKsdb2jtSq2D9N9MysQj0xT xMSeSoLj4HKiPYh5DXvNo86h9N3Qe4gBLcG7C0DcTAsLnYPOEVwiHwD+vkeZ5Cld1xGL MlABU49paQC0Ag+6MeejQrbsyu+//98ohyOykl5hT4uWk56D8nAtV+clc/2HHUDukfDH mXR+/KnLYjMs0Arf83dnI9+4wA1htFeYBkEVys8/yDYH0xSPUO6qF98n1dXRaQnOcC2p 8g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2xf73tyf37-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 00:40:31 +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 00G0cNXr037201; Thu, 16 Jan 2020 00:40:31 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2xj61kncrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Jan 2020 00:40:30 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 00G0eTHK013582; Thu, 16 Jan 2020 00:40:29 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 15 Jan 2020 16:40:28 -0800 Subject: Re: [PATCH v4] mm/page_vma_mapped.c: Explicitly compare pfn for normal, hugetlbfs and THP page To: Michal Hocko , Li Xinhai Cc: "linux-mm@kvack.org" , akpm , "kirill.shutemov" References: <1578737885-8890-1-git-send-email-lixinhai.lxh@gmail.com> <20200114092545.GF19428@dhcp22.suse.cz> <202001142147485028116@gmail.com> <20200115093148.GZ19428@dhcp22.suse.cz> From: Mike Kravetz Message-ID: <986d0f55-ae54-f3af-0d50-3e3b6621a863@oracle.com> Date: Wed, 15 Jan 2020 16:40:26 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <20200115093148.GZ19428@dhcp22.suse.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9501 signatures=668685 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-1911140001 definitions=main-2001160002 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9501 signatures=668685 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-1911140001 definitions=main-2001160002 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/15/20 1:31 AM, Michal Hocko wrote: > On Tue 14-01-20 21:47:51, Li Xinhai wrote: >> On 2020-01-14 at 17:25 Michal Hocko wrote: >>> On Sat 11-01-20 10:18:05, Li Xinhai wrote: >>>> When check_pte, pfn of normal, hugetlbfs and THP page need be compared. >>>> The current implementation apply comparison as >>>> - normal 4K page: page_pfn <= pfn < page_pfn + 1 >>>> - hugetlbfs page: page_pfn <= pfn < page_pfn + HPAGE_PMD_NR >>>> - THP page: page_pfn <= pfn < page_pfn + HPAGE_PMD_NR >>>> in pfn_in_hpage. For hugetlbfs page, it should be >>>> page_pfn == pfn >>>> >>>> Now, change pfn_in_hpage to pfn_is_match to highlight that comparison >>>> is not only for THP and explicitly compare for these cases. >>> >>> Why is this important to do. I have asked and Mike had the same feeling >>> that the patch is missing any real justification. Why do we need this >>> change? It is great that you have dropped VM_BUG_ON btw. >>> >> I think it is important to make the code clear, as said, comparing hugetlbfs page >> in range page_pfn <= pfn < page_pfn + HPAGE_PMD_NR is confusion. > > I am sorry but I do not really see a big confusion here. It is probably > a matter of taste. If others consider this an improvement then I will > not stand in the way but I consider the justification insuficient for > merging. Perhaps I am confused, but the patch does update the check done for hugetlb pages. IIUC, previously there was no distinction between THP pages and hugetlb pages in the check. It is valid to pass in a sub- page of a THP page, but not that of a hugetlb page. I do not believe it is possible for existing code to pass in a sub-page of a hugetlb page. And, no one has ever seen this as an issue. This is why I was questioning the need for the patch. With all that said, the new code/check is better (more complete) than the original. It may not do anything for the current code base, but it 'could' catch potential errors in future code. Because of this, I do consider the code an improvement. Acked-by: Mike Kravetz -- Mike Kravetz