All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>, linuxppc-dev@ozlabs.org
Cc: npiggin@gmail.com
Subject: Re: [PATCH 2/4] powerpc/64s: Add slb_full_bitmap rather than hard-coding U32_MAX
Date: Wed, 23 Jan 2019 14:32:38 +0530	[thread overview]
Message-ID: <871s53d9w1.fsf@linux.ibm.com> (raw)
In-Reply-To: <20190117121328.13395-2-mpe@ellerman.id.au>

Michael Ellerman <mpe@ellerman.id.au> writes:

> The recent rewrite of the SLB code into C included the assumption that
> all CPUs we run on have at least 32 SLB entries. This is currently
> true but a bit fragile as the SLB size is actually defined by the
> device tree and so could theoretically change at any time.
>
> The assumption is encoded in the fact that we use U32_MAX as the value
> for a full SLB bitmap. Instead, calculate what the full bitmap would
> be based on the SLB size we're given and store it. This still requires
> the SLB size to be a power of 2.

So if it is less than 32 we want to make sure we don't allocate an index
above 32. Is this the reason for that radom assert_slb_presence?

Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> 

>
> Fixes: 126b11b294d1 ("powerpc/64s/hash: Add SLB allocation status bitmaps")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/mm/slb.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
> index bc3914d54e26..61450a9cf30d 100644
> --- a/arch/powerpc/mm/slb.c
> +++ b/arch/powerpc/mm/slb.c
> @@ -506,9 +506,16 @@ void switch_slb(struct task_struct *tsk, struct mm_struct *mm)
>  	asm volatile("isync" : : : "memory");
>  }
>  
> +static u32 slb_full_bitmap;
> +
>  void slb_set_size(u16 size)
>  {
>  	mmu_slb_size = size;
> +
> +	if (size >= 32)
> +		slb_full_bitmap = U32_MAX;
> +	else
> +		slb_full_bitmap = (1ul << size) - 1;
>  }
>  
>  void slb_initialize(void)
> @@ -611,7 +618,7 @@ static enum slb_index alloc_slb_index(bool kernel)
>  	 * POWER7/8/9 have 32 SLB entries, this could be expanded if a
>  	 * future CPU has more.
>  	 */
> -	if (local_paca->slb_used_bitmap != U32_MAX) {
> +	if (local_paca->slb_used_bitmap != slb_full_bitmap) {
>  		index = ffz(local_paca->slb_used_bitmap);
>  		local_paca->slb_used_bitmap |= 1U << index;
>  		if (kernel)
> -- 
> 2.20.1


  parent reply	other threads:[~2019-01-23  9:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 12:13 [PATCH 1/4] powerpc/64s: Always set mmu_slb_size using slb_set_size() Michael Ellerman
2019-01-17 12:13 ` [PATCH 2/4] powerpc/64s: Add slb_full_bitmap rather than hard-coding U32_MAX Michael Ellerman
2019-01-17 16:30   ` Segher Boessenkool
2019-01-18 12:28     ` Michael Ellerman
2019-01-18 23:12       ` Segher Boessenkool
2019-01-23  9:02   ` Aneesh Kumar K.V [this message]
2019-01-17 12:13 ` [PATCH 3/4] powerpc/64s: Move SLB init into hash_utils_64.c Michael Ellerman
2019-01-23  9:04   ` Aneesh Kumar K.V
2019-01-17 12:13 ` [PATCH 4/4] powerpc/64s: Support shrinking the SLB for debugging Michael Ellerman
2019-01-19  0:13   ` Michal Suchánek
2019-01-19 10:27     ` Michael Ellerman
2019-01-23  8:40       ` Nicholas Piggin
2019-01-23  9:10   ` Aneesh Kumar K.V
2019-01-23  8:59 ` [PATCH 1/4] powerpc/64s: Always set mmu_slb_size using slb_set_size() Aneesh Kumar K.V

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=871s53d9w1.fsf@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.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 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.