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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 1288DC433E0 for ; Fri, 5 Feb 2021 16:14:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5675A65013 for ; Fri, 5 Feb 2021 16:14:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5675A65013 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B28AC6B0006; Fri, 5 Feb 2021 11:14:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD8386B0070; Fri, 5 Feb 2021 11:14:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A0D66B0072; Fri, 5 Feb 2021 11:14:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 7CD896B0006 for ; Fri, 5 Feb 2021 11:14:02 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 33147362E for ; Fri, 5 Feb 2021 16:14:02 +0000 (UTC) X-FDA: 77784710724.23.waste45_1d0705b275e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id EB77E37608 for ; Fri, 5 Feb 2021 16:14:01 +0000 (UTC) X-HE-Tag: waste45_1d0705b275e6 X-Filterd-Recvd-Size: 6476 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Feb 2021 16:14:00 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id n10so4847494pgl.10 for ; Fri, 05 Feb 2021 08:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tgToZXIcR//slb37mMxyXMF6K319Gf4e4xqtIkg5mSQ=; b=vi1eZTDGn0s+c7nDc/UcaxmiZ8SO8djhd8YKp6I27b2SvO+LfWMsqNulS/rqad1/EE zti94jrpclnDbtIra0/SF7oO933+vtLmvQh0LOlXgTtUA/Ys9pWpCzEJCP/8EeKnN7RY KpnRSlevGccsTyUxdhwrPyWiJ1Hac/O8fH2AVQtrKbP/z2fQG58C63wBM+0nDMC0Ynvk 4eOqfX54/u8Ei+AiBWg43xL9oUa8Xrf8Zjdlyh5mAdzbTEcTH01mFIo52cFaP8k0nK7Z Q4Y7yFF8vBMHXuXjyC1YB7Zwja6igzBF2grNPDY3PHAeLebuziRPFkGYUNNyVT7trndg fTZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tgToZXIcR//slb37mMxyXMF6K319Gf4e4xqtIkg5mSQ=; b=Vq/KPRB3BW+89hvs2t6xipCW0cCHjCEzm96wx0iODtF08HmYIYcx345aso0yd0cxD5 20zmOoQvYqf2nrrP2+BeHE2ruzzVU7vAlp6010u6Zy0RFvd6NypK9yIeNV5jtZUMFpJZ YcHISjr5Ij+FC9eZrDclOgkpF8Vxxm+fMRXvIUu3f+9dWoPY24bAxLdqT/EoHB//gIJh 062k4OQtfBiui6xbA07EyVDQEyMBfYM6J/qEnlFtDjqnoxjyfTYExvDtNBaGnWa9k9C0 9iIMkBsQsr15/TyXgJQlkfq4VOj3NU5dHCkpDg0f1OVTsdsAk5TM3Udeqtmz0NHf7Vmj pTkA== X-Gm-Message-State: AOAM533KbPSXVeTfS+wCH52v3Q210jWo1UOaMy5uHeBa7HDbJp6Xx2cX Ks6ji0lY7fn49hcQ2y1LkfIzsFOYWV6Y/MTnsoDgeA== X-Google-Smtp-Source: ABdhPJwkirrFi8xuKWL/S5D2cKkWHr8/viSsyFvrNlI047a1E3Q16PWtG8tYxcyd1lVj1EuEzbAYJyMFxhtmMXc0PgQ= X-Received: by 2002:a62:1b93:0:b029:1cb:4985:623b with SMTP id b141-20020a621b930000b02901cb4985623bmr5289599pfb.59.1612541639757; Fri, 05 Feb 2021 08:13:59 -0800 (PST) MIME-Version: 1.0 References: <20210204035043.36609-1-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Sat, 6 Feb 2021 00:13:22 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v14 0/8] Free some vmemmap pages of HugeTLB page To: Joao Martins Cc: Xiongchun duan , linux-doc@vger.kernel.org, LKML , Linux Memory Management List , linux-fsdevel , Jonathan Corbet , Mike Kravetz , 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 , Oscar Salvador , Michal Hocko , "Song Bao Hua (Barry Song)" , David Hildenbrand , =?UTF-8?B?SE9SSUdVQ0hJIE5BT1lBKOWggOWPoyDnm7TkuZ8p?= Content-Type: text/plain; charset="UTF-8" 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 Sat, Feb 6, 2021 at 12:01 AM Joao Martins wrote: > > On 2/4/21 3:50 AM, Muchun Song wrote: > > Hi all, > > > > [...] > > > When a HugeTLB is freed to the buddy system, we should allocate 6 pages for > > vmemmap pages and restore the previous mapping relationship. > > > > Apart from 2MB HugeTLB page, we also have 1GB HugeTLB page. It is similar > > to the 2MB HugeTLB page. We also can use this approach to free the vmemmap > > pages. > > > > In this case, for the 1GB HugeTLB page, we can save 4094 pages. This is a > > very substantial gain. On our server, run some SPDK/QEMU applications which > > will use 1024GB hugetlbpage. With this feature enabled, we can save ~16GB > > (1G hugepage)/~12GB (2MB hugepage) memory. > > > > Because there are vmemmap page tables reconstruction on the freeing/allocating > > path, it increases some overhead. Here are some overhead analysis. > > [...] > > > Although the overhead has increased, the overhead is not significant. Like Mike > > said, "However, remember that the majority of use cases create hugetlb pages at > > or shortly after boot time and add them to the pool. So, additional overhead is > > at pool creation time. There is no change to 'normal run time' operations of > > getting a page from or returning a page to the pool (think page fault/unmap)". > > > > Despite the overhead and in addition to the memory gains from this series ... > there's an additional benefit there isn't talked here with your vmemmap page > reuse trick. That is page (un)pinners will see an improvement and I presume because > there are fewer memmap pages and thus the tail/head pages are staying in cache more > often. > > Out of the box I saw (when comparing linux-next against linux-next + this series) > with gup_test and pinning a 16G hugetlb file (with 1G pages): > > get_user_pages(): ~32k -> ~9k > unpin_user_pages(): ~75k -> ~70k > > Usually any tight loop fetching compound_head(), or reading tail pages data (e.g. > compound_head) benefit a lot. There's some unpinning inefficiencies I am fixing[0], but > with that in added it shows even more: > > unpin_user_pages(): ~27k -> ~3.8k > > FWIW, I was also seeing that with devdax and the ZONE_DEVICE vmemmap page reuse equivalent > series[1] but it was mixed with other numbers. It's really a surprise. Thank you very much for the test data. Very nice. Thanks again. > > Anyways, JFYI :) > > Joao > > [0] https://lore.kernel.org/linux-mm/20210204202500.26474-1-joao.m.martins@oracle.com/ > [1] https://lore.kernel.org/linux-mm/20201208172901.17384-1-joao.m.martins@oracle.com/