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 930C7C25B4F for ; Sun, 12 May 2024 17:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D79DD6B0198; Sun, 12 May 2024 13:26:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D297C6B0199; Sun, 12 May 2024 13:26:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF1F96B019A; Sun, 12 May 2024 13:26:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A1F706B0198 for ; Sun, 12 May 2024 13:26:13 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2E66DC07EF for ; Sun, 12 May 2024 17:26:13 +0000 (UTC) X-FDA: 82110422226.17.16A54EB Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) by imf09.hostedemail.com (Postfix) with ESMTP id 37F09140006 for ; Sun, 12 May 2024 17:26:10 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=iTBOg7X6; spf=pass (imf09.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1715534771; a=rsa-sha256; cv=none; b=bSrdrYJqBw2+TMTzke3vJ7klw9u7OPzAUKpJy847/9JR3X//ucFCcEPDgO2h5PhpMLtdI3 knygIsIQbaCTUeXS8P9DVq3PVebReAVK07TCM/JsiACN4Dwj9q3/0Xvk4SuRAoRUhpfWUh MtMunHr2Oz+i7SNc0eTorT+IuHtQq1s= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=iTBOg7X6; spf=pass (imf09.hostedemail.com: domain of alexghiti@rivosinc.com designates 209.85.218.45 as permitted sender) smtp.mailfrom=alexghiti@rivosinc.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1715534771; 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:dkim-signature; bh=6rp1j3tK1OJVirvDudGud0MNNZLke5KUalkhcuIeFIk=; b=ofp9Jc+FT6GCRb6vYyyHJn9ZYEXuZvFU6Mm7ri3N5nSTxVDE19rrf6Dn0HUEh7wlhulljy Kjz9LqXmTzUoYRquDq2nwrT6pMSHFJAcfXa0IOed6CHKqKOdl4Ufayk5EctINOb5JJ7UOq Q9yJALBzhlxOoNDMXe8JcKDKPKWWrW8= Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a59b58fe083so789816466b.0 for ; Sun, 12 May 2024 10:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1715534769; x=1716139569; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6rp1j3tK1OJVirvDudGud0MNNZLke5KUalkhcuIeFIk=; b=iTBOg7X6j4aI9NbK3mkBtrIhbQ3ibBKDbSUl5Y/xBQRm2xWR9vi+nDvPM9W50umbH+ DVPv5lPgt75DaahXXuKX913IfZlvwyc6taDDUfymSbLH78FabLDAyfJGe6iT8U+tBwAH iVGHowgQgo1S4TybwNt2ofd7xAxwWiGFxhE1uiaXA7g8NeGSgxd8eBEKxpLT4FVmCYk8 gWbrbl//tUUoknAtyKziEYE8WMeVchLH3KhDLLvkKtMMvw/AmKIOM9daXUSk5D5/xfUC GnKFMw/eeIiMPreqe4I2q3nZAGYv3Si6dwCK9bS7vjEC/1fS6Q4DXtQBrWcO8cK3WXeQ doNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715534769; x=1716139569; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6rp1j3tK1OJVirvDudGud0MNNZLke5KUalkhcuIeFIk=; b=F4Phb8wxsZ9h+WPZoWewrQYbV4yqXYkJ4o/TmlFtCNdL+LWlQB3+Ov0U9uMx3WFeHA 6E6YwoNRCJJJbWMxgxh+M+rW5digQvEFrNKOPOJAAfdWogO4cvr4d9RkGgqSfNjrUqd4 hwXhGMWjiAj9b34bAFSrJinXFo0Zhc1nYG4e4D546VTXqEDKBRZ17M3t0LNbTtlOHvHx aJ0ffuAGWDOYFHAyo5R0ddm5vWNrP/MLHUUhIcy/hVZGe1n8Hzgec5QU0SYhotOUBB4d MzemftbQR+sp2hMXMhqYtPxPwWzMKBGPRH6N5zb6s8QbvaJAthexj86WEC34AwpuHxx7 eOhw== X-Forwarded-Encrypted: i=1; AJvYcCUQLYQukSeEcBA8KwxPpGGIJhk3UPZ7+/xPzWs/Nh68h8kxl51W0UfgOgxfBgGdh+XrO37WwbS4uFlfkC6tmXz9yLo= X-Gm-Message-State: AOJu0Yyk6bt1ABTdeh9X2wAKerTikTaEPghNMD14UV0uzXr4JfhcqjpD s9SOhesOf3blnIsU1V4JxCZEx9/GqoxdFXR3mPVmjmAJXbeJWS5anPoyO+28DjDq9pfR6xoMFgy fTZoz4fCTKdDcBO2lNUwisXFWPg9DeeO/wleAxg== X-Google-Smtp-Source: AGHT+IGfyPbzeLrU5udFiEWzczMwwxKepDEGvfHppqzXC9YS60xa54DW1mYug80BN/LUVrhw2FhktXpJfB9RmgP7f3M= X-Received: by 2002:a17:907:9405:b0:a5a:542d:ae0a with SMTP id a640c23a62f3a-a5a542daf06mr279619566b.63.1715534769414; Sun, 12 May 2024 10:26:09 -0700 (PDT) MIME-Version: 1.0 References: <20240508113419.18620-1-alexghiti@rivosinc.com> <6d37f914-d139-48ea-be63-c428ac767cc1@arm.com> In-Reply-To: <6d37f914-d139-48ea-be63-c428ac767cc1@arm.com> From: Alexandre Ghiti Date: Sun, 12 May 2024 19:25:56 +0200 Message-ID: Subject: Re: [PATCH RESEND v2 0/9] Merge arm64/riscv hugetlbfs contpte support To: Ryan Roberts Cc: Catalin Marinas , Will Deacon , Mark Rutland , Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 37F09140006 X-Rspam-User: X-Rspamd-Server: rspam12 X-Stat-Signature: pb4t7p8f85hsz37exnhdsedr6m6szena X-HE-Tag: 1715534770-201844 X-HE-Meta: U2FsdGVkX18teRJ2vzcLHFKC0wPCHNFA0lyrCP1TuSAHOv34aC6Y4GXua/gljJNSNfloU/aLsAN7QRelMjAQc6NqsqB36cXjaHXKAWAZA6yfUU8N8+XoPhDuqwbMBOien7/OdAEWC6U0b0BEIJPBleum+tjemweWrWLZfcUwv5T/obf1j5HLwz/jQVo11naccEy6JND/Ny8ERNlWcTgKazULtJ5Wp1mYpMHS+nHaaR/7RMRYunfcy8EGdF9y4vqONe/ekzGvwMMql1WQSz1rw0aQp7LnFWkoAqk+d2LERcxWeJ1vfWb+bMLv2Lsc7SFyBDhAmkWRNFjRrIUHTfmI/uYQ+70dWwX2TqPjf9mvoXo5hS/aWxPE4L+fGlGePyj/ifVZ5J5YtQIfCeulMyBVtZM7mD4duLS86f55NX0DsFS/yW0eP2AmsPI/vPvrtC3h278tXROFizVZSeKZj4SMz4aemoQtNDuxP4w7boP3nA0MRQI4QR1mldHKPm1PoWz/1n3ub8yG6ZpiVP0o+BdcDVBziz5gS4fNII+tUT9mBNS2M0JWMiEj3bwlvNSboJbJNcKATxxQ+AxKqtinhFKDRNWMF6SnujNEJ7TI0Y7Dgd6086XEBWdyYZF7Fd4U+gwtwB0BrQIlYk9hadsrQI6JjvzHj6UZ1eo4YtvB+9P8KXhFLWMN8csLGeWqTa1jHrIikwR3MxwA05eqQ8mClwC9g7olOHgWhqCaA0lEjOZ2IiIxwUh7tMtzNnmwwmBKq/SjSfJhUVsLpYb+w3bQ5vxavN7y712LkqbBZpxo8cpLevOGRqta2W7Rdgh+JC35Ash31jqUT9HXigpRQTl8XepMHmCG5LkizRofjLXI30X20C8Uy9bscGjpYqi7han4xgkA9L4yAcxDug70ULAKdUepqVicIFg0NnczfrzYrXoVKmieaAkXBWvUc+9ynylr3eeRJfnVdYKJ9Z1zwneaQij UA+wbp8y TuPzfu74c6u8P9SkpzEesbxBfVNLULZzgMjU+Ses0GO83UruVMHE+HDeJNtRnEqJOt3P8gXiezilvrcF8FFZV2CLCLdnOUgqfh/MsNstFh8OYw6aPKqSNTFy0utnVF/xcEmEAf3TjqF/bh578r3sPWo5sPEiwO5ocmsLj0nQ5i42DCpM49EXMRcTqm5AUfLAjuHmTIX8UgXHtQIC1no1wMozCD/3pJGdexEaxL6eUzNQkk29HiQW2RaAfwDMHzZV7R11eB2S2TnqpREUU8i6ZpaBzkJd8vpbe4JiYvf/mEBoXLKRGOwoCJxB3EmKvuPcepdJumDbNwZ+M1JVRItrBIYLu2YjlO4vL68fCAmJINIhA/mp7gOJQdSx2Z8LAfESaMruOqWCb33XLZ3A= 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: Hi Ryan, On Fri, May 10, 2024 at 3:49=E2=80=AFPM Ryan Roberts = wrote: > > On 08/05/2024 12:34, Alexandre Ghiti wrote: > > This patchset intends to merge the contiguous ptes hugetlbfs implementa= tion > > of arm64 and riscv. > > > > Both arm64 and riscv support the use of contiguous ptes to map pages th= at > > are larger than the default page table size, respectively called contpt= e > > and svnapot. > > > > The riscv implementation differs from the arm64's in that the LSBs of t= he > > pfn of a svnapot pte are used to store the size of the mapping, allowin= g > > for future sizes to be added (for now only 64KB is supported). That's a= n > > issue for the core mm code which expects to find the *real* pfn a pte p= oints > > to. Patch 1 fixes that by always returning svnapot ptes with the real p= fn > > and restores the size of the mapping when it is written to a page table= . > > > > The following patches are just merges of the 2 different implementation= s > > that currently exist in arm64 and riscv which are very similar. It pave= s > > the way to the reuse of the recent contpte THP work by Ryan [1] to avoi= d > > reimplementing the same in riscv. > > Hi Alexandre, > > I've skimmed through this series and the one that moves contpte. I can se= e there > is definitely value in sharing the implementation, and the rough shape of= things > seems appropriate. I had some minor concerns about making it harder to im= plement > potential future arm64 errata workarounds but on reflection, most of the > now-shared code is really just wrapping the primitives that are still arc= h-specific. > > I'm going to need to spend proper time reviewing it to give detailed feed= back, > but I'll be out on paternity leave for 3 weeks from end of Monday at the = latest. Too bad, I expected to discuss that with you at LSF/MM...But congrats! Hope your wife is fine :) > So realistically I won't be able to do the detailed review until at least= the > first week of June. > > Some high level thoughts: > > - huge_ptep_* functions could be working on different sized huge ptes - = arm64 > supports contpte, pmd, contpmd and pud. Is keeping them in contpte.c > appropriate? Hmm indeed, I'll see what I can do. > Perhaps it's better to keep huge_pte and contpte separate? Also, it > only works on arm64 because we can get away with calling the lower-level = pte > functions even when the huge_pte is actually a contpmd/pmd/pud, because t= he > format is the same. That might present challenges to other arches if the = format > is different? Yes, but I think that if that happens, we could get away with it by choosing the right function depending on the size of the mapping? > > - It might be easier to review if the arm64 stuff is first moved (withou= t > changes) then modified to make it suitable for riscv, then for riscv to b= e > hooked up. At the moment I'm trying to follow all 3 parts per-function. Ok, let me give it a try during your paternity leave! > > Thanks, > Ryan Thanks, Alex > > > > > > This patchset was tested by running the libhugetlbfs testsuite with 64K= B > > and 2MB pages on both architectures (on a 4KB base page size arm64 kern= el). > > > > [1] https://lore.kernel.org/linux-arm-kernel/20240215103205.2607016-1-r= yan.roberts@arm.com/ > > > > Changes in v2: > > - Rebase on top of 6.9-rc3 > > > > Alexandre Ghiti (9): > > riscv: Restore the pfn in a NAPOT pte when manipulated by core mm cod= e > > riscv: Safely remove huge_pte_offset() when manipulating NAPOT ptes > > mm: Use common huge_ptep_get() function for riscv/arm64 > > mm: Use common set_huge_pte_at() function for riscv/arm64 > > mm: Use common huge_pte_clear() function for riscv/arm64 > > mm: Use common huge_ptep_get_and_clear() function for riscv/arm64 > > mm: Use common huge_ptep_set_access_flags() function for riscv/arm64 > > mm: Use common huge_ptep_set_wrprotect() function for riscv/arm64 > > mm: Use common huge_ptep_clear_flush() function for riscv/arm64 > > > > arch/arm64/Kconfig | 1 + > > arch/arm64/include/asm/pgtable.h | 56 +++++- > > arch/arm64/mm/hugetlbpage.c | 291 +--------------------------- > > arch/riscv/Kconfig | 1 + > > arch/riscv/include/asm/hugetlb.h | 2 +- > > arch/riscv/include/asm/pgtable-64.h | 11 ++ > > arch/riscv/include/asm/pgtable.h | 153 +++++++++++++-- > > arch/riscv/mm/hugetlbpage.c | 227 ---------------------- > > arch/riscv/mm/pgtable.c | 6 +- > > mm/Kconfig | 3 + > > mm/Makefile | 1 + > > mm/contpte.c | 272 ++++++++++++++++++++++++++ > > 12 files changed, 480 insertions(+), 544 deletions(-) > > create mode 100644 mm/contpte.c > > >