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=-6.3 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 845A9C4363A for ; Wed, 28 Oct 2020 23:44:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E8EDD207BC for ; Wed, 28 Oct 2020 23:44:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ujVTdN3a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8EDD207BC 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 602AD6B0062; Wed, 28 Oct 2020 19:44:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 565A26B0068; Wed, 28 Oct 2020 19:44:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42C7F6B006C; Wed, 28 Oct 2020 19:44:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 09DC76B0062 for ; Wed, 28 Oct 2020 19:44:39 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 999D41EE6 for ; Wed, 28 Oct 2020 23:44:39 +0000 (UTC) X-FDA: 77422966278.20.house61_530e24827288 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 7D06E180C07A3 for ; Wed, 28 Oct 2020 23:44:39 +0000 (UTC) X-HE-Tag: house61_530e24827288 X-Filterd-Recvd-Size: 7046 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 28 Oct 2020 23:44:38 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09SNaDvZ096206; Wed, 28 Oct 2020 23:44:23 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=/1wXhSK1jawzXDWDiFn4sD8tOMsMcHZuwRWttfEpsBo=; b=ujVTdN3aiA8l72vkEvBqXJykL6YBnFEbP3iBuB+HsFwFVzcgAGCImhQty8poCRjD3EIH 5xFGOhihKgUnWcCjl+zTsnsnp6amXl3XFrbCxRZ+CoJYIdIVVo3S5RT6hDoenWyVyMwg ZHbkw5sYK4JMRKwl4iL+pviAEuWU+hcpFs+p23pocEtylwG4tg/NgXDNbXsc7vG1g402 N/Ce6Bw77owwFFo0Ny2+vdjRO3B+qLeaoJaf5fgeks2dC7KmEJyiu4XD624ARPz4eF3k /2ygaiUnxd8+rVRsMb0FsiLNQMfwb9urmySe8sDphsYYEDwa3DGnsTD4kuoWxX19KjR7 Yw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 34dgm47tm3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Oct 2020 23:44:23 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 09SNe76g041534; Wed, 28 Oct 2020 23:42:22 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 34cx5ywkq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Oct 2020 23:42:22 +0000 Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 09SNgGbb012295; Wed, 28 Oct 2020 23:42:16 GMT Received: from [192.168.2.112] (/50.38.35.18) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Oct 2020 16:42:15 -0700 Subject: Re: [External] Re: [PATCH v2 05/19] mm/hugetlb: Introduce pgtable allocation/freeing helpers To: 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 , Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel References: <20201026145114.59424-1-songmuchun@bytedance.com> <20201026145114.59424-6-songmuchun@bytedance.com> <81a7a7f0-fe0e-42e4-8de0-9092b033addc@oracle.com> From: Mike Kravetz Message-ID: Date: Wed, 28 Oct 2020 16:42:13 -0700 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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9788 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 mlxlogscore=999 suspectscore=2 bulkscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010280147 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9788 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 impostorscore=0 adultscore=0 bulkscore=0 spamscore=0 phishscore=0 mlxlogscore=999 suspectscore=2 clxscore=1015 mlxscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010280146 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 10/28/20 12:26 AM, Muchun Song wrote: > On Wed, Oct 28, 2020 at 8:33 AM Mike Kravetz wrote: >> On 10/26/20 7:51 AM, Muchun Song wrote: >> >> I see the following routines follow the pattern for vmemmap manipulation >> in dax. > > Did you mean move those functions to mm/sparse-vmemmap.c? No. Sorry, that was mostly a not to myself. >>> +static void vmemmap_pgtable_deposit(struct page *page, pte_t *pte_p) >>> +{ >>> + pgtable_t pgtable = virt_to_page(pte_p); >>> + >>> + /* FIFO */ >>> + if (!page_huge_pte(page)) >>> + INIT_LIST_HEAD(&pgtable->lru); >>> + else >>> + list_add(&pgtable->lru, &page_huge_pte(page)->lru); >>> + page_huge_pte(page) = pgtable; >>> +} >>> + >>> +static pte_t *vmemmap_pgtable_withdraw(struct page *page) >>> +{ >>> + pgtable_t pgtable; >>> + >>> + /* FIFO */ >>> + pgtable = page_huge_pte(page); >>> + if (unlikely(!pgtable)) >>> + return NULL; >>> + page_huge_pte(page) = list_first_entry_or_null(&pgtable->lru, >>> + struct page, lru); >>> + if (page_huge_pte(page)) >>> + list_del(&pgtable->lru); >>> + return page_to_virt(pgtable); >>> +} >>> + ... >>> @@ -1783,6 +1892,14 @@ static struct page *alloc_fresh_huge_page(struct hstate *h, >>> if (!page) >>> return NULL; >>> >>> + if (vmemmap_pgtable_prealloc(h, page)) { >>> + if (hstate_is_gigantic(h)) >>> + free_gigantic_page(page, huge_page_order(h)); >>> + else >>> + put_page(page); >>> + return NULL; >>> + } >>> + >> >> It seems a bit strange that we will fail a huge page allocation if >> vmemmap_pgtable_prealloc fails. Not sure, but it almost seems like we shold >> allow the allocation and log a warning? It is somewhat unfortunate that >> we need to allocate a page to free pages. > > Yeah, it seems unfortunate. But if we allocate success, we can free some > vmemmap pages later. Like a compromise :) . If we can successfully allocate > a huge page, I also prefer to be able to successfully allocate another one page. > If we allow the allocation when vmemmap_pgtable_prealloc fails, we also > need to mark this page that vmemmap has not been released. Seems > increase complexity. Yes, I think it is better to leave code as it is and avoid complexity. -- Mike Kravetz