From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CF3CC2D0CE for ; Tue, 21 Jan 2020 18:03:14 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2105824125 for ; Tue, 21 Jan 2020 18:03:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CdUv47JQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2105824125 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 087DD6B0274; Tue, 21 Jan 2020 13:03:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F058E6B0275; Tue, 21 Jan 2020 13:03:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF4CE6B0276; Tue, 21 Jan 2020 13:03:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id BE19C6B0274 for ; Tue, 21 Jan 2020 13:03:02 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 763DD2461 for ; Tue, 21 Jan 2020 18:03:02 +0000 (UTC) X-FDA: 76402412604.03.comb42_71c35a5ff9904 X-HE-Tag: comb42_71c35a5ff9904 X-Filterd-Recvd-Size: 7746 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by imf03.hostedemail.com (Postfix) with ESMTP for ; Tue, 21 Jan 2020 18:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579629781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+mL7eP+xIe7uFOXHzIdoUahyoIfaOlQfAVxV6UWyqbw=; b=CdUv47JQc6FcwAbjKXruRFIM9id4AAN8vohU3kK020XWsbPcajKWxOxJY4dP7NCvt2FaKb sxReFYPLJd23noReKE6gRttmHzTl8DfdKb0DosyAR4H2jRBbCvnlaUhWh4MAuOiryyOSLd ZRz++uFwKbQjlQxxsaKDx116Q+27HGM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-285-iEj-7c9ONO-cOwgumiyVKg-1; Tue, 21 Jan 2020 13:02:57 -0500 X-MC-Unique: iEj-7c9ONO-cOwgumiyVKg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59F0F100551D; Tue, 21 Jan 2020 18:02:55 +0000 (UTC) Received: from t480s.redhat.com (unknown [10.36.118.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 330AE5C290; Tue, 21 Jan 2020 18:02:53 +0000 (UTC) From: David Hildenbrand To: stable@vger.kernel.org Cc: linux-mm@kvack.org, Michal Hocko , Greg Kroah-Hartman , Andrew Morton , "Aneesh Kumar K . V" , Baoquan He , Dan Williams , Oscar Salvador , Wei Yang , David Hildenbrand Subject: [PATCH for 4.19-stable v2 15/24] drivers/base/memory: pass a block_id to init_memory_block() Date: Tue, 21 Jan 2020 19:01:41 +0100 Message-Id: <20200121180150.37454-16-david@redhat.com> In-Reply-To: <20200121180150.37454-1-david@redhat.com> References: <20200121180150.37454-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: commit 1811582587c43bdf13d690d83345610d4df433bb upstream. We'll rework hotplug_memory_register() shortly, so it no longer consumes pass a section. [cai@lca.pw: fix a compilation warning] Link: http://lkml.kernel.org/r/1559320186-28337-1-git-send-email-cai@lc= a.pw Link: http://lkml.kernel.org/r/20190527111152.16324-6-david@redhat.com Signed-off-by: David Hildenbrand Signed-off-by: Qian Cai Acked-by: Michal Hocko Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Alex Deucher Cc: Andrew Banman Cc: Andy Lutomirski Cc: Anshuman Khandual Cc: Ard Biesheuvel Cc: Arun KS Cc: Baoquan He Cc: Benjamin Herrenschmidt Cc: Borislav Petkov Cc: Catalin Marinas Cc: Chintan Pandya Cc: Christophe Leroy Cc: Chris Wilson Cc: Dan Williams Cc: Dave Hansen Cc: "David S. Miller" Cc: Fenghua Yu Cc: Heiko Carstens Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jonathan Cameron Cc: Joonsoo Kim Cc: Jun Yao Cc: "Kirill A. Shutemov" Cc: Logan Gunthorpe Cc: Mark Brown Cc: Mark Rutland Cc: Masahiro Yamada Cc: Mathieu Malaterre Cc: Michael Ellerman Cc: Mike Rapoport Cc: "mike.travis@hpe.com" Cc: Nicholas Piggin Cc: Oscar Salvador Cc: Oscar Salvador Cc: Paul Mackerras Cc: Pavel Tatashin Cc: Peter Zijlstra Cc: Rich Felker Cc: Rob Herring Cc: Robin Murphy Cc: Thomas Gleixner Cc: Tony Luck Cc: Vasily Gorbik Cc: Wei Yang Cc: Will Deacon Cc: Yoshinori Sato Cc: Yu Zhao Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 9a5f81dc32c5..f9818d75ac43 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -660,21 +660,18 @@ int register_memory(struct memory_block *memory) return ret; } =20 -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 =3D 0; =20 mem =3D kzalloc(sizeof(*mem), GFP_KERNEL); if (!mem) return -ENOMEM; =20 - scn_nr =3D __section_nr(section); - mem->start_section_nr =3D - base_memory_block_id(scn_nr) * sections_per_block; + mem->start_section_nr =3D block_id * sections_per_block; mem->end_section_nr =3D mem->start_section_nr + sections_per_block - 1; mem->state =3D state; start_pfn =3D section_nr_to_pfn(mem->start_section_nr); @@ -689,21 +686,18 @@ static int init_memory_block(struct memory_block **= memory, static int add_memory_block(int base_section_nr) { struct memory_block *mem; - int i, ret, section_count =3D 0, section_nr; + int i, ret, section_count =3D 0; =20 for (i =3D base_section_nr; i < base_section_nr + sections_per_block; - i++) { - if (!present_section_nr(i)) - continue; - if (section_count =3D=3D 0) - section_nr =3D i; - section_count++; - } + i++) + if (present_section_nr(i)) + section_count++; =20 if (section_count =3D=3D 0) return 0; - ret =3D init_memory_block(&mem, __nr_to_section(section_nr), MEM_ONLINE= ); + ret =3D init_memory_block(&mem, base_memory_block_id(base_section_nr), + MEM_ONLINE); if (ret) return ret; mem->section_count =3D section_count; @@ -716,6 +710,7 @@ static int add_memory_block(int base_section_nr) */ int hotplug_memory_register(int nid, struct mem_section *section) { + int block_id =3D base_memory_block_id(__section_nr(section)); int ret =3D 0; struct memory_block *mem; =20 @@ -726,7 +721,7 @@ int hotplug_memory_register(int nid, struct mem_secti= on *section) mem->section_count++; put_device(&mem->dev); } else { - ret =3D init_memory_block(&mem, section, MEM_OFFLINE); + ret =3D init_memory_block(&mem, block_id, MEM_OFFLINE); if (ret) goto out; mem->section_count++; --=20 2.24.1