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 DD501C4167B for ; Mon, 4 Dec 2023 11:11:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64F876B02BF; Mon, 4 Dec 2023 06:11:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 626676B02C1; Mon, 4 Dec 2023 06:11:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 516166B02C2; Mon, 4 Dec 2023 06:11:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 41A886B02BF for ; Mon, 4 Dec 2023 06:11:33 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0329E1401B6 for ; Mon, 4 Dec 2023 11:11:32 +0000 (UTC) X-FDA: 81528870066.06.5A8E69B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 0F21520007 for ; Mon, 4 Dec 2023 11:11:30 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.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=1701688291; 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=Aep5mmSPeSr4jywesXUA5jCgECfadxKNNHj8ePB8uiY=; b=CVbd8HR6Dq6VjJWbhxPMDptYev+qjJXs53fhO7QIuKVSKq/606WaAgq8d7/SqOZW/U/YxQ Jkg/PkivQHPQshn+D4/fC1pmJZmQaHgOcyge6L6y7gTIgYzsuf9kfiq+7vEDf7t5k7WE3F 5nNSFCJlRTrxGllR9eyI5juNsAIXgdg= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf13.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=1701688291; a=rsa-sha256; cv=none; b=o4Y+5MfKQXEOZp6uKLG7gNH/BwT9LzmGoyNnwxPkhYEodHg5Ggy0qcNDj/ao1g7Benw9mQ Zc2q3fbtNdDEEKYKgsZmsvNc6t+BB6Yzp6g0kNGi1NIipMQrRDAxUh8qDmEUrkO64aKPG3 jDgocHS1Mrr+/BfpoIdYGagljF2xU1w= 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 8F63E152B; Mon, 4 Dec 2023 03:12:17 -0800 (PST) Received: from [10.57.73.130] (unknown [10.57.73.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6CCCE3F6C4; Mon, 4 Dec 2023 03:11:27 -0800 (PST) Message-ID: <01aad92f-b1e0-4f31-b905-8b1c2012ebab@arm.com> Date: Mon, 4 Dec 2023 11:11:26 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC 06/12] mm/gup: Drop folio_fast_pin_allowed() in hugepd processing Content-Language: en-GB To: Christophe Leroy , Peter Xu Cc: Matthew Wilcox , Christoph Hellwig , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Andrea Arcangeli , James Houghton , Lorenzo Stoakes , David Hildenbrand , Vlastimil Babka , John Hubbard , Yang Shi , Rik van Riel , Hugh Dickins , Jason Gunthorpe , Axel Rasmussen , "Kirill A . Shutemov" , Andrew Morton , "linuxppc-dev@lists.ozlabs.org" , Mike Rapoport , Mike Kravetz References: <20231116012908.392077-7-peterx@redhat.com> <510adc26-9aed-4745-8807-dba071fadbbe@arm.com> <283da12c-14f1-4255-b3c4-ab933f3373c4@csgroup.eu> From: Ryan Roberts In-Reply-To: <283da12c-14f1-4255-b3c4-ab933f3373c4@csgroup.eu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0F21520007 X-Stat-Signature: ez4pxmgzc7xs6fiqadkxbg4g8tuxp68c X-HE-Tag: 1701688290-903128 X-HE-Meta: U2FsdGVkX1++t711Mfp7Yq/GTR5mPJ4BtZGeDgnE57UJm7uX4mxvQ/0ZBr96GSZ7sfIVgY2VAG5uf/4t/yC2E39VdBwuTW9PW9jykYNdI2gYz4V3pzDRVQdHIL0CUNZgiLcdmZKQU/yqa2YU18DJ9jaruxV1LaEoYrs+KyOMzZB2RGgQVvDXKL3soZZSmhoIJmxStuO55ptUEs+Yz0+Ji/ACwskdi3r1ImTQdewrTuLzhFlOSbn0fknQHrloe69KE4QxBWEK2HaiooveRd2i5h9ZAJcIIt+3YF4xul8/1Tk15LMdU5fPJXGtbiNbHQm0l0ZMKBX/s2I1t4/DRqPAREP8uZUgJqe90D5qjBuFHRcj57nTrHAsY8J9HheWZobbSNFMH9BCiPoshzMhW/d1s9zP9bBILYDeMmXM9ALJAOBvSxLrPKqGSgZkQDOIsy3PdZhSPaDvEbP7kZwCSn73DzgJ/B8jQAJYKgNJe3ft5gr3PsrNnFHmsPN8qTw4gGnlMgwmQpRgijriBbm3S0sqptUKqmLxOUydmFdwu+1adBY2hjGEiakxu4oL7lCNAHWJrH9tcPBzhVM/fny5WO9j9ZA+iQnAAB23JI89Gub0yv6meEHKzuEkD2SII6o0HizSqC94Ilt2Wku5grJ2yfgI2mwWILfJdGvZ384xI8p/BTr4gKQnpWYhh1CHBuc7hJAjznF4BBvJ8ItBJSIjcAaKyhvPqbKZcuaFgQdPOzxq4IasqKQtiMr1LtsV2m9S9ybqKJRUUfqlsbuyV8Fmw6f8i9YCXt1rbYuljhZ8ephPxp2sylDX213d+GkViaJKs0s53/ZaJYnivmLLoLr1NbxFlWIgsZbldJ/i/+VRLyRJJip1QD7TqgWp21oItckDOWhUsZTQsHAqpG2d8FCiuRZCUI7TfBbKneGTNw+cPR0SZnk13kd7um5j3B3SSW27Xl/fkzMFokRmaUdrkDqGea3 jUyuqVYr XGazjMpZ4eEaQGU1mdJ6iGiFanPYy2u+SB5lI4JSiRgchpdCy6SxbQ5GydOOKp+d3O4rlEUeBUKHQi7abOMXhtWcYRNsm29mFKbRm9ihtonl6WNKmpWjpq79JQluwtF7I9RZABhiZkpTxcMeQeTtFAKE6z+TKRGt86TOJmB9ziliLAOdzfZhbDhpd7Md78fzrVoObKl7M14R0E9ETEIl07GoCdpee/goNhj85zGjYmj1fa/I= 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: List-Subscribe: List-Unsubscribe: On 03/12/2023 13:33, Christophe Leroy wrote: > > > Le 30/11/2023 à 22:30, Peter Xu a écrit : >> On Fri, Nov 24, 2023 at 11:07:51AM -0500, Peter Xu wrote: >>> On Fri, Nov 24, 2023 at 09:06:01AM +0000, Ryan Roberts wrote: >>>> I don't have any micro-benchmarks for GUP though, if that's your question. Is >>>> there an easy-to-use test I can run to get some numbers? I'd be happy to try it out. >>> >>> Thanks Ryan. Then nothing is needed to be tested if gup is not yet touched >>> from your side, afaict. I'll see whether I can provide some rough numbers >>> instead in the next post (I'll probably only be able to test it in a VM, >>> though, but hopefully that should still reflect mostly the truth). >> >> An update: I finished a round of 64K cont_pte test, in the slow gup micro >> benchmark I see ~15% perf degrade with this patchset applied on a VM on top >> of Apple M1. >> >> Frankly that's even less than I expected, considering not only how slow gup >> THP used to be, but also on the fact that that's a tight loop over slow >> gup, which in normal cases shouldn't happen: "present" ptes normally goes >> to fast-gup, while !present goes into a fault following it. I assume >> that's why nobody cared slow gup for THP before. I think adding cont_pte >> support shouldn't be very hard, but that will include making cont_pte idea >> global just for arm64 and riscv Svnapot. > > Is there any documentation on what cont_pte is ? I have always wondered > if it could also fit powerpc 8xx need ? pte_cont() (and pte_mkcont() and pte_mknoncont()) test and manipulte the "contiguous bit" in the arm64 PTE entries. Those helpers are arm64-specific (AFAIK). The contiguous bit is a hint to the HW to tell it that a block of PTEs are mapping a physically contiguous and naturally aligned piece of memory. The HW can use this to coalesce entries in the TLB. When using 4K base pages, the contpte size is 64K (16 PTEs). For 16K base pages, its 2M (128 PTEs) and for 64K base pages, its 2M (32 PTEs). > > On powerpc, for 16k pages, we have to define 4 consecutive PTEs. All 4 > PTE are flagged with the SPS bit telling it's a 16k pages, but for TLB > misses the HW needs one entrie for each 4k fragment. >From that description, it sounds like the SPS bit might be similar to arm64 contiguous bit? Although sounds like you are currently using it in a slightly different way - telling kernel that the base page is 16K but mapping each 16K page with 4x 4K entries (plus the SPS bit set)? > > There is also a similar approach for 512k pages, we have 128 contiguous > identical PTEs for them. > > And whatever PAGE_SIZE is (either 4k or 16k), the HW needs one 'unsigned > long' pte for each 4k fragment. So at the time being when we define > PAGE_SIZE as 16k, we need a special pte_t which is a table of 4x > unsigned long. > > Wondering if the cont_pte concept is similar and whether it could help. To be honest, while I understand pte_cont() and friends, I don't understand their relevance (or at least potential future relevance) to GUP? > > Thanks > Christophe