Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4141223imm; Mon, 25 Jun 2018 10:23:03 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKQOw4u6+QrBcGBJ70jkZ++Zl5zcy3UXVTGiNR7GpsWLGQD2CU6FEK1xqI0Q71x0o9MOME5 X-Received: by 2002:a62:da07:: with SMTP id c7-v6mr13952998pfh.106.1529947383332; Mon, 25 Jun 2018 10:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529947383; cv=none; d=google.com; s=arc-20160816; b=uHIIf9iGVpBun92oF70ksc4Wu51XfeUQvHwkRMbI+NI2G+jc2kTpU5PoQhZk3XLa6g f6byQ+87aod/M6wuH3JvHpBVn/5qjgGySF+xU9wxGlehaiCA+1DPgzmdZZMf7OaJ8OZH cy7WTrI3W38LlcIpj0JWF1k+PuulFCjDRvFQkGc2IjetI2TehcoO5z0rCWE0JvVkJeoS V8BnxjIZBJS9gVyDjJcC7BqchRIfa2wKAGicrOHdTjaVNlDFNhzFbthCkovaOayhb3o3 K1qM+WR6tvktbpXWfn1OFFXLckHRDfeDSL00SQ/NLfKD3knmb0IiIHBZ2fIMnqmAEGGd BWCg== 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:dkim-signature :arc-authentication-results; bh=Lz3qc+wJJSmTnviOsOwS1zPkQ/WP7MD2SNemyAYoXOs=; b=xH9SlNG2inb3CyqEXDkKe64uea73odW1MxQUIlD1SziqwKMrdUl1wNeTm3gAn9NmOR 1NLWAZ/G9gS3N1rIAfLE61GddrRoENIDEIXTiHgMwNVQTN9P37vlWaKeXCDhRFWGgivc L5BDoQeyAq4O+mRcXC2cRHSfIN/WrhXcaxCxITvPp7eLAKuy/iw+IQp92BFNLOrPR+p0 zDQhrvCHnmMkGDRbuQdozPSDZeSQZjPuXJfdHrECKnbanEt8njNN5dfvzpxMBq7HDawR o7o3sGiSoLnrJKAHX40IbzhgNw3fFSj0Y8brNWmAZUDp9WOwq4YwVsArSZ+vb2P7lEKi yd+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c6EbeAwu; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c32-v6si14018851plj.277.2018.06.25.10.22.49; Mon, 25 Jun 2018 10:23:03 -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=@kernel.org header.s=default header.b=c6EbeAwu; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964839AbeFYRVv (ORCPT + 99 others); Mon, 25 Jun 2018 13:21:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:44276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934275AbeFYRVt (ORCPT ); Mon, 25 Jun 2018 13:21:49 -0400 Received: from localhost (unknown [69.71.4.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 53E8E25F1B; Mon, 25 Jun 2018 17:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529947308; bh=MnouLVhS1Jmpy7U8XV/1xiEkmsei6tlkbKf2tcwd8Z0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c6EbeAwubJ/CdkQaGpxbXiUha2ptk0lV0Rjg/OQmSOh3uSQ73zmQjr0TOsBR5Qk2l tj1DjHcQH3YiH4Vbjkf658x+RQ9mkrXf/RofwCd9HRw47gpcG4IPYKcsRccBzOqIJP QEcHJeAKuZQcPmabjAPBj6kTEhsB1X418p5b8V2c= Date: Mon, 25 Jun 2018 12:21:46 -0500 From: Bjorn Helgaas To: Guomin Chen Cc: Brijesh Singh , Tom Lendacky , Yaowei Bai , Bjorn Helgaas , Toshi Kani , Dan Williams , Thomas Gleixner , Andrew Morton , Joey Lee , Borislav Petkov , Takashi Iwai , "linux-efi@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 1/1] resource: Fixed iomem resource release failed on release_mem_region_adjustable() when memory node or cpu node hot-remove. Message-ID: <20180625172146.GA191076@bhelgaas-glaptop.roam.corp.google.com> References: <20180622120138.5411-1-guomin.chen@suse.com> <20180622231930.GA2834@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 23, 2018 at 05:53:40AM +0000, Guomin Chen wrote: > Hi > The report link for this issue is: https://bugzilla.suse.com/show_bug.cgi?id=1092687 If/when you update this patch, please include the URL in the commit log, e.g., Link: https://bugzilla.suse.com/show_bug.cgi?id=1092687 It would also be nice if you could make that report public so anybody can read it. > > -----Original Message----- > > From: Bjorn Helgaas [mailto:helgaas@kernel.org] > > Sent: 2018年6月23日 7:20 > > To: Guomin Chen > > Cc: Brijesh Singh ; Tom Lendacky > > ; Yaowei Bai > > ; Bjorn Helgaas ; > > Toshi Kani ; Dan Williams ; > > Thomas Gleixner ; Andrew Morton > > ; Joey Lee ; Borislav Petkov > > ; Takashi Iwai ; linux-efi@vger.kernel.org; > > linux-kernel@vger.kernel.org > > Subject: Re: [PATCH 1/1] resource: Fixed iomem resource release failed on > > release_mem_region_adjustable() when memory node or cpu node > > hot-remove. > > > > [+cc Toshi] > > > > On Fri, Jun 22, 2018 at 08:01:38PM +0800, guomin chen wrote: > > > We've got a bug report indicating the hot-remove node resource release > > > failed,when the memory on this node is divided into several > > > sections.because the release_mem_region_adjustable() can only release > > > one resource that must be [start,end]. > > > > Can you please include a URL for the bug report? That's useful for additional > > details and gives hints about how future changes in this area might be tested. > > > > release_mem_region_adjustable() and the only call to it were added by Toshi > > (cc'd): > > > > 825f787bb496 ("resource: add release_mem_region_adjustable()") > > fe74ebb106a5 ("mm: change __remove_pages() to call > > release_mem_region_adjustable()") > > > > > In my case, the BIOS supports faulty memory isolation. if BIOS > > > detected bad memory block, the BIOS will isolates this badblock. > > > And set this badblock memory to EfiUnusableMemory in EFI memory map > > > base on UEFI 2.7 spec.For example in my system, the memory range on > > > node2 is [mem 0x0000080000000000-0x00000807ffffffff].but the BIOS > > > detected the [8004e000000-8004e0fffff] is a badblock memory. > > > So the memory on node2 seem like this: > > > 80000000000-8004dffffff : System RAM > > > 8004e000000-8004e0fffff : Unusable memory > > > 8004e100000-807ffffffff : System RAM > > > > > > Now, when offline the cpu node2,the kernel will try to release > > > ioresource [mem 0x0000080000000000-0x00000807ffffffff]. at this time, > > > the kernel will release failed,and output error message: > > > "Unable to release resource <0x0000080000000000-0x00000807ffffffff> > > > (-22)". > > > Because the release_mem_region_adjustable() can only release one > > > resource that must be [0x0000080000000000 , 0x00000807ffffffff]. > > > but now,the iomem resource on node2 [0x0000080000000000, > > > 0x00000807ffffffff] are divided into three resources [80000000000- > > > 8004dffffff],[8004e000000-8004e0fffff]and[8004e100000-807ffffffff]. > > > > > > This patch help to Release multiple iomem resources at once when node > > > hot-remove. Such as in above case, when hot-remove the cpu node2,the > > > kernel will try to release resource [0x0000080000000000- > > > 0x00000807ffffffff].And this patch will release three resources > > > [80000000000-8004dffffff],[8004e000000-8004e0fffff] and > > > [8004e100000-807ffffffff]. > > > > > > Cc: Thomas Gleixner > > > Cc: Brijesh Singh > > > Cc: Borislav Petkov > > > Cc: Andrew Morton > > > Cc: Tom Lendacky > > > Cc: Bjorn Helgaas > > > Cc: Yaowei Bai > > > Cc: Takashi Iwai > > > Cc: Dan Williams > > > Cc: linux-efi@vger.kernel.org > > > Cc: linux-kernel@vger.kernel.org > > > Cc: Lee Chun-Yi > > > Signed-off-by: guomin chen > > > --- > > > kernel/resource.c | 73 > > > ++++++++++++++++++++++++++++++++----------------------- > > > 1 file changed, 43 insertions(+), 30 deletions(-) > > > > > > diff --git a/kernel/resource.c b/kernel/resource.c index > > > 30e1bc68503b..959bcce4c405 100644 > > > --- a/kernel/resource.c > > > +++ b/kernel/resource.c > > > @@ -1240,6 +1240,7 @@ int release_mem_region_adjustable(struct > > resource *parent, > > > struct resource *res; > > > struct resource *new_res; > > > resource_size_t end; > > > + resource_size_t new_start = start; > > > int ret = -EINVAL; > > > > > > end = start + size - 1; > > > @@ -1257,7 +1258,7 @@ int release_mem_region_adjustable(struct > > resource *parent, > > > break; > > > > > > /* look for the next resource if it does not fit into */ > > > - if (res->start > start || res->end < end) { > > > + if (res->end < new_start) { > > > p = &res->sibling; > > > continue; > > > } > > > @@ -1271,42 +1272,54 @@ int release_mem_region_adjustable(struct > > resource *parent, > > > } > > > > > > /* found the target resource; let's adjust accordingly */ > > > - if (res->start == start && res->end == end) { > > > + if (res->start == new_start && res->end == end) { > > > /* free the whole entry */ > > > *p = res->sibling; > > > free_resource(res); > > > ret = 0; > > > - } else if (res->start == start && res->end != end) { > > > - /* adjust the start */ > > > - ret = __adjust_resource(res, end + 1, > > > - res->end - end); > > > - } else if (res->start != start && res->end == end) { > > > - /* adjust the end */ > > > - ret = __adjust_resource(res, res->start, > > > - start - res->start); > > > + } else if (res->end > end) { > > > + if (res->start >= new_start) { > > > + /* adjust the start */ > > > + ret = __adjust_resource(res, end + 1, > > > + res->end - end); > > > + } else { > > > + /* split into two entries */ > > > + if (!new_res) { > > > + ret = -ENOMEM; > > > + break; > > > + } > > > + new_res->name = res->name; > > > + new_res->start = end + 1; > > > + new_res->end = res->end; > > > + new_res->flags = res->flags; > > > + new_res->desc = res->desc; > > > + new_res->parent = res->parent; > > > + new_res->sibling = res->sibling; > > > + new_res->child = NULL; > > > + > > > + ret = __adjust_resource(res, res->start, > > > + new_start - res->start); > > > + if (ret) > > > + break; > > > + res->sibling = new_res; > > > + new_res = NULL; > > > + } > > > } else { > > > - /* split into two entries */ > > > - if (!new_res) { > > > - ret = -ENOMEM; > > > - break; > > > + if (res->start < new_start) { > > > + /* adjust the end */ > > > + ret = __adjust_resource(res, res->start, > > > + new_start - res->start); > > > + new_start = res->end+1; > > > + p = &res->sibling; > > > + } else { > > > + new_start = res->end+1; > > > + *p = res->sibling; > > > + free_resource(res); > > > + ret = 0; > > > } > > > - new_res->name = res->name; > > > - new_res->start = end + 1; > > > - new_res->end = res->end; > > > - new_res->flags = res->flags; > > > - new_res->desc = res->desc; > > > - new_res->parent = res->parent; > > > - new_res->sibling = res->sibling; > > > - new_res->child = NULL; > > > - > > > - ret = __adjust_resource(res, res->start, > > > - start - res->start); > > > - if (ret) > > > - break; > > > - res->sibling = new_res; > > > - new_res = NULL; > > > + if (res->end < end) > > > + continue; > > > } > > > - > > > break; > > > } > > > > > > -- > > > 2.12.3 > > > >