From: Rolf Eike Beer <eb@emlix.com>
To: Matthew Wilcox <willy@infradead.org>,
linux-arch@vger.kernel.org, Alexandre Ghiti <alex@ghiti.fr>
Cc: Yin Fengwei <fengwei.yin@intel.com>,
linux-mm@kvack.org, linux-alpha@vger.kernel.org,
linux-csky@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-mips@vger.kernel.org, Dinh Nguyen <dinguyen@kernel.org>,
linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev,
openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org,
linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org,
linux-xtensa@linux-xtensa.org
Subject: Re: API for setting multiple PTEs at once
Date: Mon, 20 Feb 2023 09:29:58 +0100 [thread overview]
Message-ID: <5649318.DvuYhMxLoT@devpool47> (raw)
In-Reply-To: <0bf59207-838b-2a0b-a95e-925a6bbf1913@ghiti.fr>
[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]
On Dienstag, 14. Februar 2023 10:55:43 CET Alexandre Ghiti wrote:
> Hi Matthew,
>
> On 2/7/23 21:27, Matthew Wilcox wrote:
> > On Thu, Feb 02, 2023 at 09:14:23PM +0000, Matthew Wilcox wrote:
> >> For those of you not subscribed, linux-mm is currently discussing
> >> how best to handle page faults on large folios. I simply made it work
> >> when adding large folio support. Now Yin Fengwei is working on
> >> making it fast.
> >
> > OK, here's an actual implementation:
> >
> > https://lore.kernel.org/linux-mm/20230207194937.122543-3-willy@infradead.o
> > rg/
> >
> > It survives a run of xfstests. If your architecture doesn't store its
> > PFNs at PAGE_SHIFT, you're going to want to implement your own set_ptes(),
> > or you'll see entirely the wrong pages mapped into userspace. You may
> > also wish to implement set_ptes() if it can be done more efficiently
> > than __pte(pteval(pte) + PAGE_SIZE).
> >
> > Architectures that implement things like flush_icache_page() and
> > update_mmu_cache() may want to propose batched versions of those.
> > That's alpha, csky, m68k, mips, nios2, parisc, sh,
> > arm, loongarch, openrisc, powerpc, riscv, sparc and xtensa.
> > Maintainers BCC'd, mailing lists CC'd.
> >
> > I'm happy to collect implementations and submit them as part of a v6.
>
> Please find below the riscv implementation for set_ptes:
>
> diff --git a/arch/riscv/include/asm/pgtable.h
> b/arch/riscv/include/asm/pgtable.h
> index ebee56d47003..10bf812776a4 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -463,6 +463,20 @@ static inline void set_pte_at(struct mm_struct *mm,
> __set_pte_at(mm, addr, ptep, pteval);
> }
>
> +#define set_ptes set_ptes
> +static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
> + pte_t *ptep, pte_t pte, unsigned int nr)
> +{
> + for (;;) {
> + set_pte_at(mm, addr, ptep, pte);
> + if (--nr == 0)
> + break;
> + ptep++;
> + addr += PAGE_SIZE;
> + pte = __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
> + }
> +}
Given that this is the same code as the original version (surprise!), what
about doing something like this in the generic code instead:
#ifndef PTE_PAGE_STEP
#define PTE_PAGE_STEP PAGE_SIZE
#endif
[…]
> + pte = __pte(pte_val(pte) + PTE_PAGE_STEP);
The name of the define is an obvious candidate for bike-shedding, feel free to
name it as you want.
Or if that isn't sound enough maybe introduce something like:
static inline pte_t
set_ptes_next_pte(pte_t pte)
{
return __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
}
Greetings,
Eike
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Rolf Eike Beer <eb@emlix.com>
To: Matthew Wilcox <willy@infradead.org>,
linux-arch@vger.kernel.org, Alexandre Ghiti <alex@ghiti.fr>
Cc: Yin Fengwei <fengwei.yin@intel.com>,
linux-mm@kvack.org, linux-alpha@vger.kernel.org,
linux-csky@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-mips@vger.kernel.org, Dinh Nguyen <dinguyen@kernel.org>,
linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev,
openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org,
linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org,
linux-xtensa@linux-xtensa.org
Subject: Re: API for setting multiple PTEs at once
Date: Mon, 20 Feb 2023 09:29:58 +0100 [thread overview]
Message-ID: <5649318.DvuYhMxLoT@devpool47> (raw)
In-Reply-To: <0bf59207-838b-2a0b-a95e-925a6bbf1913@ghiti.fr>
[-- Attachment #1.1: Type: text/plain, Size: 3141 bytes --]
On Dienstag, 14. Februar 2023 10:55:43 CET Alexandre Ghiti wrote:
> Hi Matthew,
>
> On 2/7/23 21:27, Matthew Wilcox wrote:
> > On Thu, Feb 02, 2023 at 09:14:23PM +0000, Matthew Wilcox wrote:
> >> For those of you not subscribed, linux-mm is currently discussing
> >> how best to handle page faults on large folios. I simply made it work
> >> when adding large folio support. Now Yin Fengwei is working on
> >> making it fast.
> >
> > OK, here's an actual implementation:
> >
> > https://lore.kernel.org/linux-mm/20230207194937.122543-3-willy@infradead.o
> > rg/
> >
> > It survives a run of xfstests. If your architecture doesn't store its
> > PFNs at PAGE_SHIFT, you're going to want to implement your own set_ptes(),
> > or you'll see entirely the wrong pages mapped into userspace. You may
> > also wish to implement set_ptes() if it can be done more efficiently
> > than __pte(pteval(pte) + PAGE_SIZE).
> >
> > Architectures that implement things like flush_icache_page() and
> > update_mmu_cache() may want to propose batched versions of those.
> > That's alpha, csky, m68k, mips, nios2, parisc, sh,
> > arm, loongarch, openrisc, powerpc, riscv, sparc and xtensa.
> > Maintainers BCC'd, mailing lists CC'd.
> >
> > I'm happy to collect implementations and submit them as part of a v6.
>
> Please find below the riscv implementation for set_ptes:
>
> diff --git a/arch/riscv/include/asm/pgtable.h
> b/arch/riscv/include/asm/pgtable.h
> index ebee56d47003..10bf812776a4 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -463,6 +463,20 @@ static inline void set_pte_at(struct mm_struct *mm,
> __set_pte_at(mm, addr, ptep, pteval);
> }
>
> +#define set_ptes set_ptes
> +static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
> + pte_t *ptep, pte_t pte, unsigned int nr)
> +{
> + for (;;) {
> + set_pte_at(mm, addr, ptep, pte);
> + if (--nr == 0)
> + break;
> + ptep++;
> + addr += PAGE_SIZE;
> + pte = __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
> + }
> +}
Given that this is the same code as the original version (surprise!), what
about doing something like this in the generic code instead:
#ifndef PTE_PAGE_STEP
#define PTE_PAGE_STEP PAGE_SIZE
#endif
[…]
> + pte = __pte(pte_val(pte) + PTE_PAGE_STEP);
The name of the define is an obvious candidate for bike-shedding, feel free to
name it as you want.
Or if that isn't sound enough maybe introduce something like:
static inline pte_t
set_ptes_next_pte(pte_t pte)
{
return __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
}
Greetings,
Eike
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
[-- Attachment #2: Type: text/plain, Size: 161 bytes --]
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Rolf Eike Beer <eb@emlix.com>
To: Matthew Wilcox <willy@infradead.org>,
linux-arch@vger.kernel.org, Alexandre Ghiti <alex@ghiti.fr>
Cc: linux-xtensa@linux-xtensa.org, linux-parisc@vger.kernel.org,
Dinh Nguyen <dinguyen@kernel.org>,
linux-sh@vger.kernel.org, linux-mips@vger.kernel.org,
linux-csky@vger.kernel.org, Yin Fengwei <fengwei.yin@intel.com>,
linux-mm@kvack.org, linux-m68k@lists.linux-m68k.org,
openrisc@lists.librecores.org, loongarch@lists.linux.dev,
linux-alpha@vger.kernel.org, sparclinux@vger.kernel.org,
linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: API for setting multiple PTEs at once
Date: Mon, 20 Feb 2023 09:29:58 +0100 [thread overview]
Message-ID: <5649318.DvuYhMxLoT@devpool47> (raw)
In-Reply-To: <0bf59207-838b-2a0b-a95e-925a6bbf1913@ghiti.fr>
[-- Attachment #1: Type: text/plain, Size: 3141 bytes --]
On Dienstag, 14. Februar 2023 10:55:43 CET Alexandre Ghiti wrote:
> Hi Matthew,
>
> On 2/7/23 21:27, Matthew Wilcox wrote:
> > On Thu, Feb 02, 2023 at 09:14:23PM +0000, Matthew Wilcox wrote:
> >> For those of you not subscribed, linux-mm is currently discussing
> >> how best to handle page faults on large folios. I simply made it work
> >> when adding large folio support. Now Yin Fengwei is working on
> >> making it fast.
> >
> > OK, here's an actual implementation:
> >
> > https://lore.kernel.org/linux-mm/20230207194937.122543-3-willy@infradead.o
> > rg/
> >
> > It survives a run of xfstests. If your architecture doesn't store its
> > PFNs at PAGE_SHIFT, you're going to want to implement your own set_ptes(),
> > or you'll see entirely the wrong pages mapped into userspace. You may
> > also wish to implement set_ptes() if it can be done more efficiently
> > than __pte(pteval(pte) + PAGE_SIZE).
> >
> > Architectures that implement things like flush_icache_page() and
> > update_mmu_cache() may want to propose batched versions of those.
> > That's alpha, csky, m68k, mips, nios2, parisc, sh,
> > arm, loongarch, openrisc, powerpc, riscv, sparc and xtensa.
> > Maintainers BCC'd, mailing lists CC'd.
> >
> > I'm happy to collect implementations and submit them as part of a v6.
>
> Please find below the riscv implementation for set_ptes:
>
> diff --git a/arch/riscv/include/asm/pgtable.h
> b/arch/riscv/include/asm/pgtable.h
> index ebee56d47003..10bf812776a4 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -463,6 +463,20 @@ static inline void set_pte_at(struct mm_struct *mm,
> __set_pte_at(mm, addr, ptep, pteval);
> }
>
> +#define set_ptes set_ptes
> +static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
> + pte_t *ptep, pte_t pte, unsigned int nr)
> +{
> + for (;;) {
> + set_pte_at(mm, addr, ptep, pte);
> + if (--nr == 0)
> + break;
> + ptep++;
> + addr += PAGE_SIZE;
> + pte = __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
> + }
> +}
Given that this is the same code as the original version (surprise!), what
about doing something like this in the generic code instead:
#ifndef PTE_PAGE_STEP
#define PTE_PAGE_STEP PAGE_SIZE
#endif
[…]
> + pte = __pte(pte_val(pte) + PTE_PAGE_STEP);
The name of the define is an obvious candidate for bike-shedding, feel free to
name it as you want.
Or if that isn't sound enough maybe introduce something like:
static inline pte_t
set_ptes_next_pte(pte_t pte)
{
return __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
}
Greetings,
Eike
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Rolf Eike Beer <eb@emlix.com>
To: Matthew Wilcox <willy@infradead.org>,
linux-arch@vger.kernel.org, Alexandre Ghiti <alex@ghiti.fr>
Cc: Yin Fengwei <fengwei.yin@intel.com>,
linux-mm@kvack.org, linux-alpha@vger.kernel.org,
linux-csky@vger.kernel.org, linux-m68k@lists.linux-m68k.org,
linux-mips@vger.kernel.org, Dinh Nguyen <dinguyen@kernel.org>,
linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, loongarch@lists.linux.dev,
openrisc@lists.librecores.org, linuxppc-dev@lists.ozlabs.org,
linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org,
linux-xtensa@linux-xtensa.org
Subject: Re: API for setting multiple PTEs at once
Date: Mon, 20 Feb 2023 09:29:58 +0100 [thread overview]
Message-ID: <5649318.DvuYhMxLoT@devpool47> (raw)
In-Reply-To: <0bf59207-838b-2a0b-a95e-925a6bbf1913@ghiti.fr>
[-- Attachment #1.1: Type: text/plain, Size: 3141 bytes --]
On Dienstag, 14. Februar 2023 10:55:43 CET Alexandre Ghiti wrote:
> Hi Matthew,
>
> On 2/7/23 21:27, Matthew Wilcox wrote:
> > On Thu, Feb 02, 2023 at 09:14:23PM +0000, Matthew Wilcox wrote:
> >> For those of you not subscribed, linux-mm is currently discussing
> >> how best to handle page faults on large folios. I simply made it work
> >> when adding large folio support. Now Yin Fengwei is working on
> >> making it fast.
> >
> > OK, here's an actual implementation:
> >
> > https://lore.kernel.org/linux-mm/20230207194937.122543-3-willy@infradead.o
> > rg/
> >
> > It survives a run of xfstests. If your architecture doesn't store its
> > PFNs at PAGE_SHIFT, you're going to want to implement your own set_ptes(),
> > or you'll see entirely the wrong pages mapped into userspace. You may
> > also wish to implement set_ptes() if it can be done more efficiently
> > than __pte(pteval(pte) + PAGE_SIZE).
> >
> > Architectures that implement things like flush_icache_page() and
> > update_mmu_cache() may want to propose batched versions of those.
> > That's alpha, csky, m68k, mips, nios2, parisc, sh,
> > arm, loongarch, openrisc, powerpc, riscv, sparc and xtensa.
> > Maintainers BCC'd, mailing lists CC'd.
> >
> > I'm happy to collect implementations and submit them as part of a v6.
>
> Please find below the riscv implementation for set_ptes:
>
> diff --git a/arch/riscv/include/asm/pgtable.h
> b/arch/riscv/include/asm/pgtable.h
> index ebee56d47003..10bf812776a4 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -463,6 +463,20 @@ static inline void set_pte_at(struct mm_struct *mm,
> __set_pte_at(mm, addr, ptep, pteval);
> }
>
> +#define set_ptes set_ptes
> +static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
> + pte_t *ptep, pte_t pte, unsigned int nr)
> +{
> + for (;;) {
> + set_pte_at(mm, addr, ptep, pte);
> + if (--nr == 0)
> + break;
> + ptep++;
> + addr += PAGE_SIZE;
> + pte = __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
> + }
> +}
Given that this is the same code as the original version (surprise!), what
about doing something like this in the generic code instead:
#ifndef PTE_PAGE_STEP
#define PTE_PAGE_STEP PAGE_SIZE
#endif
[…]
> + pte = __pte(pte_val(pte) + PTE_PAGE_STEP);
The name of the define is an obvious candidate for bike-shedding, feel free to
name it as you want.
Or if that isn't sound enough maybe introduce something like:
static inline pte_t
set_ptes_next_pte(pte_t pte)
{
return __pte(pte_val(pte) + (1 << _PAGE_PFN_SHIFT));
}
Greetings,
Eike
--
Rolf Eike Beer, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax +49 551 30664-11
Gothaer Platz 3, 37083 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Heike Jordan, Dr. Uwe Kracke – Ust-IdNr.: DE 205 198 055
emlix - smart embedded open source
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 313 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-02-20 8:29 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 21:14 API for setting multiple PTEs at once Matthew Wilcox
2023-02-02 21:48 ` Kirill A. Shutemov
2023-02-02 22:49 ` Matthew Wilcox
2023-02-02 23:27 ` Kirill A. Shutemov
2023-02-07 20:27 ` Matthew Wilcox
2023-02-07 20:27 ` Matthew Wilcox
2023-02-07 20:27 ` Matthew Wilcox
2023-02-07 20:27 ` Matthew Wilcox
2023-02-08 11:23 ` Alexandre Ghiti
2023-02-08 11:23 ` Alexandre Ghiti
2023-02-08 11:23 ` Alexandre Ghiti
2023-02-08 11:23 ` Alexandre Ghiti
2023-02-08 12:09 ` Yin, Fengwei
2023-02-08 12:09 ` Yin, Fengwei
2023-02-08 12:09 ` Yin, Fengwei
2023-02-08 12:09 ` Yin, Fengwei
2023-02-08 12:09 ` Yin, Fengwei
2023-02-08 13:35 ` Matthew Wilcox
2023-02-08 13:35 ` Matthew Wilcox
2023-02-08 13:35 ` Matthew Wilcox
2023-02-08 13:35 ` Matthew Wilcox
2023-02-14 9:55 ` Alexandre Ghiti
2023-02-14 9:55 ` Alexandre Ghiti
2023-02-14 9:55 ` Alexandre Ghiti
2023-02-14 9:55 ` Alexandre Ghiti
2023-02-20 8:29 ` Rolf Eike Beer [this message]
2023-02-20 8:29 ` Rolf Eike Beer
2023-02-20 8:29 ` Rolf Eike Beer
2023-02-20 8:29 ` Rolf Eike Beer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5649318.DvuYhMxLoT@devpool47 \
--to=eb@emlix.com \
--cc=alex@ghiti.fr \
--cc=dinguyen@kernel.org \
--cc=fengwei.yin@intel.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-csky@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-parisc@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-sh@vger.kernel.org \
--cc=linux-xtensa@linux-xtensa.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=loongarch@lists.linux.dev \
--cc=openrisc@lists.librecores.org \
--cc=sparclinux@vger.kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.