linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Arjun Roy <arjunroy.kdev@gmail.com>,
	davem@davemloft.net, akpm@linux-foundation.org,
	linux-mm@kvack.org, arjunroy@google.com, soheil@google.com,
	edumazet@google.com
Subject: Re: [PATCH mm] mm: Bring sparc pte_index() semantics inline with other platforms.
Date: Sun, 1 Mar 2020 18:40:43 +0200	[thread overview]
Message-ID: <20200301164043.GA19967@hump.haifa.ibm.com> (raw)
In-Reply-To: <20200227105045.6b421d9f@canb.auug.org.au>

On Thu, Feb 27, 2020 at 10:50:45AM +1100, Stephen Rothwell wrote:
> Hi all,
> 
> On Fri, 21 Feb 2020 13:17:07 -0800 Arjun Roy <arjunroy.kdev@gmail.com> wrote:
> >
> > From: Arjun Roy <arjunroy@google.com>
> > 
> > pte_index() on platforms other than sparc return a numerical index.
> > On sparc, it returns a pte_t*. This presents an issue for
> > vm_insert_pages(), which relies on pte_index() to find the offset for
> > a pte within a pmd, for batched inserts.
> > 
> > This patch:
> > 1. Modifies pte_index() for sparc to return a numerical index, like
> >    other platforms,
> > 2. Defines pte_entry() for sparc which returns a pte_t*
> >    (as pte_index() used to),
> > 3. Converts existing sparc callers for pte_index() to use pte_entry().
> > 
> > Signed-off-by: Arjun Roy <arjunroy@google.com>
> > 
> > ---
> >  arch/sparc/include/asm/pgtable_64.h | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> > index 65494c3a420e..851ed0f99159 100644
> > --- a/arch/sparc/include/asm/pgtable_64.h
> > +++ b/arch/sparc/include/asm/pgtable_64.h
> > @@ -907,11 +907,12 @@ static inline unsigned long pud_pfn(pud_t pud)
> >  	 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)))
> >  
> >  /* Find an entry in the third-level page table.. */
> > -#define pte_index(dir, address)	\
> > -	((pte_t *) __pmd_page(*(dir)) + \
> > -	 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
> > -#define pte_offset_kernel		pte_index
> > -#define pte_offset_map			pte_index
> > +#define pte_index(address)	\
> > +	 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
> > +#define pte_entry(dir, address)	\
> > +	((pte_t *) __pmd_page(*(dir)) + pte_index(address))
> > +#define pte_offset_kernel		pte_entry
> > +#define pte_offset_map			pte_entry
> >  #define pte_unmap(pte)			do { } while (0)
> >  
> >  /* We cannot include <linux/mm_types.h> at this point yet: */
> > -- 
> > 2.25.0.265.gbab2e86ba0-goog
> 
> I have applied the following patch to the akpm tree today (just ahead
> of "mm/memory.c: add vm_insert_pages()") - this includes my suggested
> changes.
> 
> From: Arjun Roy <arjunroy@google.com>
> Date: Fri, 21 Feb 2020 13:17:07 -0800
> Subject: [PATCH] mm: Bring sparc pte_index() semantics inline with other platforms.
> 
> pte_index() on platforms other than sparc return a numerical index.
> On sparc, it returns a pte_t*. This presents an issue for
> vm_insert_pages(), which relies on pte_index() to find the offset for
> a pte within a pmd, for batched inserts.
> 
> This patch:
> 1. Modifies pte_index() for sparc to return a numerical index, like
>    other platforms,
> 2. Defines pte_entry() for sparc which returns a pte_t*
>    (as pte_index() used to),
> 3. Converts existing sparc callers for pte_index() to use pte_entry().
> 
> sfr: removed pte_entry and just directly modified pte_offset_kernel instead
> 
> Signed-off-by: Arjun Roy <arjunroy@google.com>
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>

FWIW: Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>

> ---
>  arch/sparc/include/asm/pgtable_64.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> index 65494c3a420e..930ea3c12739 100644
> --- a/arch/sparc/include/asm/pgtable_64.h
> +++ b/arch/sparc/include/asm/pgtable_64.h
> @@ -907,11 +907,11 @@ static inline unsigned long pud_pfn(pud_t pud)
>  	 (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1)))
>  
>  /* Find an entry in the third-level page table.. */
> -#define pte_index(dir, address)	\
> -	((pte_t *) __pmd_page(*(dir)) + \
> -	 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
> -#define pte_offset_kernel		pte_index
> -#define pte_offset_map			pte_index
> +#define pte_index(address)			\
> +	 ((address >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
> +#define pte_offset_kernel(dir, address)	\
> +	((pte_t *) __pmd_page(*(dir)) + pte_index(address))
> +#define pte_offset_map(dir, address)	pte_offset_kernel((dir), (address))
>  #define pte_unmap(pte)			do { } while (0)
>  
>  /* We cannot include <linux/mm_types.h> at this point yet: */
> -- 
> 2.25.1
> 
> -- 
> Cheers,
> Stephen Rothwell



-- 
Sincerely yours,
Mike.



      reply	other threads:[~2020-03-01 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-21 21:17 [PATCH mm] mm: Bring sparc pte_index() semantics inline with other platforms Arjun Roy
2020-02-21 21:25 ` Arjun Roy
2020-02-26  4:22 ` Stephen Rothwell
2020-02-26 23:50 ` Stephen Rothwell
2020-03-01 16:40   ` Mike Rapoport [this message]

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=20200301164043.GA19967@hump.haifa.ibm.com \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=arjunroy.kdev@gmail.com \
    --cc=arjunroy@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-mm@kvack.org \
    --cc=sfr@canb.auug.org.au \
    --cc=soheil@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).