All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Haren Myneni <haren@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, mpe@ellerman.id.au,
	nathanl@linux.ibm.com
Subject: Re: [PATCH v4 7/9] powerpc/pseries/vas: Reopen windows with DLPAR core add
Date: Wed, 23 Feb 2022 17:28:30 +1000	[thread overview]
Message-ID: <1645601119.3ay9nmf9qs.astroid@bobo.none> (raw)
In-Reply-To: <a54ce2973c12602a73468446076115746fe71cf3.camel@linux.ibm.com>

Excerpts from Haren Myneni's message of February 20, 2022 6:01 am:
> 
> VAS windows can be closed in the hypervisor due to lost credits
> when the core is removed and the kernel gets fault for NX
> requests on these in-active windows. If these credits are
> available later for core add, reopen these windows and set them
> active. When the OS sees page faults on these active windows,
> it creates mapping on the new paste address. Then the user space
> can continue to use these windows and send HW compression
> requests to NX successfully.

Just for my own ignorance, what happens if userspace does not get
another page fault on that window? Presumably when it gets a page
fault it changes to an available window and doesn't just keep
re-trying. So in what situation does it attempt to re-access a
faulting window?

Thanks,
Nick

> 
> Signed-off-by: Haren Myneni <haren@linux.ibm.com>
> ---
>  arch/powerpc/platforms/pseries/vas.c | 91 +++++++++++++++++++++++++++-
>  1 file changed, 90 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/vas.c b/arch/powerpc/platforms/pseries/vas.c
> index a297720bcdae..96178dd58adf 100644
> --- a/arch/powerpc/platforms/pseries/vas.c
> +++ b/arch/powerpc/platforms/pseries/vas.c
> @@ -565,6 +565,88 @@ static int __init get_vas_capabilities(u8 feat, enum vas_cop_feat_type type,
>  	return 0;
>  }
>  
> +/*
> + * VAS windows can be closed due to lost credits when the core is
> + * removed. So reopen them if credits are available due to DLPAR
> + * core add and set the window active status. When NX sees the page
> + * fault on the unmapped paste address, the kernel handles the fault
> + * by setting the remapping to new paste address if the window is
> + * active.
> + */
> +static int reconfig_open_windows(struct vas_caps *vcaps, int creds)
> +{
> +	long domain[PLPAR_HCALL9_BUFSIZE] = {VAS_DEFAULT_DOMAIN_ID};
> +	struct vas_cop_feat_caps *caps = &vcaps->caps;
> +	struct pseries_vas_window *win = NULL, *tmp;
> +	int rc, mv_ents = 0;
> +
> +	/*
> +	 * Nothing to do if there are no closed windows.
> +	 */
> +	if (!vcaps->nr_close_wins)
> +		return 0;
> +
> +	/*
> +	 * For the core removal, the hypervisor reduces the credits
> +	 * assigned to the LPAR and the kernel closes VAS windows
> +	 * in the hypervisor depends on reduced credits. The kernel
> +	 * uses LIFO (the last windows that are opened will be closed
> +	 * first) and expects to open in the same order when credits
> +	 * are available.
> +	 * For example, 40 windows are closed when the LPAR lost 2 cores
> +	 * (dedicated). If 1 core is added, this LPAR can have 20 more
> +	 * credits. It means the kernel can reopen 20 windows. So move
> +	 * 20 entries in the VAS windows lost and reopen next 20 windows.
> +	 */
> +	if (vcaps->nr_close_wins > creds)
> +		mv_ents = vcaps->nr_close_wins - creds;
> +
> +	list_for_each_entry_safe(win, tmp, &vcaps->list, win_list) {
> +		if (!mv_ents)
> +			break;
> +
> +		mv_ents--;
> +	}
> +
> +	list_for_each_entry_safe_from(win, tmp, &vcaps->list, win_list) {
> +		/*
> +		 * Nothing to do on this window if it is not closed
> +		 * with VAS_WIN_NO_CRED_CLOSE
> +		 */
> +		if (!(win->vas_win.status & VAS_WIN_NO_CRED_CLOSE))
> +			continue;
> +
> +		rc = allocate_setup_window(win, (u64 *)&domain[0],
> +					   caps->win_type);
> +		if (rc)
> +			return rc;
> +
> +		rc = h_modify_vas_window(win);
> +		if (rc)
> +			goto out;
> +
> +		mutex_lock(&win->vas_win.task_ref.mmap_mutex);
> +		/*
> +		 * Set window status to active
> +		 */
> +		win->vas_win.status &= ~VAS_WIN_NO_CRED_CLOSE;
> +		mutex_unlock(&win->vas_win.task_ref.mmap_mutex);
> +		win->win_type = caps->win_type;
> +		if (!--vcaps->nr_close_wins)
> +			break;
> +	}
> +
> +	return 0;
> +out:
> +	/*
> +	 * Window modify HCALL failed. So close the window to the
> +	 * hypervisor and return.
> +	 */
> +	free_irq_setup(win);
> +	h_deallocate_vas_window(win->vas_win.winid);
> +	return rc;
> +}
> +
>  /*
>   * The hypervisor reduces the available credits if the LPAR lost core. It
>   * means the excessive windows should not be active and the user space
> @@ -673,7 +755,14 @@ static int vas_reconfig_capabilties(u8 type)
>  	 * closed / reopened. Hold the vas_pseries_mutex so that the
>  	 * the user space can not open new windows.
>  	 */
> -	if (old_nr_creds >  new_nr_creds) {
> +	if (old_nr_creds <  new_nr_creds) {
> +		/*
> +		 * If the existing target credits is less than the new
> +		 * target, reopen windows if they are closed due to
> +		 * the previous DLPAR (core removal).
> +		 */
> +		rc = reconfig_open_windows(vcaps, new_nr_creds - old_nr_creds);
> +	} else {
>  		/*
>  		 * # active windows is more than new LPAR available
>  		 * credits. So close the excessive windows.
> -- 
> 2.27.0
> 
> 
> 

  reply	other threads:[~2022-02-23  7:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-19 19:49 [PATCH v4 0/9] powerpc/pseries/vas: NXGZIP support with DLPAR Haren Myneni
2022-02-19 19:54 ` [PATCH v4 1/9] powerpc/pseries/vas: Use common names in VAS capability structure Haren Myneni
2022-02-19 19:55 ` [PATCH v4 2/9] powerpc/pseries/vas: Save PID in pseries_vas_window struct Haren Myneni
2022-02-23  7:00   ` Nicholas Piggin
2022-02-19 19:55 ` [PATCH v4 3/9] powerpc/vas: Add paste address mmap fault handler Haren Myneni
2022-02-23  7:03   ` Nicholas Piggin
2022-02-19 19:58 ` [PATCH v4 4/9] powerpc/vas: Return paste instruction failure if no active window Haren Myneni
2022-02-23  7:05   ` Nicholas Piggin
2022-02-23  7:56     ` Haren Myneni
2022-02-19 19:59 ` [PATCH v4 5/9] powerpc/vas: Map paste address only if window is active Haren Myneni
2022-02-23  7:11   ` Nicholas Piggin
2022-02-23  8:02     ` Haren Myneni
2022-02-19 20:00 ` [PATCH v4 6/9] powerpc/pseries/vas: Close windows with DLPAR core removal Haren Myneni
2022-02-23  7:23   ` Nicholas Piggin
2022-02-23  8:21     ` Haren Myneni
2022-02-19 20:01 ` [PATCH v4 7/9] powerpc/pseries/vas: Reopen windows with DLPAR core add Haren Myneni
2022-02-23  7:28   ` Nicholas Piggin [this message]
2022-02-23  8:32     ` Haren Myneni
2022-02-19 20:01 ` [PATCH v4 8/9] powerpc/pseries/vas: sysfs interface to export capabilities Haren Myneni
2022-02-23  7:29   ` Nicholas Piggin
2022-02-19 20:03 ` [PATCH v4 9/9] powerpc/pseries/vas: Write 'nr_total_credits' for QoS credits change Haren Myneni
2022-02-23  7:33   ` Nicholas Piggin
2022-02-23  8:39     ` Haren Myneni

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=1645601119.3ay9nmf9qs.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=haren@linux.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=nathanl@linux.ibm.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.