From patchwork Thu Jun 20 10:35:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78D9514DB for ; Thu, 20 Jun 2019 10:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A31B26E96 for ; Thu, 20 Jun 2019 10:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E4292844E; Thu, 20 Jun 2019 10:35:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86B44283A8 for ; Thu, 20 Jun 2019 10:35:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE6B88E0001; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A71626B0008; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E95C8E0001; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 540C46B0006 for ; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id x17so3027998qkf.14 for ; Thu, 20 Jun 2019 03:35:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=PicruJ+VHEPybZvyUaTHSXSbDBs5YreqCwZ14euAQts=; b=Fq54nB5yOA5rlokACv2MbAOSljiN43IAwnQYiPnZBKZHzuGwcddl1H+D817bsUxNBA clQCtI9AoDnBFiahs29cCGLf+jXddQdquCR19x43CeiSToLYQ3PRrP5LSWRsPzhd2je2 MaPQOW42fy+3aK18DwcL6kWgX21fFP9dX9/tft3oVKYAAu6Ll8Hk0upIFH4osxjPm52N KDMGGPfWnsQ3iVqhLwnLzGiHJsBD7vl/0gNrWQ7mPj5sNtU3XyoF6k/J2b2a3lHdm5GB 9SYORQgWdOiYtu7ofFgZ9lh9mE+I7nOdovoib3QxNKurav86dehWtu/kkNST/ssCUeff DvSg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAXP3t38GWE2zWRIrjzznzkZ+9AxuiRG+Yj0w3HRf6B5uMfZjJ2s v1WmV5cO1KZ7JFBr72dUt9ywIc5ZubVEDxzZKPjYtbhF22KPJCanyk9a9iZIAc3UCgUTFmZI34L b80w7ezc5mqctpo/7wkukxgLCIMJOZs26maVMQhWCN2bxBKHX2+4ezIIVcELrGn4YEw== X-Received: by 2002:ac8:2763:: with SMTP id h32mr113471647qth.350.1561026949111; Thu, 20 Jun 2019 03:35:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3bVu90bXC7PqwuV84c1X2R4qlk4IpBI043kvqvgbVtzE3q1qm0clEMGCYeNTeMCzG6crC X-Received: by 2002:ac8:2763:: with SMTP id h32mr113471569qth.350.1561026948067; Thu, 20 Jun 2019 03:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026948; cv=none; d=google.com; s=arc-20160816; b=zUOEeiyJsjrv2dWxx9xeYVC2hGsyfgLYaoYnvnCRrdisFwgOnmOQk9RFsXna1tu38e YrW95kd0CVVD6XunM4iv9CLR0Zc7OeYHAwjfIItoinvcWnN2PlCxBxvFsxKpl1PStBIB 0S0e9CMrUVsrJxTisot+9kiRvry7ivI9fEQTetFKD9cSwhrk7Dn0FyCtlMrYLsgd0gNm yw+cOphaFLdHtTzkJUS4mGgB5ZWS8sXD6cs8T/B72JDAFtiuXvKH/ScFkxkhsu2P6ta2 2VIeEOa8qiz8vNQM5sVYU+LqeNZHJe0wgfvMPcNgs6cd7HXCpHN8TUT3iF8fVvigDB5/ Xu7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=PicruJ+VHEPybZvyUaTHSXSbDBs5YreqCwZ14euAQts=; b=qsJ+SVW2NUKOjadjWUHlgLAcSHzHa+V6oQLqreHtGZ4WYFSMIeqBa122iK1xNde/jI imhCsecF2M7nGsRuSrVgi+FhNwb9eYKaBm4puw9mFU9bTb641opG4yh3ZZQpGDXW2rZl +seIPvp7kDeAeo1MiH1nAUu0VGLM6BHOeF5jTOZOIi3mnH2zP7P2aW7NiFiAnuZSnZum Wmn0yLVrQjP2bdhTVfUCSyXzApJ59bELHlv7JdS12eCX1uGy3uV59ACl1+jP3y47atmr n2lJOdFL1tQ/nWOWZX4zACkwx5GI1S8BujhlTNInIZZLSc2kyfKsQOe8JL93Hem5nNf/ 8pcw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d32si4673522qtd.116.2019.06.20.03.35.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:35:48 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 836851556B; Thu, 20 Jun 2019 10:35:41 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C9D560A97; Thu, 20 Jun 2019 10:35:35 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Vlastimil Babka , Michal Hocko , Mel Gorman , Wei Yang , Johannes Weiner , Arun KS , Pavel Tatashin , Oscar Salvador , Stephen Rothwell , Mike Rapoport , Baoquan He Subject: [PATCH v2 1/6] mm: Section numbers use the type "unsigned long" Date: Thu, 20 Jun 2019 12:35:15 +0200 Message-Id: <20190620103520.23481-2-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Jun 2019 10:35:47 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP We are using a mixture of "int" and "unsigned long". Let's make this consistent by using "unsigned long" everywhere. We'll do the same with memory block ids next. While at it, turn the "unsigned long i" in removable_show() into an int - sections_per_block is an int. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Vlastimil Babka Cc: Michal Hocko Cc: Dan Williams Cc: Mel Gorman Cc: Wei Yang Cc: Johannes Weiner Cc: Arun KS Cc: Pavel Tatashin Cc: Oscar Salvador Cc: Stephen Rothwell Cc: Mike Rapoport Cc: Baoquan He Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 27 +++++++++++++-------------- include/linux/mmzone.h | 4 ++-- mm/sparse.c | 12 ++++++------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 826dd76f662e..5947b5a5686d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -34,7 +34,7 @@ static DEFINE_MUTEX(mem_sysfs_mutex); static int sections_per_block; -static inline int base_memory_block_id(int section_nr) +static inline int base_memory_block_id(unsigned long section_nr) { return section_nr / sections_per_block; } @@ -131,9 +131,9 @@ static ssize_t phys_index_show(struct device *dev, static ssize_t removable_show(struct device *dev, struct device_attribute *attr, char *buf) { - unsigned long i, pfn; - int ret = 1; struct memory_block *mem = to_memory_block(dev); + unsigned long pfn; + int ret = 1, i; if (mem->state != MEM_ONLINE) goto out; @@ -691,15 +691,15 @@ static int init_memory_block(struct memory_block **memory, int block_id, return ret; } -static int add_memory_block(int base_section_nr) +static int add_memory_block(unsigned long base_section_nr) { + int ret, section_count = 0; struct memory_block *mem; - int i, ret, section_count = 0; + unsigned long nr; - for (i = base_section_nr; - i < base_section_nr + sections_per_block; - i++) - if (present_section_nr(i)) + for (nr = base_section_nr; nr < base_section_nr + sections_per_block; + nr++) + if (present_section_nr(nr)) section_count++; if (section_count == 0) @@ -822,10 +822,9 @@ static const struct attribute_group *memory_root_attr_groups[] = { */ int __init memory_dev_init(void) { - unsigned int i; int ret; int err; - unsigned long block_sz; + unsigned long block_sz, nr; ret = subsys_system_register(&memory_subsys, memory_root_attr_groups); if (ret) @@ -839,9 +838,9 @@ int __init memory_dev_init(void) * during boot and have been initialized */ mutex_lock(&mem_sysfs_mutex); - for (i = 0; i <= __highest_present_section_nr; - i += sections_per_block) { - err = add_memory_block(i); + for (nr = 0; nr <= __highest_present_section_nr; + nr += sections_per_block) { + err = add_memory_block(nr); if (!ret) ret = err; } diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h index 427b79c39b3c..83b6aae16f13 100644 --- a/include/linux/mmzone.h +++ b/include/linux/mmzone.h @@ -1220,7 +1220,7 @@ static inline struct mem_section *__nr_to_section(unsigned long nr) return NULL; return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; } -extern int __section_nr(struct mem_section* ms); +extern unsigned long __section_nr(struct mem_section *ms); extern unsigned long usemap_size(void); /* @@ -1292,7 +1292,7 @@ static inline struct mem_section *__pfn_to_section(unsigned long pfn) return __nr_to_section(pfn_to_section_nr(pfn)); } -extern int __highest_present_section_nr; +extern unsigned long __highest_present_section_nr; #ifndef CONFIG_HAVE_ARCH_PFN_VALID static inline int pfn_valid(unsigned long pfn) diff --git a/mm/sparse.c b/mm/sparse.c index 1552c855d62a..e8c57e039be8 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -102,7 +102,7 @@ static inline int sparse_index_init(unsigned long section_nr, int nid) #endif #ifdef CONFIG_SPARSEMEM_EXTREME -int __section_nr(struct mem_section* ms) +unsigned long __section_nr(struct mem_section *ms) { unsigned long root_nr; struct mem_section *root = NULL; @@ -121,9 +121,9 @@ int __section_nr(struct mem_section* ms) return (root_nr * SECTIONS_PER_ROOT) + (ms - root); } #else -int __section_nr(struct mem_section* ms) +unsigned long __section_nr(struct mem_section *ms) { - return (int)(ms - mem_section[0]); + return (unsigned long)(ms - mem_section[0]); } #endif @@ -178,10 +178,10 @@ void __meminit mminit_validate_memmodel_limits(unsigned long *start_pfn, * Keeping track of this gives us an easy way to break out of * those loops early. */ -int __highest_present_section_nr; +unsigned long __highest_present_section_nr; static void section_mark_present(struct mem_section *ms) { - int section_nr = __section_nr(ms); + unsigned long section_nr = __section_nr(ms); if (section_nr > __highest_present_section_nr) __highest_present_section_nr = section_nr; @@ -189,7 +189,7 @@ static void section_mark_present(struct mem_section *ms) ms->section_mem_map |= SECTION_MARKED_PRESENT; } -static inline int next_present_section_nr(int section_nr) +static inline unsigned long next_present_section_nr(unsigned long section_nr) { do { section_nr++; From patchwork Thu Jun 20 10:35:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD97414DB for ; Thu, 20 Jun 2019 10:35:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD5FF283A8 for ; Thu, 20 Jun 2019 10:35:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1B5A284AF; Thu, 20 Jun 2019 10:35:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41092283A8 for ; Thu, 20 Jun 2019 10:35:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 604076B0007; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5BF948E0002; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 42E9E8E0001; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 1BF966B0006 for ; Thu, 20 Jun 2019 06:35:49 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id e39so3008373qte.8 for ; Thu, 20 Jun 2019 03:35:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=avoS6L2KoFWgEbuyJgNZwy6yIMSlaOGkc4g5/F0NbSw=; b=hGIcG/f3wkaWoyLnTjHHCr78ENpDi4CzXe6VLmRArPYKHiPCQc/bqQVo7AbLt1CvRf zeKKbyEZurnVMVAzAejbzYjzpMWkG82Dzh8UlHWnubVUTbJ37dOGGa3gnr9EP3fv4Kpf kIs/c42sPctZWWpgReuXo280Q/eIzE3ZZBOvMt07gdWiwL9jviFgPwWxgBW0110gWstz vfybiSxLXh7JgYQHNxeZwEP1dVn5eco0Z7Ufn5jSKnDAxBi60ggNSum414jca/rTeTd0 M31y1F/KNi4Zf5Q11L2SxZMjkjmDcN01d2zyYS53sMrlUGHEMCmcvkUhhiGTRywlPJSN RgSQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAU9F1My9zJwOdWAnIgbGXzaM51QnFbhVGMuuddI4+yQFrkuCtoG gUvnb6R5O1WtLnZ7XVIbTYM2we4l+q4ObabhHOKWWjvGGM8AxPggo59+fxAiv/Q5OnzV8YrmYFN smqkY3Khzs8cklQsStnEwEfhZ0Ry5P3KT+9rwRlSJuGMrHl974TZ6fgPXnD3gvpvP6w== X-Received: by 2002:ac8:4982:: with SMTP id f2mr101469976qtq.213.1561026948878; Thu, 20 Jun 2019 03:35:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDmNaCks25gUONJY1qNanyHZJeBgNGacNJHOwfPGE+xUaVhDd0/48MtfNqFI2fG9kuG+9F X-Received: by 2002:ac8:4982:: with SMTP id f2mr101469902qtq.213.1561026947880; Thu, 20 Jun 2019 03:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026947; cv=none; d=google.com; s=arc-20160816; b=BRVVw1y92WF3a27VtAnXwF++ECinV7jRlGcHcLIY/tFXyAHfj1fQr/idK9vPhkIfU3 cX7UDC+Vm907o0uZo19y3+g3cmW69NwLuXZtTDVjfp+4Wkm6S8ci4v/ZlA5Tgf+yAkxx MmyUzFn7ZCLoGfofF1Lurx4jjLa9/KF2CI2tyNoD8hI27eHyCMcGwS9S3ybo1dApV6QB og8O+aP8c20utY3BE1opwaYJz2DeHpMJcshAQtu4nvx924jMAnjl8FB5cGeIdr6NcPgZ E5sQn/lnFb5S6Q+qvSbvXjdFs0EVOn/LD6d65gBmcsrx+3NMb1q2+MheJqqT253UDB9Z R7fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=avoS6L2KoFWgEbuyJgNZwy6yIMSlaOGkc4g5/F0NbSw=; b=ifafUlU3V3wjcuMh2U5X0BC1S9Qx2QLDTnRGJv6jmxSpULaOy7fAz5XC76HOE5ZePe udVj2FGRkTO1et+o3dt/SBdQxzq2IkHAp6D9uJ6yvoI3bRKSOfhUir+kLCt3QC/wY3OE etU6fivW8PedwQ5hL+eAANQKViqI+Pb6sig7vVqE6TgvG4/M4R58FUS8P6azd7vMmhzA ts08V5S/oHaOO00ETRMtRztoW0a/TLUdq51n6AXIA++VUNyNttdNikGKwxUx2ROPSp9l KZDpoDSBTjybM1+qb6GTwjcOjjF1yCEpVpZpWTl5B1xAeUPEvl0IczMPp1EeDfBdnf2h sF3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id m14si8393qke.372.2019.06.20.03.35.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 074DF2E97C7; Thu, 20 Jun 2019 10:35:47 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id D445160600; Thu, 20 Jun 2019 10:35:41 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" Subject: [PATCH v2 2/6] drivers/base/memory: Use "unsigned long" for block ids Date: Thu, 20 Jun 2019 12:35:16 +0200 Message-Id: <20190620103520.23481-3-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 20 Jun 2019 10:35:47 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP Block ids are just shifted section numbers, so let's also use "unsigned long" for them, too. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 5947b5a5686d..c54e80fd25a8 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -34,12 +34,12 @@ static DEFINE_MUTEX(mem_sysfs_mutex); static int sections_per_block; -static inline int base_memory_block_id(unsigned long section_nr) +static inline unsigned long base_memory_block_id(unsigned long section_nr) { return section_nr / sections_per_block; } -static inline int pfn_to_block_id(unsigned long pfn) +static inline unsigned long pfn_to_block_id(unsigned long pfn) { return base_memory_block_id(pfn_to_section_nr(pfn)); } @@ -587,7 +587,7 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) * A reference for the returned object is held and the reference for the * hinted object is released. */ -static struct memory_block *find_memory_block_by_id(int block_id, +static struct memory_block *find_memory_block_by_id(unsigned long block_id, struct memory_block *hint) { struct device *hintdev = hint ? &hint->dev : NULL; @@ -604,7 +604,7 @@ static struct memory_block *find_memory_block_by_id(int block_id, struct memory_block *find_memory_block_hinted(struct mem_section *section, struct memory_block *hint) { - int block_id = base_memory_block_id(__section_nr(section)); + unsigned long block_id = base_memory_block_id(__section_nr(section)); return find_memory_block_by_id(block_id, hint); } @@ -663,8 +663,8 @@ int register_memory(struct memory_block *memory) return ret; } -static int init_memory_block(struct memory_block **memory, int block_id, - unsigned long state) +static int init_memory_block(struct memory_block **memory, + unsigned long block_id, unsigned long state) { struct memory_block *mem; unsigned long start_pfn; @@ -729,8 +729,8 @@ static void unregister_memory(struct memory_block *memory) */ int create_memory_block_devices(unsigned long start, unsigned long size) { - const int start_block_id = pfn_to_block_id(PFN_DOWN(start)); - int end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); + const unsigned long start_block_id = pfn_to_block_id(PFN_DOWN(start)); + unsigned long end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); struct memory_block *mem; unsigned long block_id; int ret = 0; @@ -766,10 +766,10 @@ int create_memory_block_devices(unsigned long start, unsigned long size) */ void remove_memory_block_devices(unsigned long start, unsigned long size) { - const int start_block_id = pfn_to_block_id(PFN_DOWN(start)); - const int end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); + const unsigned long start_block_id = pfn_to_block_id(PFN_DOWN(start)); + const unsigned long end_block_id = pfn_to_block_id(PFN_DOWN(start + size)); struct memory_block *mem; - int block_id; + unsigned long block_id; if (WARN_ON_ONCE(!IS_ALIGNED(start, memory_block_size_bytes()) || !IS_ALIGNED(size, memory_block_size_bytes()))) From patchwork Thu Jun 20 10:35:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84B2A14BB for ; Thu, 20 Jun 2019 10:35:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72496285D4 for ; Thu, 20 Jun 2019 10:35:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D440285CC; Thu, 20 Jun 2019 10:35:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5811285CC for ; Thu, 20 Jun 2019 10:35:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7D9816B0008; Thu, 20 Jun 2019 06:35:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 763C48E0003; Thu, 20 Jun 2019 06:35:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 603DB8E0002; Thu, 20 Jun 2019 06:35:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 3AADB6B0008 for ; Thu, 20 Jun 2019 06:35:51 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id r40so3064040qtk.0 for ; Thu, 20 Jun 2019 03:35:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=CgJcDDtOoRdyVXX+iicAe9GvZqRRuW9//gwRK0vdIho=; b=ZcnUJW+C/3eu68iHjq6ZYfpQ4E1rjqj9eXaPjIJ63lbLyBQZZebPEjAsgSyGZ5HrWf U/fGt4wEF/AciK81S/v+KYV7T3Fr+iCI0gJ4Ymj6blb7EwBMH3ruA5FnQE++PU/DCxc1 g7PLf9ZLZgo0zZ9zEMZFXgj5TKu2OuLurF7aUZWfiCO5iPPBHx1tkIkZVQ6VB9QyaKE2 QBYMTI+EqaLsqZC6di45es8a6m1vS/nQiRaMCA2x1zNCG+W2EM9cg4qlaPv6Hlpy+QUU 1+giSQ/WaDR+GVyAelsUiB+IRWF1wSKWUplBUHd0oPjU5kXVNGH9xVM8MgMV1o98kIyM bujQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAUV2QgtUZF19uWTOtdxAxFST5uJ/CLET4sqIP9TD/xquY4V61iS 4ctzvx7WDyXQ0F3MTdX+WiYUZO+jTJwef3mpiImPjGn9WRalubS65qpsyE2zv74ayz7ywCF1sHJ 3ANVd+f4fSNoZtf3HsxEsxJaP+25owGUlmi6FHOfPaMB13M+dF132sz/kYtgHNEol8A== X-Received: by 2002:a37:4887:: with SMTP id v129mr24712197qka.17.1561026951002; Thu, 20 Jun 2019 03:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9rIxWn2pQR9fJuIlvyt3htGTOaQV/hb/F1E0KkAn7kTPqT2m6ige2AuiJEf60Nvkjv+Ef X-Received: by 2002:a37:4887:: with SMTP id v129mr24712152qka.17.1561026950234; Thu, 20 Jun 2019 03:35:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026950; cv=none; d=google.com; s=arc-20160816; b=GWJYlVj/lyHgI5EjW3uVMatsOVmF21L44sEERm7BAGfhS5fnqxqZ+CxqWydDlTjNQg k/R9aGCOulCr8tzahjRPME0RSCMH4P/davYhiR9sinG8aPDwHHS3mqhg08ECN2pwqB0F YRfgr81EKk2HcpQo4hAGflEq1ADEfuCFFA2jmGg7NRmJoNAvAB9GGZI9Qk54RjkImvHc Gm14yD8tQaOi/y2cBfdIN4ARbBVDVaqkcaL3dwRZ5Mu+k8mOu6VQEMigqUJnQThcevq6 6rnkviD4iHcmqdtSBBlF7gkgkB2btYZclm1zwPi2sfEUDQYRxzNACfdqYRo+b/BsV1R+ XfZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=CgJcDDtOoRdyVXX+iicAe9GvZqRRuW9//gwRK0vdIho=; b=lOTzuc9225l0NfSnuIrK01cdC0cln7nojlzdBh+L25cxThry7BWbH5CcXdy4qCk7YI Hay+en8OuSNq50G+M/UhNo6X8jY38VMGg3hjnX6bucfMwE/rSGdzENiU9TCfVcoeoYow qhhS2f/+e5G8Qzv/TIWzWNUFe3tEYHnYcDjvnNgY+i3MrQq175g8Ds2f+c742oTZbzPl p1io75gno73lUKuHjY9TjKGwiTiUDJMC31fQzyCSZIYZJprPxCL4NcWDEPHgwB5EQj/3 KHhMl6BfEErQki8kJyjJbovB8ourDdXfU7qsb5bIiuCNr+zIo8KcEFRtSgNfjsnCsNmD y4uQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id u28si13938963qkj.169.2019.06.20.03.35.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7828130C2534; Thu, 20 Jun 2019 10:35:49 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53CE860600; Thu, 20 Jun 2019 10:35:47 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Keith Busch , Oscar Salvador Subject: [PATCH v2 3/6] mm: Make register_mem_sect_under_node() static Date: Thu, 20 Jun 2019 12:35:17 +0200 Message-Id: <20190620103520.23481-4-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 20 Jun 2019 10:35:49 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP It is only used internally. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Keith Busch Cc: Oscar Salvador Signed-off-by: David Hildenbrand --- drivers/base/node.c | 3 ++- include/linux/node.h | 7 ------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/base/node.c b/drivers/base/node.c index 9be88fd05147..e6364e3e3e31 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -752,7 +752,8 @@ static int __ref get_nid_for_pfn(unsigned long pfn) } /* register memory section under specified node if it spans that node */ -int register_mem_sect_under_node(struct memory_block *mem_blk, void *arg) +static int register_mem_sect_under_node(struct memory_block *mem_blk, + void *arg) { int ret, nid = *(int *)arg; unsigned long pfn, sect_start_pfn, sect_end_pfn; diff --git a/include/linux/node.h b/include/linux/node.h index 548c226966a2..4866f32a02d8 100644 --- a/include/linux/node.h +++ b/include/linux/node.h @@ -137,8 +137,6 @@ static inline int register_one_node(int nid) extern void unregister_one_node(int nid); extern int register_cpu_under_node(unsigned int cpu, unsigned int nid); extern int unregister_cpu_under_node(unsigned int cpu, unsigned int nid); -extern int register_mem_sect_under_node(struct memory_block *mem_blk, - void *arg); extern void unregister_memory_block_under_nodes(struct memory_block *mem_blk); extern int register_memory_node_under_compute_node(unsigned int mem_nid, @@ -170,11 +168,6 @@ static inline int unregister_cpu_under_node(unsigned int cpu, unsigned int nid) { return 0; } -static inline int register_mem_sect_under_node(struct memory_block *mem_blk, - void *arg) -{ - return 0; -} static inline void unregister_memory_block_under_nodes(struct memory_block *mem_blk) { } From patchwork Thu Jun 20 10:35:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 60B6314DB for ; Thu, 20 Jun 2019 10:36:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F961285CC for ; Thu, 20 Jun 2019 10:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42F49285EA; Thu, 20 Jun 2019 10:36:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 311A8285CC for ; Thu, 20 Jun 2019 10:35:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 084118E0003; Thu, 20 Jun 2019 06:35:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 00E928E0002; Thu, 20 Jun 2019 06:35:57 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA6778E0003; Thu, 20 Jun 2019 06:35:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id B3BB38E0002 for ; Thu, 20 Jun 2019 06:35:57 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id z6so3021985qtj.7 for ; Thu, 20 Jun 2019 03:35:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=VMeP8L/qWslV2jjlEW9DSGEVWMFsOcD8qyH3nOU1iUI=; b=mEt+oPelqFUmKWboT2M6sMqEVt2IOYtVSd20HKV3teZz8UrGSf2YJLuSeNm4kJhEqA 4KERTLZz4umQ4btr52K1EbwIP7p/i1IbScOFfpEEUZoyZXlDDYBRU+KA8OpjP/lJasp0 4jbe2vWaCggt+sqDvfSiL/tNot3IB9XraH2oStRpy/EkKQ5S29GuuD0sKtpCmNkNkbqC 6u7kiUjMLvEiHtiGR9DwZhiXXKLdxKb21by4CEEH0+J9TknJPCsmgZ6MFShLRjGmvObO kZ8P8ZmAq2Ok4OpcCj5AehV2Y2k3FxkaWsX73rGWfL9TF2k63GFRSW0xbjSu8nja9dw+ v6Qg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAUReasdIf20YLL/8w/1COp8zSnEs7YImWIqIv6rObxXY7BsueMD xA0SQlQ1q9OYSIkoExYbd0NYWNMxkBowl8cZaKW1IQE6lLQ+E5vxw9/3FT59sltu+2pBJBOHTjJ FcegthiaKgLAgGsTc3rmciFAGEmZGEEkYuWmCJWAwTQMl61BbKK0kBCLRMUUoFXkklg== X-Received: by 2002:a37:5f82:: with SMTP id t124mr38077554qkb.180.1561026957494; Thu, 20 Jun 2019 03:35:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwesdMjJpa34QF2X1tFGKiBhhyewei49ZMhOZUYJaZz/G20yR9CjvecH6TkdS7qAPC25MWM X-Received: by 2002:a37:5f82:: with SMTP id t124mr38077480qkb.180.1561026956123; Thu, 20 Jun 2019 03:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026956; cv=none; d=google.com; s=arc-20160816; b=0l1F5isEgmhESD/JvmeUFJbSJ2jKkk5A8AV5ZuijwsZzPARjZc5fCEisdxNFTMCg3H 21XWXv2Ak1pMYGz1h0SLVEg2YWreXlzTXx+DDNMaifbo4AdLGi+Stmk8ldXbEcG2UNUD PzUXUWdeFHKcD0goaRX+HCGHTI43Lg12lR5TxBQ6T9RSc1Giz8WPDzdwgLJBiS//tMtO 38cn1/3fofhyxrt038gRixeI1uH+V/OXJBMufbsW0sf3jppNfbpmsLIrWT8UGVtCQv/U r9K8WMtaGnhOIw+UrcGYnfs2xnPhfQQBYqhPrAsCfBI9E9NmgY8/fWyKey6me/+pVAoB 2/TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=VMeP8L/qWslV2jjlEW9DSGEVWMFsOcD8qyH3nOU1iUI=; b=wG8m1WhXypswBRl9foGldhbvdNccZVGnDwqdKuB0tKBr6iTNL0YTbcEiCXpM++Cm4y V2ZbG7BjylVoDrnWw8i/dzAf7TacUJHL/z5frX+ZnX5cgSQYU4Wm++tKCMAW/xg2pTmU as67k13Aan4gMVCGwU6u2q2qvtWWY6lpclDtP3Lj15qfgOlbElPxpdOoeX785i10fOMO eMXrb2veM6WdWTO8rIYdPVbaswuGfRaDJhM/tDB2kZVfXRKc/eB4E6hYay759PIo2a1U J7WkEeM3ZbiI90MP1IPwtM4eYmFhB4me9VFcMvSTnRkF84a/vdiXYX3T75krI+KtFfQm gxJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id w190si8711qka.294.2019.06.20.03.35.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 242293098576; Thu, 20 Jun 2019 10:35:55 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id C66445F7C0; Thu, 20 Jun 2019 10:35:49 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , "Rafael J. Wysocki" , Len Brown , Greg Kroah-Hartman , Rashmica Gupta , Pavel Tatashin , Anshuman Khandual , Michael Neuling , Thomas Gleixner , Oscar Salvador , Michal Hocko , Wei Yang , Juergen Gross , Qian Cai , Arun KS Subject: [PATCH v2 4/6] mm/memory_hotplug: Rename walk_memory_range() and pass start+size instead of pfns Date: Thu, 20 Jun 2019 12:35:18 +0200 Message-Id: <20190620103520.23481-5-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 20 Jun 2019 10:35:55 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP walk_memory_range() was once used to iterate over sections. Now, it iterates over memory blocks. Rename the function, fixup the documentation. Also, pass start+size instead of PFNs, which is what most callers already have at hand. (we'll rework link_mem_sections() most probably soon) Follow-up patches wil rework, simplify, and move walk_memory_blocks() to drivers/base/memory.c. Note: walk_memory_blocks() only works correctly right now if the start_pfn is aligned to a section start. This is the case right now, but we'll generalize the function in a follow up patch so the semantics match the documentation. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Michael Ellerman Cc: "Rafael J. Wysocki" Cc: Len Brown Cc: Greg Kroah-Hartman Cc: David Hildenbrand Cc: Rashmica Gupta Cc: Andrew Morton Cc: Pavel Tatashin Cc: Anshuman Khandual Cc: Michael Neuling Cc: Thomas Gleixner Cc: Oscar Salvador Cc: Michal Hocko Cc: Wei Yang Cc: Juergen Gross Cc: Qian Cai Cc: Arun KS Signed-off-by: David Hildenbrand --- arch/powerpc/platforms/powernv/memtrace.c | 22 ++++++++++----------- drivers/acpi/acpi_memhotplug.c | 19 ++++-------------- drivers/base/node.c | 5 +++-- include/linux/memory_hotplug.h | 2 +- mm/memory_hotplug.c | 24 ++++++++++++----------- 5 files changed, 32 insertions(+), 40 deletions(-) diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index 5e53c1392d3b..8c82c041afe6 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c @@ -70,23 +70,24 @@ static int change_memblock_state(struct memory_block *mem, void *arg) /* called with device_hotplug_lock held */ static bool memtrace_offline_pages(u32 nid, u64 start_pfn, u64 nr_pages) { + const unsigned long start = PFN_PHYS(start_pfn); + const unsigned long size = PFN_PHYS(nr_pages); u64 end_pfn = start_pfn + nr_pages - 1; - if (walk_memory_range(start_pfn, end_pfn, NULL, - check_memblock_online)) + if (walk_memory_blocks(start, size, NULL, check_memblock_online)) return false; - walk_memory_range(start_pfn, end_pfn, (void *)MEM_GOING_OFFLINE, - change_memblock_state); + walk_memory_blocks(start, size, (void *)MEM_GOING_OFFLINE, + change_memblock_state); if (offline_pages(start_pfn, nr_pages)) { - walk_memory_range(start_pfn, end_pfn, (void *)MEM_ONLINE, - change_memblock_state); + walk_memory_blocks(start, size, (void *)MEM_ONLINE, + change_memblock_state); return false; } - walk_memory_range(start_pfn, end_pfn, (void *)MEM_OFFLINE, - change_memblock_state); + walk_memory_blocks(start, size, (void *)MEM_OFFLINE, + change_memblock_state); return true; @@ -242,9 +243,8 @@ static int memtrace_online(void) */ if (!memhp_auto_online) { lock_device_hotplug(); - walk_memory_range(PFN_DOWN(ent->start), - PFN_UP(ent->start + ent->size - 1), - NULL, online_mem_block); + walk_memory_blocks(ent->start, ent->size, NULL, + online_mem_block); unlock_device_hotplug(); } diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c index db013dc21c02..e294f44a7850 100644 --- a/drivers/acpi/acpi_memhotplug.c +++ b/drivers/acpi/acpi_memhotplug.c @@ -155,16 +155,6 @@ static int acpi_memory_check_device(struct acpi_memory_device *mem_device) return 0; } -static unsigned long acpi_meminfo_start_pfn(struct acpi_memory_info *info) -{ - return PFN_DOWN(info->start_addr); -} - -static unsigned long acpi_meminfo_end_pfn(struct acpi_memory_info *info) -{ - return PFN_UP(info->start_addr + info->length-1); -} - static int acpi_bind_memblk(struct memory_block *mem, void *arg) { return acpi_bind_one(&mem->dev, arg); @@ -173,9 +163,8 @@ static int acpi_bind_memblk(struct memory_block *mem, void *arg) static int acpi_bind_memory_blocks(struct acpi_memory_info *info, struct acpi_device *adev) { - return walk_memory_range(acpi_meminfo_start_pfn(info), - acpi_meminfo_end_pfn(info), adev, - acpi_bind_memblk); + return walk_memory_blocks(info->start_addr, info->length, adev, + acpi_bind_memblk); } static int acpi_unbind_memblk(struct memory_block *mem, void *arg) @@ -186,8 +175,8 @@ static int acpi_unbind_memblk(struct memory_block *mem, void *arg) static void acpi_unbind_memory_blocks(struct acpi_memory_info *info) { - walk_memory_range(acpi_meminfo_start_pfn(info), - acpi_meminfo_end_pfn(info), NULL, acpi_unbind_memblk); + walk_memory_blocks(info->start_addr, info->length, NULL, + acpi_unbind_memblk); } static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) diff --git a/drivers/base/node.c b/drivers/base/node.c index e6364e3e3e31..d8c02e65df68 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -833,8 +833,9 @@ void unregister_memory_block_under_nodes(struct memory_block *mem_blk) int link_mem_sections(int nid, unsigned long start_pfn, unsigned long end_pfn) { - return walk_memory_range(start_pfn, end_pfn, (void *)&nid, - register_mem_sect_under_node); + return walk_memory_blocks(PFN_PHYS(start_pfn), + PFN_PHYS(end_pfn - start_pfn), (void *)&nid, + register_mem_sect_under_node); } #ifdef CONFIG_HUGETLBFS diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 79e0add6a597..d9fffc34949f 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -340,7 +340,7 @@ static inline void __remove_memory(int nid, u64 start, u64 size) {} #endif /* CONFIG_MEMORY_HOTREMOVE */ extern void __ref free_area_init_core_hotplug(int nid); -extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, +extern int walk_memory_blocks(unsigned long start, unsigned long size, void *arg, int (*func)(struct memory_block *, void *)); extern int __add_memory(int nid, u64 start, u64 size); extern int add_memory(int nid, u64 start, u64 size); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index a88c5f334e5a..122a7d31efdd 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1126,8 +1126,7 @@ int __ref add_memory_resource(int nid, struct resource *res) /* online pages if requested */ if (memhp_auto_online) - walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), - NULL, online_memory_block); + walk_memory_blocks(start, size, NULL, online_memory_block); return ret; error: @@ -1665,20 +1664,24 @@ int offline_pages(unsigned long start_pfn, unsigned long nr_pages) #endif /* CONFIG_MEMORY_HOTREMOVE */ /** - * walk_memory_range - walks through all mem sections in [start_pfn, end_pfn) - * @start_pfn: start pfn of the memory range - * @end_pfn: end pfn of the memory range + * walk_memory_blocks - walk through all present memory blocks overlapped + * by the range [start, start + size) + * + * @start: start address of the memory range + * @size: size of the memory range * @arg: argument passed to func - * @func: callback for each memory section walked + * @func: callback for each memory block walked * - * This function walks through all present mem sections in range - * [start_pfn, end_pfn) and call func on each mem section. + * This function walks through all present memory blocks overlapped by the + * range [start, start + size), calling func on each memory block. * * Returns the return value of func. */ -int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, +int walk_memory_blocks(unsigned long start, unsigned long size, void *arg, int (*func)(struct memory_block *, void *)) { + const unsigned long start_pfn = PFN_DOWN(start); + const unsigned long end_pfn = PFN_UP(start + size - 1); struct memory_block *mem = NULL; struct mem_section *section; unsigned long pfn, section_nr; @@ -1824,8 +1827,7 @@ static int __ref try_remove_memory(int nid, u64 start, u64 size) * whether all memory blocks in question are offline and return error * if this is not the case. */ - rc = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL, - check_memblock_offlined_cb); + rc = walk_memory_blocks(start, size, NULL, check_memblock_offlined_cb); if (rc) goto done; From patchwork Thu Jun 20 10:35:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F138614BB for ; Thu, 20 Jun 2019 10:36:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E240D285CC for ; Thu, 20 Jun 2019 10:36:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D607C285EA; Thu, 20 Jun 2019 10:36:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B330285CC for ; Thu, 20 Jun 2019 10:36:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A24188E0005; Thu, 20 Jun 2019 06:36:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AA878E0002; Thu, 20 Jun 2019 06:36:01 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 873158E0005; Thu, 20 Jun 2019 06:36:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id 5FC638E0002 for ; Thu, 20 Jun 2019 06:36:01 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id l16so3050098qkk.9 for ; Thu, 20 Jun 2019 03:36:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xosbEIjLFiGE08Kfhn6doMeJLReGW2/GZVrriI9jhUA=; b=hJT6FVfJKT4y/gUGINvC0lR9F8jFUrJ6Bp8dQDZQtlE1346TOx952qvReuzn2bpqj1 5tst+LxeMuJH9x2z64yUe8RaiSzWcHfZCZlwEUitd6xhFK5PeaWwROsro6i5rqlsR9J6 sWyU3BRo+O4T5wZJqSoFy6ElflBZTuhTM6g2xHhPfxSrRs4xkuFDHeWPHoi0W2AHzjbC Jri2Bj3pA1QwDol9MI8HrFYQjAZxvKh0SrovBBAIU/egN/o1WQkDhnBI3ELOmXpIOisd dDx9OuvYCxqzS2j1Vvqmv8ZTDOVNy1LAy33vnk05/1AB48rBOG3eic2Kav87vVQ4ZzxX B52w== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAUx3onZr/rxlIjWy1/+3pisaXz5CrRe2bIxK2DalmrQI8qGYugb rG0pmTYh7y8UDsOyh4Whh6a/wQ5IWgGL2FJVvTW+OoKtxg95Qr/hSNqSO/7127xsf1yIJP+w/H/ cz0TJEHqfvreTnH1T5RnvQRSK5hw/XpTQHyNeMyMSkFwF9SQhYGHSSFoGb2oUdiwNeQ== X-Received: by 2002:ac8:24f5:: with SMTP id t50mr107916218qtt.285.1561026961154; Thu, 20 Jun 2019 03:36:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfPJbipuYeODWitIl5RMt0xnNydnPLi5jt27NoeGUfXsT9HftaT+EQh/XnTZyBX9EnaBY+ X-Received: by 2002:ac8:24f5:: with SMTP id t50mr107916151qtt.285.1561026960020; Thu, 20 Jun 2019 03:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026960; cv=none; d=google.com; s=arc-20160816; b=arLlApyuUR8otr238LeeaPco7EuulCZJtz7Y6JiwCZ/mXccf2qNDFeZqOPR/dBVcHh 9pnyZGl54U+gAvONmG0vGMyfat1NP6Dc43UwhNWJHTMx2cARoATNRV6AsTq8QycUQ36S 8vaMhz15CRba0YUlmShdAXGZVGAGqrwdyyrHcCT9QSm/JB6hrZc8BMj9UGvcFI58TbsJ jBMUSvJ7CC4wCpS1Yc7+gTO8H/JzzfV3kenIsaCJjHRbOU4gkpTJCIsIJGJulLV6qa9C ONhFMxnmOV9Bps0oj7WyW1RwApys138fuUUcif+DuMQGdO+1fiCa31N33WJmRPMTqapD G+2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=xosbEIjLFiGE08Kfhn6doMeJLReGW2/GZVrriI9jhUA=; b=BZlzeMr0+7qsC7DLEC9RlwRTQi61OwR0/cA5TQ+BezQEFCw6r9QL2wfNoVbPbYGtkk T55Nt1Q2G+Cgrl4u0hIw2XXLEjJZ+Mo5HtOefTCPG5h5JwwTrv9Cl+jCnN7sI02WXE3m KY3HbwmP1H1resUGA8PXz7FjDlfhori1GejIMdfwZo71ORR8HbnPDMi1uOuaKNCdqLvz +h4dtnH0pNWaFA72qvjhJdGPTZ7yux7Jbw9ty7QEnijyLzGOhv6mDNG3lp4KT2ygOeA/ 1ZroGrldfpoFcJKsK35FThHBZqdWPFO2VBx+N4O4pFMGXW523OJqHi+aJD/GAvthbo4L efsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id j3si4471438qtq.155.2019.06.20.03.35.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:36:00 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11F6230BC57F; Thu, 20 Jun 2019 10:35:59 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 72834608A7; Thu, 20 Jun 2019 10:35:55 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Stephen Rothwell , Pavel Tatashin , Andrew Banman , "mike.travis@hpe.com" , Oscar Salvador , Michal Hocko , Wei Yang , Arun KS , Qian Cai Subject: [PATCH v2 5/6] mm/memory_hotplug: Move and simplify walk_memory_blocks() Date: Thu, 20 Jun 2019 12:35:19 +0200 Message-Id: <20190620103520.23481-6-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 20 Jun 2019 10:35:59 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP Let's move walk_memory_blocks() to the place where memory block logic resides and simplify it. While at it, add a type for the callback function. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: David Hildenbrand Cc: Andrew Morton Cc: Stephen Rothwell Cc: Pavel Tatashin Cc: Andrew Banman Cc: "mike.travis@hpe.com" Cc: Oscar Salvador Cc: Michal Hocko Cc: Wei Yang Cc: Arun KS Cc: Qian Cai Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 42 ++++++++++++++++++++++++++ include/linux/memory.h | 3 ++ include/linux/memory_hotplug.h | 2 -- mm/memory_hotplug.c | 55 ---------------------------------- 4 files changed, 45 insertions(+), 57 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index c54e80fd25a8..0204384b4d1d 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -44,6 +44,11 @@ static inline unsigned long pfn_to_block_id(unsigned long pfn) return base_memory_block_id(pfn_to_section_nr(pfn)); } +static inline unsigned long phys_to_block_id(unsigned long phys) +{ + return pfn_to_block_id(PFN_DOWN(phys)); +} + static int memory_subsys_online(struct device *dev); static int memory_subsys_offline(struct device *dev); @@ -851,3 +856,40 @@ int __init memory_dev_init(void) printk(KERN_ERR "%s() failed: %d\n", __func__, ret); return ret; } + +/** + * walk_memory_blocks - walk through all present memory blocks overlapped + * by the range [start, start + size) + * + * @start: start address of the memory range + * @size: size of the memory range + * @arg: argument passed to func + * @func: callback for each memory section walked + * + * This function walks through all present memory blocks overlapped by the + * range [start, start + size), calling func on each memory block. + * + * In case func() returns an error, walking is aborted and the error is + * returned. + */ +int walk_memory_blocks(unsigned long start, unsigned long size, + void *arg, walk_memory_blocks_func_t func) +{ + const unsigned long start_block_id = phys_to_block_id(start); + const unsigned long end_block_id = phys_to_block_id(start + size - 1); + struct memory_block *mem; + unsigned long block_id; + int ret = 0; + + for (block_id = start_block_id; block_id <= end_block_id; block_id++) { + mem = find_memory_block_by_id(block_id, NULL); + if (!mem) + continue; + + ret = func(mem, arg); + put_device(&mem->dev); + if (ret) + break; + } + return ret; +} diff --git a/include/linux/memory.h b/include/linux/memory.h index f26a5417ec5d..b3b388775a30 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -119,6 +119,9 @@ extern int memory_isolate_notify(unsigned long val, void *v); extern struct memory_block *find_memory_block_hinted(struct mem_section *, struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); +typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); +extern int walk_memory_blocks(unsigned long start, unsigned long size, + void *arg, walk_memory_blocks_func_t func); #define CONFIG_MEM_BLOCK_SIZE (PAGES_PER_SECTION<= mem->start_section_nr) && - (section_nr <= mem->end_section_nr)) - continue; - - mem = find_memory_block_hinted(section, mem); - if (!mem) - continue; - - ret = func(mem, arg); - if (ret) { - kobject_put(&mem->dev.kobj); - return ret; - } - } - - if (mem) - kobject_put(&mem->dev.kobj); - - return 0; -} - -#ifdef CONFIG_MEMORY_HOTREMOVE static int check_memblock_offlined_cb(struct memory_block *mem, void *arg) { int ret = !is_memblock_offlined(mem); From patchwork Thu Jun 20 10:35:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11006423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B37B714DB for ; Thu, 20 Jun 2019 10:36:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3584285CC for ; Thu, 20 Jun 2019 10:36:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 965E4285EA; Thu, 20 Jun 2019 10:36:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 030DB285CC for ; Thu, 20 Jun 2019 10:36:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EAC78E0006; Thu, 20 Jun 2019 06:36:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 872898E0002; Thu, 20 Jun 2019 06:36:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 713DC8E0006; Thu, 20 Jun 2019 06:36:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 498408E0002 for ; Thu, 20 Jun 2019 06:36:04 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id c4so3016895qkd.16 for ; Thu, 20 Jun 2019 03:36:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DoTahoElNd51FKBs5W52n2Aegfmsf/gprGY01Gxnd1k=; b=JMy2qVpcKGO/R0LrZlzECXjfefYkhiQ5kLgMHOP1bKhpo/lkiCcfW9lx682HnV+z1f z1EqvlTLS40Q9UI/utrPb+1y50mNmFIcjAPofgDEc8jk/4IZMtFoe9I46ux4HNtXOa5S 4yXFv3M+MLIwOyUd+j4f7m8/i1Rtc8aaaBW4EeCx9FiRawZ/m6A5bSv4GKrn3bhBMmlO MBxWH6nNelXpiYM2u8tbu3znRaUHbWuMHeBTqxnDKKDAwi7rcwtpgj10Xxlb6xPpoQX6 TXaglMzXsmvnmsgVwX4O4a26Hj//0Jh7R6olf8cwCrxbpvsg70Dwx6xQiOslgez/phdz Uo0A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APjAAAUF8Es8AJF2HWdm2b/uSVx3UFfj3Y3iO0+eiOHEM3teUNXTaKVD h1e1Th/mHekBhG6Js3fIymgmtulohIzEAuDJgaxpNB4JK8P2H0F05sEVe9pC12mt3w0+y/6hFbZ 8FT0a0GE8Nd32KH4QFcjOwlkTfu0pWwMjThwKltVV1X3+/Q2+hUv2DF/JSquadm/CfQ== X-Received: by 2002:ac8:3932:: with SMTP id s47mr112367173qtb.264.1561026964042; Thu, 20 Jun 2019 03:36:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqx3VSOgZbEdKrqkaxsaRLCVk4MHsZm1qv9Ah0MMPdqFEhlsJsWILnlMcr9tYXOhir3X/BQf X-Received: by 2002:ac8:3932:: with SMTP id s47mr112367108qtb.264.1561026963137; Thu, 20 Jun 2019 03:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561026963; cv=none; d=google.com; s=arc-20160816; b=ph84ztAzI1tO01fTrcRfYZGi3z8yIWZBqgR3BRq3QPsPWTkUPsefv18U0Y+ynxeJPm niQc0zl6NfBkEny/TtxWSsLr1/iPeTYJk0cK+55EfKqhroyc4XVrSF7TPke5Hmrz4SL8 qkVT852201KeRZR6FeTHN8NQMRxdDyGOxPwTlQMIIGOpqCwCIy8j0QAqFt+tq33LJgUs 8ulPuCt1hQrJHVdJ+fGSX0XY8sZ+OVE6UNx9yi7uqz+C4bLoygVEph0xh5dcYSzdHt1Q ihpBe4k/lvAaB+GgdUJK5GpP2EDSqk9x7wDyjtKmQ77SM6gzIE2ez9ssP6WE1L54BbYP CkVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=DoTahoElNd51FKBs5W52n2Aegfmsf/gprGY01Gxnd1k=; b=NUwXgxECHKVlh+zo3CujOKx+7fLsPoTNsF2KojD7FJ/2mAdc3XISTM6mNmtZE1zXRF whrBRdfT6d4zQe5kcGzbHYuP2vWulBuKXXED3SbgD/PiI7dhWl8ozkENoinlAb5FqMMJ 4nunWLQGxbnu0f4wH5zJ92ED/u3UCB/bYIV2Rx1UCuhg6vjayFCjsiuk+t55g6md67qL mxj4dPLqQRGOjXl2bbE6KIKfHPiq+y4QQNWZ3mj7VK33IdVU+lzN5v6EBvdmSmNsON2b k5yXzgf9PzmtkSMxURd7nn3HIVa+EpsIlklkXYjj0pqCRV+YgX3FqKAUanNfahgeb7Wd CNiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id k23si15303426qke.240.2019.06.20.03.36.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 03:36:03 -0700 (PDT) Received-SPF: pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of david@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3AF3386663; Thu, 20 Jun 2019 10:36:02 +0000 (UTC) Received: from t460s.redhat.com (ovpn-117-88.ams2.redhat.com [10.36.117.88]) by smtp.corp.redhat.com (Postfix) with ESMTP id 628215C66B; Thu, 20 Jun 2019 10:35:59 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: Dan Williams , Andrew Morton , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, David Hildenbrand , Greg Kroah-Hartman , "Rafael J. Wysocki" , Stephen Rothwell , Pavel Tatashin , "mike.travis@hpe.com" Subject: [PATCH v2 6/6] drivers/base/memory.c: Get rid of find_memory_block_hinted() Date: Thu, 20 Jun 2019 12:35:20 +0200 Message-Id: <20190620103520.23481-7-david@redhat.com> In-Reply-To: <20190620103520.23481-1-david@redhat.com> References: <20190620103520.23481-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Jun 2019 10:36:02 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP No longer needed, let's remove it. Also, drop the "hint" parameter completely from "find_memory_block_by_id", as nobody needs it anymore. Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Andrew Morton Cc: Stephen Rothwell Cc: Pavel Tatashin Cc: "mike.travis@hpe.com" Signed-off-by: David Hildenbrand --- drivers/base/memory.c | 32 ++++++++++---------------------- include/linux/memory.h | 2 -- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 0204384b4d1d..fefb64d3588e 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -592,26 +592,12 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) * A reference for the returned object is held and the reference for the * hinted object is released. */ -static struct memory_block *find_memory_block_by_id(unsigned long block_id, - struct memory_block *hint) +static struct memory_block *find_memory_block_by_id(unsigned long block_id) { - struct device *hintdev = hint ? &hint->dev : NULL; struct device *dev; - dev = subsys_find_device_by_id(&memory_subsys, block_id, hintdev); - if (hint) - put_device(&hint->dev); - if (!dev) - return NULL; - return to_memory_block(dev); -} - -struct memory_block *find_memory_block_hinted(struct mem_section *section, - struct memory_block *hint) -{ - unsigned long block_id = base_memory_block_id(__section_nr(section)); - - return find_memory_block_by_id(block_id, hint); + dev = subsys_find_device_by_id(&memory_subsys, block_id, NULL); + return dev ? to_memory_block(dev) : NULL; } /* @@ -624,7 +610,9 @@ struct memory_block *find_memory_block_hinted(struct mem_section *section, */ struct memory_block *find_memory_block(struct mem_section *section) { - return find_memory_block_hinted(section, NULL); + unsigned long block_id = base_memory_block_id(__section_nr(section)); + + return find_memory_block_by_id(block_id); } static struct attribute *memory_memblk_attrs[] = { @@ -675,7 +663,7 @@ static int init_memory_block(struct memory_block **memory, unsigned long start_pfn; int ret = 0; - mem = find_memory_block_by_id(block_id, NULL); + mem = find_memory_block_by_id(block_id); if (mem) { put_device(&mem->dev); return -EEXIST; @@ -755,7 +743,7 @@ int create_memory_block_devices(unsigned long start, unsigned long size) end_block_id = block_id; for (block_id = start_block_id; block_id != end_block_id; block_id++) { - mem = find_memory_block_by_id(block_id, NULL); + mem = find_memory_block_by_id(block_id); mem->section_count = 0; unregister_memory(mem); } @@ -782,7 +770,7 @@ void remove_memory_block_devices(unsigned long start, unsigned long size) mutex_lock(&mem_sysfs_mutex); for (block_id = start_block_id; block_id != end_block_id; block_id++) { - mem = find_memory_block_by_id(block_id, NULL); + mem = find_memory_block_by_id(block_id); if (WARN_ON_ONCE(!mem)) continue; mem->section_count = 0; @@ -882,7 +870,7 @@ int walk_memory_blocks(unsigned long start, unsigned long size, int ret = 0; for (block_id = start_block_id; block_id <= end_block_id; block_id++) { - mem = find_memory_block_by_id(block_id, NULL); + mem = find_memory_block_by_id(block_id); if (!mem) continue; diff --git a/include/linux/memory.h b/include/linux/memory.h index b3b388775a30..02e633f3ede0 100644 --- a/include/linux/memory.h +++ b/include/linux/memory.h @@ -116,8 +116,6 @@ void remove_memory_block_devices(unsigned long start, unsigned long size); extern int memory_dev_init(void); extern int memory_notify(unsigned long val, void *v); extern int memory_isolate_notify(unsigned long val, void *v); -extern struct memory_block *find_memory_block_hinted(struct mem_section *, - struct memory_block *); extern struct memory_block *find_memory_block(struct mem_section *); typedef int (*walk_memory_blocks_func_t)(struct memory_block *, void *); extern int walk_memory_blocks(unsigned long start, unsigned long size,