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.5 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 DE7B1C433DB for ; Wed, 13 Jan 2021 23:28:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 73C7F23382 for ; Wed, 13 Jan 2021 23:28:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 73C7F23382 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 699368D009D; Wed, 13 Jan 2021 18:28:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 621808D008E; Wed, 13 Jan 2021 18:28:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C3448D009D; Wed, 13 Jan 2021 18:28:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 309FC8D008E for ; Wed, 13 Jan 2021 18:28:01 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DB3481F1A for ; Wed, 13 Jan 2021 23:28:00 +0000 (UTC) X-FDA: 77702341920.08.dirt03_480b23027522 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id C40F81819E76F for ; Wed, 13 Jan 2021 23:28:00 +0000 (UTC) X-HE-Tag: dirt03_480b23027522 X-Filterd-Recvd-Size: 6948 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 23:27:59 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10DNKDqt129605; Wed, 13 Jan 2021 23:27:40 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=8nhKPkft+xGSN2PyfovUj+WldoTS6Xrgzrpgzt8e86w=; b=v7VHxdffCnMUVJhbIDNMJ1Qfr5ZAv7MJdvUqMKSTY+fc5MnCU2qmENSBaH8P4invXRwW CjIeWdV+IZ19P8Yx/8a+NO9hRB9DQQZRjQFBn2fsKrcf068dC0C204nl2J69hC/DpG5m btY56Kg9qqZp5c7bVJKfehNq6b8PkiJiQZ27EnraZnXgsmPRU3cLgL6VH2kNH/baSBXf pUW/+fOVRL+Z/+/P7sXoz3ETcHTEAKbSCWt/PH0fQLKLaAgQD2Cx7bpwlqcNqRRJKOQA fZT710NseYt6navd9ZlhGqNV0SUVFZo1UCHLye1wpHjSeRQJliDze4X0uDH+/bI2mZVW XA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 360kcyx1v3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jan 2021 23:27:40 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10DNKBki145808; Wed, 13 Jan 2021 23:27:39 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 360kf1dy53-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Jan 2021 23:27:39 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 10DNRZCb002460; Wed, 13 Jan 2021 23:27:35 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Jan 2021 15:27:34 -0800 Subject: Re: [External] Re: [PATCH v12 04/13] mm/hugetlb: Free the vmemmap pages associated with each HugeTLB page To: Oscar Salvador , Muchun Song Cc: Jonathan Corbet , Thomas Gleixner , mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com, dave.hansen@linux.intel.com, luto@kernel.org, Peter Zijlstra , viro@zeniv.linux.org.uk, Andrew Morton , paulmck@kernel.org, mchehab+huawei@kernel.org, pawan.kumar.gupta@linux.intel.com, Randy Dunlap , oneukum@suse.com, anshuman.khandual@arm.com, jroedel@suse.de, Mina Almasry , David Rientjes , Matthew Wilcox , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel References: <20210106141931.73931-1-songmuchun@bytedance.com> <20210106141931.73931-5-songmuchun@bytedance.com> <20210112080453.GA10895@linux> <20210113092028.GB24816@linux> From: Mike Kravetz Message-ID: Date: Wed, 13 Jan 2021 15:27:31 -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: <20210113092028.GB24816@linux> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9863 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 bulkscore=0 malwarescore=0 suspectscore=0 adultscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101130141 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9863 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 impostorscore=0 bulkscore=0 adultscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101130141 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/13/21 1:20 AM, Oscar Salvador wrote: > On Tue, Jan 12, 2021 at 07:33:33PM +0800, Muchun Song wrote: >>> It seems a bit odd to only pass "start" for the BUG_ON. >>> Also, I kind of dislike the "addr += PAGE_SIZE" in vmemmap_pte_range. >>> >>> I wonder if adding a ".remap_start_addr" would make more sense. >>> And adding it here with the vmemmap_remap_walk init. >> >> How about introducing a new function which aims to get the reuse >> page? In this case, we can drop the BUG_ON() and "addr += PAGE_SIZE" >> which is in vmemmap_pte_range. The vmemmap_remap_range only >> does the remapping. > > How would that look? > It might be good, dunno, but the point is, we should try to make the rules as > simple as possible, dropping weird assumptions. > > Callers of vmemmap_remap_free should know three things: > > - Range to be remapped > - Addr to remap to > - Current implemantion needs addr to be remap to to be part of the complete > range > > right? And, current implementation needs must have remap addr be the first in the complete range. This is just because of the way the page tables are walked for remapping. The remap/reuse page must be found first so that the following pages can be remapped to it. That implementation seems to be the 'most efficient' for hugetlb pages where we want vmemmap pages n+3 and beyond mapped to n+2. In a more general purpose vmemmap_remap_free implementation, the reuse/remap address would not necessarily need to be related to the range. However, this would require a separate page table walk/validation for the reuse address independent of the range. This may be what Muchun was proposing for 'a new function which aims to get the reuse page'. IMO, the decision on how to implement depends on the intended use case. - If this is going to be hugetlb only (or perhaps generic huge page only) functionality, then I am OK with an efficient implementation that has some restrictions. - If we see this being used for more general purpose remapping, then we should go with a more general purpose implementation. Again, just my opinion. -- Mike Kravetz