Received: by 10.192.165.148 with SMTP id m20csp1773893imm; Thu, 26 Apr 2018 01:59:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx49n61i9CNOZq6tdUkstO4szrOb1m1XfAyBWvq/7mh02372PG4We4ylcBYAT2B+Hm8rh/Cm8 X-Received: by 2002:a17:902:684c:: with SMTP id f12-v6mr33095466pln.139.1524733145924; Thu, 26 Apr 2018 01:59:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524733145; cv=none; d=google.com; s=arc-20160816; b=xR3xhnXWDv3FIYGDDkCx/eFcnuYg9uOBSm+dYTSk3tZTMVccZxVbJZKJAHyr5sEwoy 5vaMTzFavHV1CTXeYtkJb17QxeETa2AzerRrsCWELdSQ834nEPmkpFzinyJl2U2TH4PY pCwdrHZS3PVCVCU5a7pIvaRbYSuaohAhWs85zFERbXWGQOdvKE6WsHBg0b0UizfVon09 iXEwOOBJHeENaqoa/saHA6TfAbHAQECS/CG2S8yrA2aIQ1zoz6UVxAKiEa/vRnOfoXjG SEUtcOGtdSVtzX6jpqnukPnV7105y9WZUjg97KpboZG2AT0I4M//VL9M/3GS/VxrspBv 45tA== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=IsksgRLZm/0T7eUplajK58Kmy1jZYYiUExzQq9bX2Fw=; b=LUu0SoL7BakbeeIdW3MW0U9cKdeaiNKfUwFdJydN7ud2tml7k6mZmZjP3lICAM58vZ Za8rfapOcXtmcfJ8waE6cqaFSErDq1NGW9mWaz+cJIW80mKBOeNT5bxMyRmKNKzngxnq ZuL1pCbXjTbWf5DxVgXuHzW4NAEL4AhjcalPBtO4pApzf4GKARZjTgT8bCCA/q0/Xfnb 6RUBi7h496Odmf5i2UcyxB70GW/oqYT7sZWzd7WTyrRrd3DOe0KebL0V3u3QBQx0XuP1 bml2Aol3+yV374WdoaeQRBpk2FQz77e+vOcco2024QHxnGSiBo0nIj8ySxZIYMHfVADk WZgA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si2440317pfk.228.2018.04.26.01.58.51; Thu, 26 Apr 2018 01:59:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754783AbeDZI5C (ORCPT + 99 others); Thu, 26 Apr 2018 04:57:02 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43730 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754015AbeDZI44 (ORCPT ); Thu, 26 Apr 2018 04:56:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4E0F4023112; Thu, 26 Apr 2018 08:56:55 +0000 (UTC) Received: from localhost (ovpn-8-16.pek2.redhat.com [10.72.8.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27C2B83B66; Thu, 26 Apr 2018 08:56:53 +0000 (UTC) Date: Thu, 26 Apr 2018 16:56:49 +0800 From: Baoquan He To: Borislav Petkov Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, robh+dt@kernel.org, dan.j.williams@intel.com, nicolas.pitre@linaro.org, josh@joshtriplett.org, Thomas Gleixner , Brijesh Singh , =?iso-8859-1?B?Suly9G1l?= Glisse , Tom Lendacky , Wei Yang Subject: Re: [PATCH v3 2/3] resource: add walk_system_ram_res_rev() Message-ID: <20180426085649.GC18395@localhost.localdomain> References: <20180419001848.3041-1-bhe@redhat.com> <20180419001848.3041-3-bhe@redhat.com> <20180419100745.GC3896@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180419100745.GC3896@pd.tnic> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 26 Apr 2018 08:56:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 26 Apr 2018 08:56:55 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'bhe@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry to all reviewers, I had a redhat urgent issue, this patchset discussing is delayed. On 04/19/18 at 12:07pm, Borislav Petkov wrote: > On Thu, Apr 19, 2018 at 08:18:47AM +0800, Baoquan He 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 code. > > Of course, what is missing is the big *WHY* you need this to happen this > way... Sorry for that, I just ran scripts/get_maintainer.pl to get expert's name and added them into each patch. The reason this change is made is in patch 3/3. Test robot reported a code bug on the latest kernel, will repost and CC everyone in all patches. Rob Herring asked the same question in v2, I explained to him. The discussion can be found here: https://lkml.org/lkml/2018/4/10/484 > > > /* > > + * This function, being a variant of walk_system_ram_res(), calls the @func > > + * callback against all memory ranges of type System RAM which are marked as > > + * IORESOURCE_SYSTEM_RAM and IORESOUCE_BUSY in reversed order, i.e., from > > + * higher to lower. > > + */ > > +int walk_system_ram_res_rev(u64 start, u64 end, void *arg, > > + int (*func)(struct resource *, void *)) > > +{ > > + unsigned long flags; > > + struct resource *res; > > + int ret = -1; > > + > > + flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY; > > + > > + read_lock(&resource_lock); > > + list_for_each_entry_reverse(res, &iomem_resource.child, sibling) { > > ... and the other thing that I'm not clear on is why are you > slapping this function just like that instead of extending > __walk_iomem_res_desc() to do reverse direction too? Yes, I planned to do as you said when started to write code. After investigation, I changed to use the way of this patch. Because __walk_iomem_res_desc() provides two interfaces by calling find_next_iomem_res(). If 'first_level_children_only' is true, it only iterates system RAM resource; if 'first_level_children_only' is false, it does depth first iteration in iomem_resource. The 1st interface is only used by walk_system_ram_res() and walk_mem_res(). While the 2nd interface need call find_next_iomem_res() which resorts to next_resource(). next_resource() will check 'sibling_only' to decide if iterate iomem_resource's children, or walk over all resources of iomem_resource with depth first. For walk_system_ram_res_rev(), we only need to iterate iomem_resource's children, and seems no one has requirement to iterate all iomem_resource's children and grand children revresedly. For simplifying code implementation, I just did as in this patch, surely, if any suggestion or scenario given about the reversed iteration of all resources, I can change to add below functions, and based on them to implement walk_system_ram_res_rev(). walk_system_ram_res_rev ->__walk_iomem_res_desc_rev ->find_next_iomem_res_rev ->next_resource_rev Thanks Baoquan > > SUSE Linux GmbH, GF: Felix Imend?rffer, Jane Smithard, Graham Norton, HRB 21284 (AG N?rnberg) > --