Re: [PATCH 0/3] x86/kexec_file: Fix some corners bugs and improve the crash_exclude_mem_range()

2020-08-04 Thread Dave Young
Hi Lianbo,

Added Andrew in cc.
On 08/04/20 at 12:49pm, Lianbo Jiang wrote:
> This series includes the following patches, it fixes some corners bugs
> and improves the crash_exclude_mem_range().
> 
> [1] [PATCH 1/3] x86/crash: Correct the address boundary of function
> parameters
> [2] [PATCH 2/3] kexec: Improve the crash_exclude_mem_range() to handle
> the overlapping ranges
> [3] [PATCH 3/3] kexec_file: correctly output debugging information for
> the PT_LOAD elf header
> 
> Lianbo Jiang (3):
>   x86/crash: Correct the address boundary of function parameters
>   kexec: Improve the crash_exclude_mem_range() to handle the overlapping
> ranges
>   kexec_file: correctly output debugging information for the PT_LOAD elf
> header
> 
>  arch/x86/kernel/crash.c |  2 +-
>  kernel/kexec_file.c | 33 ++---
>  2 files changed, 23 insertions(+), 12 deletions(-)
> 
> -- 
> 2.17.1

Looks good, thanks for the patches

Acked-by: Dave Young 

Thanks
Dave


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCHv4 2/2] powerpc/pseries: update device tree before ejecting hotplug uevents

2020-08-04 Thread Pingfan Liu
On Tue, Aug 4, 2020 at 12:29 AM Laurent Dufour  wrote:
>
[...]
> >   lmb_set_nid(lmb);
> >   lmb->flags |= DRCONF_MEM_ASSIGNED;
> > + if (dt_update) {
> > + ret = drmem_update_dt();
> > + if (ret)
> > + pr_warn("%s fail to update dt, but continue\n", 
> > __func__);
> > + }
> >
> >   block_sz = memory_block_size_bytes();
>
> In the case the call to __add_memory is failing, the flag DRCONF_MEM_ASSIGNED
> should be cleared as I mentioned in your previous patch. In addition to this,
Yes.
> the DT should be updated, or the caller should manage that but that will be 
> hard
> since it doesn't know where the error happened in this function.
Yeah, it is hard to manage it by caller, so just updating dt  is a
easier method.
>
> >
> > @@ -625,7 +653,11 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
> >   invalidate_lmb_associativity_index(lmb);
> >   lmb_clear_nid(lmb);
> >   lmb->flags &= ~DRCONF_MEM_ASSIGNED;
> > -
> > + if (dt_update) {
> > + ret = drmem_update_dt();
> > + if (ret)
> > + pr_warn("%s fail to update dt during 
> > rollback, but continue\n", __func__);
> > + }
> >   __remove_memory(nid, base_addr, block_sz);
> >   }
> >
> > @@ -638,6 +670,7 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
> >   int lmbs_available = 0;
> >   int lmbs_added = 0;
> >   int rc;
> > + bool dt_update = false;
> >
> >   pr_info("Attempting to hot-add %d LMB(s)\n", lmbs_to_add);
> >
> > @@ -664,7 +697,7 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
> >   if (rc)
> >   continue;
> >
> > - rc = dlpar_add_lmb(lmb);
> > + rc = dlpar_add_lmb(lmb, dt_update);
> >   if (rc) {
> >   dlpar_release_drc(lmb->drc_index);
> >   continue;
> > @@ -678,16 +711,23 @@ static int dlpar_memory_add_by_count(u32 lmbs_to_add)
> >   lmbs_added++;
> >   if (lmbs_added == lmbs_to_add)
> >   break;
> > + else if (lmbs_added == lmbs_to_add - 1)
> > + dt_update = true;
>
> In the case the number of LMB to add is 1, dt_update is never set to true, and
> the device tree is never updated. You need to set dt_update to true earlier in
> the loop block.
Oh, I will fix it in V5
>
> >   }
> >
> >   if (lmbs_added != lmbs_to_add) {
> > + bool rollback_dt_update = false;
> > +
> >   pr_err("Memory hot-add failed, removing any added LMBs\n");
> >
> >   for_each_drmem_lmb(lmb) {
> >   if (!drmem_lmb_reserved(lmb))
> >   continue;
> >
> > - rc = dlpar_remove_lmb(lmb);
> > + if (--lmbs_added == 0 && dt_update)
> > + rollback_dt_update = true;
>
> That test may have to be review to deal with error during the last LMB 
> addition,
> the DT may have been updated before __add_memory() is failing in
> dlpar_add_lmb(). In that case, lmbs_added == 0 and that branch is not covered.
> That's not an issue if dlpar_add_lmb() is handling that case (see my comment 
> above).
I will fix it in next version.

Thanks for your review.

Regards,
Pingfan

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCHv4 1/2] powerpc/pseries: group lmb operation and memblock's

2020-08-04 Thread Pingfan Liu
On Mon, Aug 3, 2020 at 9:52 PM Laurent Dufour  wrote:
>
> > @@ -603,6 +606,8 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
> > }
> >
> > lmb_set_nid(lmb);
> > +   lmb->flags |= DRCONF_MEM_ASSIGNED;
> > +
> > block_sz = memory_block_size_bytes();
> >
> > /* Add the memory */
>
> Since the lmb->flags is now set earlier, you should unset it in the case the
> call to __add_memory() fails, something like:
>
> @@ -614,6 +614,7 @@ static int dlpar_add_lmb(struct drmem_lmb *lmb)
> rc = __add_memory(lmb->nid, lmb->base_addr, block_sz);
> if (rc) {
> invalidate_lmb_associativity_index(lmb);
> +   lmb->flags &= ~DRCONF_MEM_ASSIGNED;
You are right. I will fix it in V5.

Thanks,
Pingfan

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH v2][next] printk: ringbuffer: support dataless records

2020-08-04 Thread Petr Mladek
On Tue 2020-07-21 15:31:28, John Ogness wrote:
> With commit ("printk: use the lockless ringbuffer"), printk()
> started silently dropping messages without text because such
> records are not supported by the new printk ringbuffer.
> 
> Add support for such records.
> 
> Currently dataless records are denoted by INVALID_LPOS in order
> to recognize failed prb_reserve() calls. Change the ringbuffer
> to instead use two different identifiers (FAILED_LPOS and
> NO_LPOS) to distinguish between failed prb_reserve() records and
> successful dataless records, respectively.
> 
> diff --git a/kernel/printk/printk_ringbuffer.c 
> b/kernel/printk/printk_ringbuffer.c
> index 7355ca99e852..0659b50872b5 100644
> --- a/kernel/printk/printk_ringbuffer.c
> +++ b/kernel/printk/printk_ringbuffer.c
>  static bool data_check_size(struct prb_data_ring *data_ring, unsigned int 
> size)
>  {
>   struct prb_data_block *db = NULL;
>  
> - /*
> -  * Writers are not allowed to write data-less records. Such records
> -  * are used only internally by the ringbuffer to denote records where
> -  * their data failed to allocate or have been lost.
> -  */
>   if (size == 0)
> - return false;
> + return true;

Nit: This might deserve a comment why size == 0 is handled
 a special way.specially. I think about something like:

/*
 * Empty data blocks are handled by special lpos values in
 * the record descriptor. No space is needed in the data ring.
 */

or simply

/* Data-less records take no space in the data ring. */

>   /*
>* Ensure the alignment padded size could possibly fit in the data

> @@ -1025,6 +1020,10 @@ static char *data_alloc(struct printk_ringbuffer *rb,
>  static unsigned int space_used(struct prb_data_ring *data_ring,
>  struct prb_data_blk_lpos *blk_lpos)
>  {
> + /* Data-less blocks take no space. */
> + if (LPOS_DATALESS(blk_lpos->begin))
> + return 0;

Nit: It seems that all the other locations check also blk_lpos->next,
 for example, get_data() does:

if (LPOS_DATALESS(blk_lpos->begin) && LPOS_DATALESS(blk_lpos->next)) {


 Both approaches are error prone. I would either simplify the
 other locations and check only lpos->begin. But better might
 be to be on the safe side do a paranoid check, like:

bool is_dataless(struct prb_data_blk_lpos *blk_lpos)
{
if (LPOS_DATALESS(blk_lpos->begin) || LPOS_DATALESS(blk_lpos->next)) {
WARN_ON_ONCE(blk_lpos->begin != blk_lpos->next);
return true;
}

return false;
}

> +
>   if (DATA_WRAPS(data_ring, blk_lpos->begin) == DATA_WRAPS(data_ring, 
> blk_lpos->next)) {
>   /* Data block does not wrap. */
>   return (DATA_INDEX(data_ring, blk_lpos->next) -

Anyway, the patch looks fine. It is already pushed in
printk/linux.git. So, if you agree with my nits, we should
solve them with separate patches on top of the existing ones.

Best Regards,
Petr

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec