linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: Sahil Mehta <smehta@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v2 2/2] powerpc/pseries: Implemented indexed-count hotplug memory remove
Date: Tue, 19 Jul 2016 12:56:19 -0500	[thread overview]
Message-ID: <578E69C3.4050309@linux.vnet.ibm.com> (raw)
In-Reply-To: <43770dca-871a-8f6c-6dbf-cdf842b6b442@linux.vnet.ibm.com>

On 07/18/2016 10:08 AM, Sahil Mehta wrote:
> Indexed-count remove for memory hotplug guarantees that a contiguous block
> of <count> lmbs beginning at a specified <index> will be unassigned (NOT
> that <count> lmbs will be removed). Because of Qemu's per-DIMM memory
> management, the removal of a contiguous block of memory currently
> requires a series of individual calls. Indexed-count remove reduces
> this series into a single call.
> 
> Signed-off-by: Sahil Mehta <smehta@linux.vnet.ibm.com>

Reviewed-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>

> ---
> v2:	-use u32s drc_index and count instead of u32 ic[]
> 	 in dlpar_memory
> 
>  arch/powerpc/platforms/pseries/hotplug-memory.c |   84 +++++++++++++++++++++++
>  1 file changed, 84 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c
> index d7942ca..244e1a8 100644
> --- a/arch/powerpc/platforms/pseries/hotplug-memory.c
> +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c
> @@ -503,6 +503,86 @@ static int dlpar_memory_remove_by_index(u32 drc_index, struct property *prop)
>  	return rc;
>  }
> 
> +static int dlpar_memory_remove_by_ic(u32 lmbs_to_remove, u32 drc_index,
> +				     struct property *prop)
> +{
> +	struct of_drconf_cell *lmbs;
> +	u32 num_lmbs, *p;
> +	int i, rc;
> +	int lmbs_available = 0, start_index = 0, end_index;
> +
> +	pr_info("Attempting to hot-remove %u LMB(s) at %x\n",
> +		lmbs_to_remove, drc_index);
> +
> +	if (lmbs_to_remove == 0)
> +		return -EINVAL;
> +
> +	p = prop->value;
> +	num_lmbs = *p++;
> +	lmbs = (struct of_drconf_cell *)p;
> +
> +	/* Navigate to drc_index */
> +	while (start_index < num_lmbs) {
> +		if (lmbs[start_index].drc_index == drc_index)
> +			break;
> +
> +		start_index++;
> +	}
> +
> +	end_index = start_index + lmbs_to_remove;
> +
> +	/* Validate that there are enough LMBs to satisfy the request */
> +	for (i = start_index; i < end_index; i++) {
> +		if (lmbs[i].flags & DRCONF_MEM_RESERVED)
> +			break;
> +
> +		lmbs_available++;
> +	}
> +
> +	if (lmbs_available < lmbs_to_remove)
> +		return -EINVAL;
> +
> +	for (i = 0; i < end_index; i++) {
> +		if (!(lmbs[i].flags & DRCONF_MEM_ASSIGNED))
> +			continue;
> +
> +		rc = dlpar_remove_lmb(&lmbs[i]);
> +		if (rc)
> +			break;
> +
> +		lmbs[i].reserved = 1;
> +	}
> +
> +	if (rc) {
> +		pr_err("Memory indexed-count-remove failed, adding any removed LMBs\n");
> +
> +		for (i = start_index; i < end_index; i++) {
> +			if (!lmbs[i].reserved)
> +				continue;
> +
> +			rc = dlpar_add_lmb(&lmbs[i]);
> +			if (rc)
> +				pr_err("Failed to add LMB, drc index %x\n",
> +				       be32_to_cpu(lmbs[i].drc_index));
> +
> +			lmbs[i].reserved = 0;
> +		}
> +		rc = -EINVAL;
> +	} else {
> +		for (i = start_index; i < end_index; i++) {
> +			if (!lmbs[i].reserved)
> +				continue;
> +
> +			pr_info("Memory at %llx (drc index %x) was hot-removed\n",
> +				lmbs[i].base_addr, lmbs[i].drc_index);
> +
> +			lmbs[i].reserved = 0;
> +		}
> +	}
> +
> +	return rc;
> +}
> +
>  #else
>  static inline int pseries_remove_memblock(unsigned long base,
>  					  unsigned int memblock_size)
> @@ -821,6 +901,10 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
>  		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_DRC_INDEX) {
>  			drc_index = hp_elog->_drc_u.drc_index;
>  			rc = dlpar_memory_remove_by_index(drc_index, prop);
> +		} else if (hp_elog->id_type == PSERIES_HP_ELOG_ID_IC) {
> +			count = hp_elog->_drc_u.indexed_count[0];
> +			drc_index = hp_elog->_drc_u.indexed_count[1];
> +			rc = dlpar_memory_remove_by_ic(count, drc_index, prop);
>  		} else
>  			rc = -EINVAL;
>  		break;
> 
> On 07/18/2016 10:04 AM, Sahil Mehta wrote:
>> Indexed-count memory management allows addition and removal of contiguous
>> lmb blocks with a single command. When compared to the series of calls
>> previously required to manage contiguous blocks, indexed-count decreases
>> command frequency and reduces risk of buffer overflow.
>>
>> Changes in v2:
>> --------------
>> -[PATCH 1/2]:	-remove potential memory leak when parsing command
>> 		-use u32s drc_index and count instead of u32 ic[]
>> 		 in dlpar_memory
>> -[PATCH 2/2]:	-use u32s drc_index and count instead of u32 ic[]
>> 		 in dlpar_memory
>>
>> -Sahil Mehta
>> ---
>>  include/asm/rtas.h                 |    2
>>  platforms/pseries/dlpar.c          |   34 ++++++
>>  platforms/pseries/hotplug-memory.c |  184 +++++++++++++++++++++++++++++++++++--
>>  3 files changed, 208 insertions(+), 12 deletions(-)
>>
>> _______________________________________________
>> Linuxppc-dev mailing list
>> Linuxppc-dev@lists.ozlabs.org
>> https://lists.ozlabs.org/listinfo/linuxppc-dev
>>
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
> 

      reply	other threads:[~2016-07-19 17:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-18 15:04 [PATCH v2 0/2] powerpc/pseries: Implemented indexed-count hotplug memory management Sahil Mehta
2016-07-18 15:07 ` [PATCH v2 1/2] powerpc/pseries: Implemented indexed-count hotplug memory add Sahil Mehta
2016-07-19 17:55   ` Nathan Fontenot
2016-07-19 18:31   ` Tyrel Datwyler
2016-07-19 23:36   ` Thomas Falcon
2016-07-18 15:08 ` [PATCH v2 2/2] powerpc/pseries: Implemented indexed-count hotplug memory remove Sahil Mehta
2016-07-19 17:56   ` Nathan Fontenot [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=578E69C3.4050309@linux.vnet.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=smehta@linux.vnet.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 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).