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=-9.5 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 CCCC7C4338F for ; Mon, 16 Aug 2021 23:23:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 38A2560F38 for ; Mon, 16 Aug 2021 23:23:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 38A2560F38 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A409C8D0001; Mon, 16 Aug 2021 19:23:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA4D6B0073; Mon, 16 Aug 2021 19:23:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B8958D0001; Mon, 16 Aug 2021 19:23:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6F9A76B0072 for ; Mon, 16 Aug 2021 19:23:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D655220BC7 for ; Mon, 16 Aug 2021 23:23:07 +0000 (UTC) X-FDA: 78482521614.19.D1A5F40 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf01.hostedemail.com (Postfix) with ESMTP id 3A88750186E1 for ; Mon, 16 Aug 2021 23:23:07 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 033A660F35; Mon, 16 Aug 2021 23:23:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1629156186; bh=n+wwokIPkrGhwwnxslCZ/pC5W06miwa1WJrK0dzO5qQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Rz1K4gONy6IHigGB2ZtfXfsxPM1VzZmGHGohRt0wMliWtdVeEd9c5m+r7xoeS9+02 stEGXvuvOH+MUx0XKujtKKUsapHTqfPcWMWTDWn9ZD8lQhfLP40MebGLKriwv9rCIo c/QBtihgA4AC7Keo3D5SbHbjlgrV84ISc+qQ9SSM= Date: Mon, 16 Aug 2021 16:23:05 -0700 From: Andrew Morton To: Mike Kravetz Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Hildenbrand , Michal Hocko , Oscar Salvador , Zi Yan , Muchun Song , Naoya Horiguchi , David Rientjes Subject: Re: [PATCH RESEND 0/8] hugetlb: add demote/split page functionality Message-Id: <20210816162305.b19bfa3f3ba7431a62ff205f@linux-foundation.org> In-Reply-To: <20210816224953.157796-1-mike.kravetz@oracle.com> References: <20210816224953.157796-1-mike.kravetz@oracle.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Rz1K4gON; spf=pass (imf01.hostedemail.com: domain of akpm@linux-foundation.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3A88750186E1 X-Stat-Signature: fuuxpdqfm4t8irhuwyy19s34netq3hmk X-HE-Tag: 1629156187-874601 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 Mon, 16 Aug 2021 15:49:45 -0700 Mike Kravetz wrote: > This is a resend of PATCHes sent here [4]. There was some discussion > and interest when the RFC [5] was sent, but little after that. The > resend is just a rebase of [4] to next-20210816 with a few typos in > commmit messages fixed. > > Original Cover Letter > --------------------- > The concurrent use of multiple hugetlb page sizes on a single system > is becoming more common. One of the reasons is better TLB support for > gigantic page sizes on x86 hardware. In addition, hugetlb pages are > being used to back VMs in hosting environments. > > When using hugetlb pages to back VMs in such environments, it is > sometimes desirable to preallocate hugetlb pools. This avoids the delay > and uncertainty of allocating hugetlb pages at VM startup. In addition, > preallocating huge pages minimizes the issue of memory fragmentation that > increases the longer the system is up and running. > > In such environments, a combination of larger and smaller hugetlb pages > are preallocated in anticipation of backing VMs of various sizes. Over > time, the preallocated pool of smaller hugetlb pages may become > depleted while larger hugetlb pages still remain. In such situations, > it may be desirable to convert larger hugetlb pages to smaller hugetlb > pages. > > Converting larger to smaller hugetlb pages can be accomplished today by > first freeing the larger page to the buddy allocator and then allocating > the smaller pages. However, there are two issues with this approach: > 1) This process can take quite some time, especially if allocation of > the smaller pages is not immediate and requires migration/compaction. > 2) There is no guarantee that the total size of smaller pages allocated > will match the size of the larger page which was freed. This is > because the area freed by the larger page could quickly be > fragmented. > > To address these issues, introduce the concept of hugetlb page demotion. > Demotion provides a means of 'in place' splitting a hugetlb page to > pages of a smaller size. For example, on x86 one 1G page can be > demoted to 512 2M pages. Page demotion is controlled via sysfs files. > - demote_size Read only target page size for demotion Should this be "write only"? If not, I'm confused. If "yes" then "write only" would be a misnomer - clearly this file is readable (looks at demote_size_show()). > - demote Writable number of hugetlb pages to be demoted So how does this interface work? Write the target size to `demote_size', write the number of to-be-demoted larger pages to `demote' and then the operation happens? If so, how does one select which size pages should be selected for the demotion? And how does one know the operation has completed so the sysfs files can be reloaded for another operation? > Only hugetlb pages which are free at the time of the request can be demoted. > Demotion does not add to the complexity surplus pages. Demotion also honors > reserved huge pages. Therefore, when a value is written to the sysfs demote > file, that value is only the maximum number of pages which will be demoted. > It is possible fewer will actually be demoted. > > If demote_size is PAGESIZE, demote will simply free pages to the buddy > allocator. > > Real world use cases > -------------------- > There are groups today using hugetlb pages to back VMs on x86. Their > use case is as described above. They have experienced the issues with > performance and not necessarily getting the excepted number smaller huge ("expected") > pages after free/allocate cycle. > It seems odd to add the interfaces in patch 1 then document them in patch 5. Why not add-and-document in a single patch?