Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3679767ybi; Mon, 27 May 2019 04:15:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg43aN9RkyJslkho0q9YWkNiofv4ZPhpsqjht8QUYhSkgcnBVXNapuuSmghQ1ehqsCQBCq X-Received: by 2002:a62:304:: with SMTP id 4mr118035409pfd.186.1558955714766; Mon, 27 May 2019 04:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558955714; cv=none; d=google.com; s=arc-20160816; b=MtX/RvSedQNtxtsMRFAr4fZVg+6tJ6oBXsut/l6aB8yH0b9FCKOZ8M0XKOR7212NQj ZT/QhJcYq8vDNwW15NMDTSUeYWdHMYt/idcsJBc+7weyZxPMRwdPzksCAyZ3xo7r/9wy 8G69C8+IL6qxD2184Vrt75YtyCBhgfeUMlri1ULwp3qqtlqmv59Ba28PO/l5j0cmAEz7 JFJ6KQow5hhkfK+oiYaj0Uj7F8DF2B89OuvSTZHadafRLRj+dig5O+s5608mxPb5Dzgo CSqp3oVfJI2tJ5xps3spTyGNgzVSnoRMhEFl7rPeTjBqXS9xMuJThdsE5EA+W6ayj+Mo DFTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=FNTktvj0kV+SOdLAQ71+yr15WutmVjJpnyIy6jk9OZM=; b=cLIqJ9iuwA0yqOKDsf5f7BmIqgmZFIM9GP7Qz7OWnZ6/vdC+YDw8l1KwVDx5DVq1Xo m1rPVwHS48YIAEtaTYz2dH0MTKnVBGB9CXv3eYdCqIckhTvO/gPt8n+kmcq7yL61+S3+ dsfQidQ6XpINnDG5qzDuLOr4mpw+rhz2GONGR91lpoJm6NVXVwP9JWN1Ga0S+DgOM/aR hu+lGLPdcIEQ3B7G54FRepssHpGzzmco6ntzWM1Fd+O+yWCjpITJ80RiAsmNqcylwyak 5Ga84kSQK6rWNCLigJPLdAy3m94LolHTaV00i6IyX+WOvw2KlVgmpQqpgJJVUjoK8tKY grjw== 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 r132si17574277pfr.275.2019.05.27.04.14.58; Mon, 27 May 2019 04:15:14 -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 S1726999AbfE0LMc (ORCPT + 99 others); Mon, 27 May 2019 07:12:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59280 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726887AbfE0LMa (ORCPT ); Mon, 27 May 2019 07:12:30 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B17DE88319; Mon, 27 May 2019 11:12:30 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-89.ams2.redhat.com [10.36.117.89]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FD3919C7F; Mon, 27 May 2019 11:12:27 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-arm-kernel@lists.infradead.org, akpm@linux-foundation.org, Dan Williams , Wei Yang , Igor Mammedov , David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v3 05/11] drivers/base/memory: Pass a block_id to init_memory_block() Date: Mon, 27 May 2019 13:11:46 +0200 Message-Id: <20190527111152.16324-6-david@redhat.com> In-Reply-To: <20190527111152.16324-1-david@redhat.com> References: <20190527111152.16324-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 27 May 2019 11:12:30 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We'll rework hotplug_memory_register() shortly, so it no longer consumes pass a section. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index f180427e48f4..f914fa6fe350 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -651,21 +651,18 @@ int register_memory(struct memory_block *memory) return ret; } -static int init_memory_block(struct memory_block **memory, - struct mem_section *section, unsigned long state) +static int init_memory_block(struct memory_block **memory, int block_id, + unsigned long state) { struct memory_block *mem; unsigned long start_pfn; - int scn_nr; int ret = 0; mem = kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return -ENOMEM; - scn_nr = __section_nr(section); - mem->start_section_nr = - base_memory_block_id(scn_nr) * sections_per_block; + mem->start_section_nr = block_id * sections_per_block; mem->end_section_nr = mem->start_section_nr + sections_per_block - 1; mem->state = state; start_pfn = section_nr_to_pfn(mem->start_section_nr); @@ -694,7 +691,8 @@ static int add_memory_block(int base_section_nr) if (section_count == 0) return 0; - ret = init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE); + ret = init_memory_block(&mem, base_memory_block_id(base_section_nr), + MEM_ONLINE); if (ret) return ret; mem->section_count = section_count; @@ -707,6 +705,7 @@ static int add_memory_block(int base_section_nr) */ int hotplug_memory_register(int nid, struct mem_section *section) { + int block_id = base_memory_block_id(__section_nr(section)); int ret = 0; struct memory_block *mem; @@ -717,7 +716,7 @@ int hotplug_memory_register(int nid, struct mem_section *section) mem->section_count++; put_device(&mem->dev); } else { - ret = init_memory_block(&mem, section, MEM_OFFLINE); + ret = init_memory_block(&mem, block_id, MEM_OFFLINE); if (ret) goto out; mem->section_count++; -- 2.20.1