Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp112849lfu; Mon, 4 Apr 2022 21:24:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynEsOuZ6BOFFuIvKsbhCdy3bXF8KsGbpMAjV92mgXmnU9hKW5N09cdKfMtIkXgRVrUnPQh X-Received: by 2002:a17:90a:734a:b0:1ca:8240:9e48 with SMTP id j10-20020a17090a734a00b001ca82409e48mr1843057pjs.174.1649132668503; Mon, 04 Apr 2022 21:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649132668; cv=none; d=google.com; s=arc-20160816; b=NXcSmdMDWKIiLTaIS1K+KAoY28AfU7bguWg9s23ClfQQzSgmIYEfdBB0Bf71THAtL1 kXBVmafl+YqTDg6yUCe+jmAXzZOYOeBmgU3UVj+X5Uv2kL4FllsErjVTK0V0nBnFgyzy l0yinMi+EIrTVtlfFSS7E4p8BgWDU97UaufK0Llu6PamyPoQuNPOibginjIBzDyKRpQ5 1xqdH2FZfWTTGR60mpvvm3WQ2LOUOQJeA+eKTVVor+jxsKoqbmE5QVdRnHRi9Zt/zn55 V0kg6N+Ej8CtbpDiMKzuix9nZlSwTDlxVgFUwtiEV4E2izgWMVL0x5N2ngP2kBk6Npp2 Z47Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TeIlPBykaaoOQQ8YagbDwarHCQQ/nrdr/5DasCXPXhU=; b=MfaNjhZWxI48TUVkGNTHCZ64l4AgKfTryG59/jRmIn6zQ5eMprFgT86dYokHe1Xr9l g5jOmjOYuodp3zy6EH1gmcamIAPIxLNOGkw24AVQO4RdKFoTUfaI6aAS+OKO4wVccjYx Rz5Wmqo991Zbo9a6OSLRVQFzOLQPBCYVI0ppnAqhPzJ2S/olRFPpcXc2zmn1jp3d+kH2 wHnMAByvc3BKv5RpRGHVP47SZ7odDT9FzqmjS6Bwf8EsH7YaNzAgVBdky/H8mSDBtMHy AWdTWlicmoZM+QIGSdgyxOwhBkT+xupSkkAH4mP0Ni+AvS8ktM6BUqjmchZxJtQMl/fh +PuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=wneh0BiX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t2-20020a170902e84200b00153bc4c8989si12707258plg.204.2022.04.04.21.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 21:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=wneh0BiX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 328353A73E; Mon, 4 Apr 2022 20:50:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230416AbiDEDw2 (ORCPT + 99 others); Mon, 4 Apr 2022 23:52:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbiDEDwM (ORCPT ); Mon, 4 Apr 2022 23:52:12 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ED482AC75 for ; Mon, 4 Apr 2022 20:50:06 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id d138so12811630ybc.13 for ; Mon, 04 Apr 2022 20:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TeIlPBykaaoOQQ8YagbDwarHCQQ/nrdr/5DasCXPXhU=; b=wneh0BiXc+5llZgked4jWuiU/DBGvp91kCAV1p0+Bk/v0mKdq3eNhoPxFpl4Qr6JNz I2BPx4rs+GpJLmuw0bVzUjLJQmXtkYyVVyTS/+c9WHWC9IwZM5nkJ7+BTsFdriHTFSJr lTBju3CN3ktZXrYOAMvEv4QwM/t+Es5VVfI6r4dfcNnrBJCcCJHJToHHCjsBYgrNJUwg Mrgh27PPtbfCYjkuHgr1wJvJFaTd8eDgNGRqhTs3Ct/Dn91bINafMkD+cpT3JnIT924q 6WemLZYZIET3loPw/ZsP/scr1vVwajweZs82K5JS/dh4C3/pXOmny1DoKiFETFZq2uk7 ZYpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TeIlPBykaaoOQQ8YagbDwarHCQQ/nrdr/5DasCXPXhU=; b=rA0CuFHrk0NJX536jaJnR4ujtQO/BknbXX/F18bXdiQqANfU/J+4UDWtCs7GV5FSPj JRyjp1S1UCbJMVNnBP/BqIIq3Ix/xjQ6WtEyxyBHwYebeS6uQH+J6/w5yOVIY2uGXMDp CBtVLSP1MLAT638KbWrvIL2N+gS0aklFkplMYBqAELs+Dp1GQQQVDz3DPqe1jNGLEX7h j/q2RG9cSvPxfiW/PRJv5urGWrCmh19nBmj/pSsEtCq3xTVoHbm1CnCswWeawas/awKU cLHkmFWtjRXgzl9U7tBH6GE1a/Rssd3gX5c2+89JqlbJP3yAlTqlgQApfkUT9cFrNawF NcYQ== X-Gm-Message-State: AOAM532oyciYK6I1jxLKdn3KqUtit3zpco3dCh1l3/HZg+KKZNeUfzcM axHXVKXZW/v2NEZLWPrr9aoZgRmCQEOhouMv6jdiOQ== X-Received: by 2002:a25:cc92:0:b0:63d:b330:e8a4 with SMTP id l140-20020a25cc92000000b0063db330e8a4mr1120705ybf.427.1649130604963; Mon, 04 Apr 2022 20:50:04 -0700 (PDT) MIME-Version: 1.0 References: <20220331065640.5777-1-songmuchun@bytedance.com> <20220331065640.5777-2-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Tue, 5 Apr 2022 11:49:29 +0800 Message-ID: Subject: Re: [PATCH v4 2/2] arm64: mm: hugetlb: Enable HUGETLB_PAGE_FREE_VMEMMAP for arm64 To: Anshuman Khandual Cc: Will Deacon , Andrew Morton , David Hildenbrand , "Bodeddula, Balasubramaniam" , Oscar Salvador , Mike Kravetz , David Rientjes , Mark Rutland , Catalin Marinas , james.morse@arm.com, Barry Song <21cnbao@gmail.com>, LAK , LKML , Linux Memory Management List , Xiongchun duan , Fam Zheng , Muchun Song Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 5, 2022 at 11:34 AM Anshuman Khandual wrote: > > > > On 4/4/22 17:31, Muchun Song wrote: > > On Mon, Apr 4, 2022 at 5:25 PM Anshuman Khandual > > wrote: > >> > >> Hello Muchun, > >> > >> On 3/31/22 12:26, Muchun Song wrote: > >>> The feature of minimizing overhead of struct page associated with each > >>> HugeTLB page aims to free its vmemmap pages (used as struct page) to > >>> save memory, where is ~14GB/16GB per 1TB HugeTLB pages (2MB/1GB type). > >> > >> Enabling this feature saves us around 1.4/1.6 % memory but looking from > >> other way around, unavailability of vmemmap backing pages (~1.4GB) when > >> freeing up a corresponding HugeTLB page, could prevent ~1TB memory from > >> being used as normal page form (requiring their own struct pages), thus > >> forcing the HugeTLB page to remain as such ? Is not this problematic ? > >> > >> These additional 1TB memory in normal pages, from a HugeTLB dissolution > >> could have eased the system's memory pressure without this feature being > >> enabled. > > > > You are right. If the system is already under heavy memory pressure, it could > > prevent the user from freeing HugeTLB pages to the buddy allocator. If the > > HugeTLB page are allocated from non-movable zone, this scenario may be > > not problematic since once a HugeTLB page is freed, then the system will > > But how can even the first HugeTLB page be freed without vmemmmap which is > throttled due to lack of sufficient memory ? It's unfortunate, we're deadlocked and will have to try again later :-( > > > have memory to be allocated to be used as vmemmap pages, subsequent > > freeing of HugeTLB pages may be getting easier. However, if the HUgeTLB > > pages are allocated from the movable zone, then the thing becomes terrible, > > which is documented in Documentation/admin-guide/mm/memory-hotplug.rst. > > > > So there is a cmdline "hugetlb_free_vmemmap" to control if enabling this > > feature. The user should enable/disable this depending on their workload. > > Should there also be a sysfs interface for this knob as well ? Perhaps the > system usage might change on the way, without requiring a reboot. Yep. I'm working on this [1] and will cc you in the next version. [1] https://lore.kernel.org/all/20220330153745.20465-1-songmuchun@bytedance.com/ Thanks.