All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fabiano Rosas <farosas@linux.ibm.com>
To: Nicholas Piggin <npiggin@gmail.com>, linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH 3/6] KVM: PPC: Book3S HV: Use IDA allocator for LPID allocator
Date: Mon, 24 Jan 2022 19:13:40 -0300	[thread overview]
Message-ID: <87ilu8eq97.fsf@linux.ibm.com> (raw)
In-Reply-To: <20220123120043.3586018-4-npiggin@gmail.com>

Nicholas Piggin <npiggin@gmail.com> writes:

> This removes the fixed-size lpid_inuse array.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>

>  arch/powerpc/kvm/powerpc.c | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 102993462872..c527a5751b46 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -2453,20 +2453,22 @@ long kvm_arch_vm_ioctl(struct file *filp,
>  	return r;
>  }
>
> -static unsigned long lpid_inuse[BITS_TO_LONGS(KVMPPC_NR_LPIDS)];
> +static DEFINE_IDA(lpid_inuse);
>  static unsigned long nr_lpids;
>
>  long kvmppc_alloc_lpid(void)
>  {
> -	long lpid;
> +	int lpid;
>
> -	do {
> -		lpid = find_first_zero_bit(lpid_inuse, KVMPPC_NR_LPIDS);
> -		if (lpid >= nr_lpids) {
> +	/* The host LPID must always be 0 (allocation starts at 1) */
> +	lpid = ida_alloc_range(&lpid_inuse, 1, nr_lpids - 1, GFP_KERNEL);
> +	if (lpid < 0) {
> +		if (lpid == -ENOMEM)
> +			pr_err("%s: Out of memory\n", __func__);
> +		else
>  			pr_err("%s: No LPIDs free\n", __func__);
> -			return -ENOMEM;
> -		}
> -	} while (test_and_set_bit(lpid, lpid_inuse));
> +		return -ENOMEM;
> +	}
>
>  	return lpid;
>  }
> @@ -2474,15 +2476,14 @@ EXPORT_SYMBOL_GPL(kvmppc_alloc_lpid);
>
>  void kvmppc_free_lpid(long lpid)
>  {
> -	clear_bit(lpid, lpid_inuse);
> +	ida_free(&lpid_inuse, lpid);
>  }
>  EXPORT_SYMBOL_GPL(kvmppc_free_lpid);
>
> +/* nr_lpids_param includes the host LPID */
>  void kvmppc_init_lpid(unsigned long nr_lpids_param)
>  {
> -	nr_lpids = min_t(unsigned long, KVMPPC_NR_LPIDS, nr_lpids_param);
> -	memset(lpid_inuse, 0, sizeof(lpid_inuse));
> -	set_bit(0, lpid_inuse); /* The host LPID must always be 0 */
> +	nr_lpids = nr_lpids_param;
>  }
>  EXPORT_SYMBOL_GPL(kvmppc_init_lpid);

  reply	other threads:[~2022-01-24 22:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-23 12:00 [PATCH 0/6] KVM: PPC: Book3S: Make LPID/nested LPID allocations dynamic Nicholas Piggin
2022-01-23 12:00 ` [PATCH 1/6] KVM: PPC: Remove kvmppc_claim_lpid Nicholas Piggin
2022-01-23 12:00 ` [PATCH 2/6] KVM: PPC: Book3S HV: Update LPID allocator init for POWER9, Nested Nicholas Piggin
2022-01-24 22:13   ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 3/6] KVM: PPC: Book3S HV: Use IDA allocator for LPID allocator Nicholas Piggin
2022-01-24 22:13   ` Fabiano Rosas [this message]
2022-01-23 12:00 ` [PATCH 4/6] KVM: PPC: Book3S HV Nested: Change nested guest lookup to use idr Nicholas Piggin
2022-01-24 22:14   ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 5/6] KVM: PPC: Book3S Nested: Use explicit 4096 LPID maximum Nicholas Piggin
2022-01-24 22:15   ` Fabiano Rosas
2022-01-23 12:00 ` [PATCH 6/6] KVM: PPC: Book3S HV: Remove KVMPPC_NR_LPIDS Nicholas Piggin
2022-01-24 22:15   ` Fabiano Rosas
2022-05-24 10:51 ` [PATCH 0/6] KVM: PPC: Book3S: Make LPID/nested LPID allocations dynamic Michael Ellerman

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=87ilu8eq97.fsf@linux.ibm.com \
    --to=farosas@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --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.