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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA57EC83F3F for ; Mon, 4 Sep 2023 10:05:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27A16280019; Mon, 4 Sep 2023 06:05:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 22A688D0002; Mon, 4 Sep 2023 06:05:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 11A73280019; Mon, 4 Sep 2023 06:05:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 025A38D0002 for ; Mon, 4 Sep 2023 06:05:11 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C3535405BB for ; Mon, 4 Sep 2023 10:05:11 +0000 (UTC) X-FDA: 81198482022.08.A31AB34 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 469C3180027 for ; Mon, 4 Sep 2023 10:05:09 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693821909; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7qTsYbyWpVRIvKZOH6uKQ4aNho+XjSfgjlJlsXcCdeU=; b=zKlt6UZR+KUWM0kNXBo58uAhbjroF2Goq4EzokSy2njuxycmCXXsvfjTBvSr85c1wUnNDl 1ZECmrtgw39vrIiqy8negg46VEE92J4sQKGfunoyu+fV+5Nwx0UdheblRsjvNzPS45ZciF dTw7qY8cNIOpZVyVqPoMqeNTeM9HKCc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693821909; a=rsa-sha256; cv=none; b=UJe6W02F47S3Ohv1LfVHcFJ9IrWHsCojr1M/+HPV1EJqgkbsusmOUhkE01w5mYu45PQMpJ AJEK9PdhntHUElUgWM9KTFLWTZFNM5KYUiHEe6CHA/uT8iQXSeYaBjfT3nAq6riCOVDdJz iu7WQ71zasAzBrEGdoMA2hZPiX8vyck= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 34EEA143D; Mon, 4 Sep 2023 03:05:46 -0700 (PDT) Received: from [10.57.65.16] (unknown [10.57.65.16]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 995A13F793; Mon, 4 Sep 2023 03:05:05 -0700 (PDT) Message-ID: <61f875fe-d2e0-4a46-baeb-b6cd7b765267@arm.com> Date: Mon, 4 Sep 2023 11:05:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/5] mm: LARGE_ANON_FOLIO for improved performance Content-Language: en-GB To: Yang Shi , Matthew Wilcox Cc: David Hildenbrand , "Huang, Ying" , Andrew Morton , Yin Fengwei , Yu Zhao , Catalin Marinas , Anshuman Khandual , Zi Yan , Luis Chamberlain , Itaru Kitayama , "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org References: <20230810142942.3169679-1-ryan.roberts@arm.com> <20230810142942.3169679-4-ryan.roberts@arm.com> <87v8dg6lfu.fsf@yhuang6-desk2.ccr.corp.intel.com> <5c9ba378-2920-4892-bdf0-174e47d528b7@arm.com> <87cyz43s63.fsf@yhuang6-desk2.ccr.corp.intel.com> <4e14730b-4e4c-de30-04bb-9f3ec4a93754@redhat.com> From: Ryan Roberts In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 469C3180027 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: bf9porghfio3nxr7s9ydmeg5bcqnadtk X-HE-Tag: 1693821909-516128 X-HE-Meta: U2FsdGVkX1+x4gNTNVZr4ktxKHCddnR7ZCwq8A7hVDUQQepdrM8CL4mQCN/RckGLCC2oZVQzafAvpAQQl0vNc9qFSF1TUJfNpGd0lsO0ZqSx1/MEGwznFaU6gtMfWpyGl6Y5WFnHnpjAnp9Zms9g4f7XuMpVubJ38ZmiRn+gYMy2j6zHUFaWOFb2sWpil3JutXwYnfzu+ZHeuAeS+NwP5khq4vkszrrg/NEjW1suGx5ILHKv5oDMNXdwm3T4iVYdI6lrcS6GyRGJcy7ZQOP88w6ttUK/YKq/qEwE0O1gNDZTiixRZwg50NpmNMU2MJIXfjr2eu7iLfk2Hr9S74ZLV+3gCT2YWzciiOTi0W3zuxxVF3OOSgoNKxfoXMhEG8wlwfSdq+WCEKrOZE5xvzD2TkoryNHDY2m57GmQIJ0ubCX0l6zCvhKwCot2gClCQKPqDa2dVZm/QiivSAbULOh+5T1d0iKG1kE1m7PKQgdIm1TGMsomPir24xKUFnoGyuQ0+XFFuNA39FeE7MSgXV9YsWrpLVzxlOzPiDTUcIF5bX/XP7iyfKtB2Up/XmKs3Nl+PvfCehjO9D822WZc66Ksdt8z6xFWXxc5vhCR9+QQ1baBLdNeqiSO+9kOCf7rCjGLPjqYk3o5OxK447McLhSWDnUwJ1Id/UA1S8WhxCEtJp3HXFEatiE3uMzCpHjJMwEMRoURje6g+sW2P1jBPMqwGK3ptp/gX337gR6Ja7NXrn6lUsQ6KHUC6hpmURYmsND0427IXgXwuu5XGbpi5z2U+Cz5opm92ut28DHencerOSMzJRjULI2Ea4lJb4He2POd6BMwQ67D6Z66D9I2+nvFovgB9aOgwKr+Ei/I1WM++j9uMzk13mBCcPWwTESvN872dzxk10Qzb1uSDKkz8QhxfLyhSffYHg5j9Q+c0ZSXKS5pQolZmDnV/drRLzQ20A7IAuHI3pefyQ/fAatCL43 jX21zJ14 yV7k/vAXJm76qU5RSGZljq1U1ekJA0nlL2yxyD2vEP8wRcgFABROVqvlaf5xg3zhe2qByIP3Ofsei51YU9tc6ZVGf2nsz3jzseyCWON97FopTNymPOa/u80P39vAoe/i0VqdRgSJoj471NDveN3vLk9Q2JnFZIZqLWmhcWBE1SSYJTwaeV45ARN1XwVZ0hR7TRlEMQXhKoMcNaNAFIpON2o8a4580Jqudw4V6fxyVJkztCIgrs++ijjxTHQr8FsYaijzWGEKqLk8IeJw9qKdvBfoxnyeUxp6BPxXHB+F6fWSXEKtel6uOw4SxgzO+arE+MC3Ce6q8v8HtegBUcgWQ0XXNkxPCvSfanOR73Hp5SAkaNwTNTYMh6ZLFMAAwBWKQURCvPXsw43UFcSjeX6bVo30WOLZMizBEhjQT8ik5zMc4sGuav3fu+3xIug== 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 01/09/2023 18:18, Yang Shi wrote: > On Fri, Sep 1, 2023 at 9:13 AM Matthew Wilcox wrote: >> >> On Thu, Aug 31, 2023 at 10:15:09AM -0700, Yang Shi wrote: >>> On Thu, Aug 31, 2023 at 12:57 AM David Hildenbrand wrote: >>>> Let's talk about that in a bi-weekly MM session. (I proposed it as a >>>> topic for next week). >>>> >>>> As raised in another mail, we can then discuss >>>> * how we want to call this feature (transparent large pages? there is >>>> the concern that "THP" might confuse users. Maybe we can consider >>>> "large" the more generic version and "huge" only PMD-size, TBD) >>> >>> I tend to agree. "Huge" means PMD-mappable (transparent or HugeTLB), >>> "Large" means any order but less than PMD-mappable order, "Gigantic" >>> means PUD mappable. This should incur the least confusion IMHO. >> >> "Large" means any order > 0. The limitation to <= PMD_ORDER is simply >> because I don't want to go through the whole VM and fix all the places >> that assume that pmd_page() returns a head page. The benefit to doing so >> is quite small, and the work to achieve it is quite large. The amount of >> work needed should decrease over time as we convert more code to folios, >> so deferring it is the right decision today. > > Yeah, I agree. And we are on the same page. > >> >> But nobody should have the impression that large folios are smaller >> than PMD size, nor even less than or equal. Just like they shouldn't >> think that large folios depend on CONFIG_TRANSPARENT_HUGEPAGE. They do >> today, but that's purely an implementation detail that will be removed >> eventually. > > Yes, THP should be just a special case of large folio from page table > point of view (for example, PMD-mappable vs non-PMD-mappable). > >> >>>> I think there *really* has to be a way to disable it for a running >>>> system, otherwise no distro will dare pulling it in, even after we >>>> figured out the other stuff. >>> >>> TBH I really don't like to tie large folio to THP toggles. THP >>> (PMD-mappable) is just a special case of LAF. The large folio should >>> be tried whenever it is possible ideally. But I do agree we may not be >>> able to achieve the ideal case at the time being, and also understand >>> the concern about regression in early adoption, so a knob that can >>> disable large folio may be needed for now. But it should be just a >>> simple binary knob (on/off), and should not be a part of kernel ABI >>> (temporary and debugging only) IMHO. >> >> Best of luck trying to remove it after you've shipped it ... we've >> never been able to remove any of the THP toggles, only make them more >> complicated. > > Fingers crossed... and my point is we should try to avoid making > things more complicated. It may be hard... > >> >>> One more thing we may discuss is whether huge page madvise APIs should >>> take effect for large folio or not. >> >> They already do for file large folios; we listen to MADV_HUGEPAGE and >> attempt to allocate PMD_ORDER folios for faults. > > OK, file folio may be simpler than anonymous. For anonymous folio, > there may be two potential cases depending on our choice: > > Tie large folio to THP knobs: > MADV_HUGEPAGE - large folio if THP is on/no large folio if THP is off > MADV_NOHUGEPAGE - no large folio > > Not tie large folio to THP knob: > MADV_HUGEPAGE - always large folio > MADV_NOHUGEPAGE - shall create large folio? > In my mind, the debate on how LAF and MADV_NOHUGEPAGE should interact is concluded; David has explained a QEMU live migration use case, which would break if a LAF was allocated for a VMA with MADV_NOHUGEPAGE (see [1]). Given LAF and THP controls must be tied together at MADV_NOHUGEPAGE as a minimum, then for me it makes most sense to expose LAF to user space as a generalization of THP rather than a separate, independent feature. And if taking such a route, Huang Ying's suggestion at [2] sounds like a good starting point. Anyway, let's discuss in the mm meeting as David requested. [1] https://lore.kernel.org/linux-mm/b936041c-08a7-e844-19e7-eafc4ddf63b9@redhat.com/ [2] https://lore.kernel.org/linux-mm/87v8dg6lfu.fsf@yhuang6-desk2.ccr.corp.intel.com/