Received: by 10.213.65.68 with SMTP id h4csp76521imn; Mon, 19 Mar 2018 20:14:57 -0700 (PDT) X-Google-Smtp-Source: AG47ELvWGbuKLGdSgb62N411GrJe+6fuRmAUEFX1BqwvSWAwf+7mWu35yLLx/wpjpRulgkWfJBKh X-Received: by 2002:a17:902:8c83:: with SMTP id t3-v6mr5055340plo.391.1521515697954; Mon, 19 Mar 2018 20:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521515697; cv=none; d=google.com; s=arc-20160816; b=rjFBNr1Or8kcppqo1JgU4HySVwUbJu+mc1MnTZOIWVBie5LMsGUPna9XAd07hmYSXf JBjU0XiYkcbAl1TLJQ53AwoiqstTTi7n0Pk47LsgeCdWZpAIbIWazp4Lx1XU1rDInbj3 WpDz6jeItXcDGZJRzvNpnO/E4Di0blzZNsQ4e5vsalc+5k4NpZd9CW/NSAr99dEa6d8S HHREunkx1cVrNaKjWmBwfG8yFrk2JrKaiwEnevmn6u2CuUz1/OJwCY2wgcmlEmi4EYKt torJUAlKQ6bQ1c5LGoqWER6uQKOi4ovGwhI4JHW8+/k+JrfDjjBO4ASY9wwyDhanhGlb AWnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=jQtYNUH1oQisJ8u58MrUanWAXm9wPyeV7Ee1Gt4sAwk=; b=GoUyWUg7Cpth66WssC3jHGcVq5/HBvkkIumohsTMk1krjI78XJK/MefDlXir4Rxpmh 35z+oIOam8gWmvrM7dok0IXQdghgpOJAUnIH5awV/1K3omVUfPa+XtK0AUEJfxyBE9hF puJH/OKkHO1WwlYnqnS9irpwTsM6PXKdtkjMXf5275dgfhgMQ4322ZUzqTUzGwNHY4B4 35RaWCIwKIcxEtDzMLM7KuJgz1jeg6H1nFohcFbpt8EslBmiRKCP7pLuzTEB2recXjpk zJSbExr2mS3U3QpqOuRkub/K3LztFb7eqtlRGnvf1BpcjqN0VeWIapLmGnQGMBg0MKW9 +frQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJT5od4L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si519420pga.175.2018.03.19.20.14.43; Mon, 19 Mar 2018 20:14:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XJT5od4L; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbeCTDNF (ORCPT + 99 others); Mon, 19 Mar 2018 23:13:05 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33818 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750968AbeCTDNC (ORCPT ); Mon, 19 Mar 2018 23:13:02 -0400 Received: by mail-pg0-f67.google.com with SMTP id m15so113062pgc.1 for ; Mon, 19 Mar 2018 20:13:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=jQtYNUH1oQisJ8u58MrUanWAXm9wPyeV7Ee1Gt4sAwk=; b=XJT5od4LfL7x7FGlNTn+KlTB9LYO7RwZ0Rpbg3zFb2NqrJiEyqI1LRtingsiaUrvqH wjMBjr570YdBKnhnCtM+Wt2GIVWAhrO1rN0bd7en3AKPIYbgr5jGqkGqMjjwo4uwGEhn dlW/x/ZdOa1CqXvyk3ifRNrUl3Shot2IDQgRY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=jQtYNUH1oQisJ8u58MrUanWAXm9wPyeV7Ee1Gt4sAwk=; b=FyOmtax19KVIVDvlwtmJNwWbuR2qoi+g70fNT/sXktTyrmceUOg0UgL0MtohjQkrGN z/iNH0gOUug+GYkxNXjNbpts2rr3JcwGeEp+GMKk+IUvVpM3JD0kxpDijTb8NRLT2Hq0 wXNIwapNdUnOeRDdzCo/4ZfBGlA+d8foxxj/XFuZAQw0/sfPUaE+jtWNqAdZbv5Bm8XV P6OtuTUDTY9uZkjWHSUhCrN9IeilrzYu+Q+5LvTIyIY/hClWN+z/FTxgf7qIy0b+x9ow 0UHfdTs1La9nYyaSsjtbJV4/YAtFI1X7ax3kTYS2olEFpKqp8npa/afyNivHmEeLfreo Gq8Q== X-Gm-Message-State: AElRT7G8ZsJUFHpwPY6FJZdpZJ30t+VmRMW2vsV+3aKuTLi0l+lpN2H0 0PRtGX8HhwBOESeRabWC17EPug== X-Received: by 10.99.177.66 with SMTP id g2mr10828819pgp.425.1521515581323; Mon, 19 Mar 2018 20:13:01 -0700 (PDT) Received: from dragonfly (165084180235.ctinets.com. [165.84.180.235]) by smtp.googlemail.com with ESMTPSA id a17sm775934pfc.122.2018.03.19.20.12.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Mar 2018 20:13:00 -0700 (PDT) Date: Tue, 20 Mar 2018 12:12:55 +0900 From: AKASHI Takahiro To: Baoquan He Cc: Dave Young , herbert@gondor.apana.org.au, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, julien.thierry@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, dhowells@redhat.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, akpm@linux-foundation.org, Linus Torvalds , davem@davemloft.net, vgoyal@redhat.com Subject: Re: [PATCH v8 01/13] resource: add walk_system_ram_res_rev() Message-ID: <20180320031253.bwxat2dr3sns5uj4@dragonfly> Mail-Followup-To: AKASHI Takahiro , Baoquan He , Dave Young , herbert@gondor.apana.org.au, ard.biesheuvel@linaro.org, catalin.marinas@arm.com, julien.thierry@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, dhowells@redhat.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, akpm@linux-foundation.org, Linus Torvalds , davem@davemloft.net, vgoyal@redhat.com References: <20180222111732.23051-1-takahiro.akashi@linaro.org> <20180222111732.23051-2-takahiro.akashi@linaro.org> <20180223083619.GA4433@dhcp-128-65.nay.redhat.com> <20180320014318.GA2514@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180320014318.GA2514@localhost.localdomain> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Baoquan, On Tue, Mar 20, 2018 at 09:43:18AM +0800, Baoquan He wrote: > On 02/23/18 at 04:36pm, Dave Young wrote: > > Hi AKASHI, > > > > On 02/22/18 at 08:17pm, AKASHI Takahiro wrote: > > > This function, being a variant of walk_system_ram_res() introduced in > > > commit 8c86e70acead ("resource: provide new functions to walk through > > > resources"), walks through a list of all the resources of System RAM > > > in reversed order, i.e., from higher to lower. > > > > > > It will be used in kexec_file implementation on arm64. > > > > I remember there was an old discussion about this, it should be added > > in patch log why this is needed. > > It's used to load kernel/initrd at the top of system RAM, and this is > consistent with user space kexec behaviour. > > In x86 64, Vivek didn't do like this since there's no reverse iomem > resource iterating function, he just chose a match RAM region bottom up, > then put kernel/initrd top down in the found RAM region. This is > different than kexec_tools utility. I am considering to change resource > sibling as double list, seems AKASHI's way is easier to be accepted by > people. So I will use this one to change x86 64 code. > > Hi AKASHI, > > About arm64 kexec_file patches, will you post recently? Or any other > plan? A short answer is yes, but my new version won't include this specific patch. So please feel free to add it to your own patch set if you want. The reason that I'm going to remove it is that we will make a modification on /proc/iomem due to a bug fixing and then we will have to have our own "walking" routine. Thanks, -Takahiro AKASHI > Thanks > Baoquan > > > > > > > > > Signed-off-by: AKASHI Takahiro > > > Cc: Vivek Goyal > > > Cc: Andrew Morton > > > Cc: Linus Torvalds > > > --- > > > include/linux/ioport.h | 3 +++ > > > kernel/resource.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ > > > 2 files changed, 60 insertions(+) > > > > > > diff --git a/include/linux/ioport.h b/include/linux/ioport.h > > > index da0ebaec25f0..f12d95fe038b 100644 > > > --- a/include/linux/ioport.h > > > +++ b/include/linux/ioport.h > > > @@ -277,6 +277,9 @@ extern int > > > walk_system_ram_res(u64 start, u64 end, void *arg, > > > int (*func)(struct resource *, void *)); > > > extern int > > > +walk_system_ram_res_rev(u64 start, u64 end, void *arg, > > > + int (*func)(struct resource *, void *)); > > > +extern int > > > walk_iomem_res_desc(unsigned long desc, unsigned long flags, u64 start, u64 end, > > > void *arg, int (*func)(struct resource *, void *)); > > > > > > diff --git a/kernel/resource.c b/kernel/resource.c > > > index e270b5048988..bdaa93407f4c 100644 > > > --- a/kernel/resource.c > > > +++ b/kernel/resource.c > > > @@ -23,6 +23,8 @@ > > > #include > > > #include > > > #include > > > +#include > > > +#include > > > #include > > > > > > > > > @@ -486,6 +488,61 @@ int walk_mem_res(u64 start, u64 end, void *arg, > > > arg, func); > > > } > > > > > > +int walk_system_ram_res_rev(u64 start, u64 end, void *arg, > > > + int (*func)(struct resource *, void *)) > > > +{ > > > + struct resource res, *rams; > > > + int rams_size = 16, i; > > > + int ret = -1; > > > + > > > + /* create a list */ > > > + rams = vmalloc(sizeof(struct resource) * rams_size); > > > + if (!rams) > > > + return ret; > > > + > > > + res.start = start; > > > + res.end = end; > > > + res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > > + i = 0; > > > + while ((res.start < res.end) && > > > + (!find_next_iomem_res(&res, IORES_DESC_NONE, true))) { > > > + if (i >= rams_size) { > > > + /* re-alloc */ > > > + struct resource *rams_new; > > > + int rams_new_size; > > > + > > > + rams_new_size = rams_size + 16; > > > + rams_new = vmalloc(sizeof(struct resource) > > > + * rams_new_size); > > > + if (!rams_new) > > > + goto out; > > > + > > > + memcpy(rams_new, rams, > > > + sizeof(struct resource) * rams_size); > > > + vfree(rams); > > > + rams = rams_new; > > > + rams_size = rams_new_size; > > > + } > > > + > > > + rams[i].start = res.start; > > > + rams[i++].end = res.end; > > > + > > > + res.start = res.end + 1; > > > + res.end = end; > > > + } > > > + > > > + /* go reverse */ > > > + for (i--; i >= 0; i--) { > > > + ret = (*func)(&rams[i], arg); > > > + if (ret) > > > + break; > > > + } > > > + > > > +out: > > > + vfree(rams); > > > + return ret; > > > +} > > > + > > > #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) > > > > > > /* > > > -- > > > 2.16.2 > > > > > > > Thanks > > Dave > > > > _______________________________________________ > > kexec mailing list > > kexec@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/kexec