From patchwork Thu Jun 20 18:31:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007655 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 CF290112C for ; Thu, 20 Jun 2019 18:32:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFAFE271CB for ; Thu, 20 Jun 2019 18:32:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3C25286A2; Thu, 20 Jun 2019 18:32:24 +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 EBB302866D for ; Thu, 20 Jun 2019 18:32:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC8696B0006; Thu, 20 Jun 2019 14:32:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BA11B8E0003; Thu, 20 Jun 2019 14:32:22 -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 A41938E0002; Thu, 20 Jun 2019 14:32:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 7BAC06B0006 for ; Thu, 20 Jun 2019 14:32:22 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id s9so4795849qtn.14 for ; Thu, 20 Jun 2019 11:32:22 -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=UvLMHUntMOjZa0lEJvNyPm3ldTyg3szMg7m9QWLE7xdPlO0L+hrTKjvzxvNrYxbj4t vpHNArHE1YL1eBvrW3teT+5V63mFTt4Hy6v4lAFfKwMC34yDUGaFtSpy39kYsr4t4lGN 0aSf4dfTM1fPq46shEsinHkbwneLYHPCH68X3+4SuxkZQ6s3rv2M6uxcIaTFz4YGIsQ8 9oYNJVa+XWjtYt2Ne6zFheJzdqrXLLIcMmJ87AsjLYGQAv4Mgb5IpnHJWdJZCbei+UPr rjkUE6t7vTIBhBg/7TAA4BJ9tsZid5qpj5hc4tIbZTn+dVaDA3RQXlQcDgtAmzk4sdRl crFw== 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: APjAAAWDEQCEpSir3oNhPCHIDwgEBOY+vLBlU+/ldguMMi0TfKp1pOBJ n7LG//k9mdOZRpU7BzT73PWxUXKvtvfRZIAiIWquNh3BZJbZ8PN6MES5kaSRQWxnXIxY08mhzAt FmIGEp054DzUAgMw2x33arkFZiXx68zO8bA9PuYm04Ht1N87RL6JvMumV5ACUjgVZlg== X-Received: by 2002:a0c:8aaa:: with SMTP id 39mr41144882qvv.17.1561055542259; Thu, 20 Jun 2019 11:32:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwac4mbNsCBlhDqyecFOI5XA//glC71rAjJe7umkZUrNjFToBps1KnuPYD3BC6z80rqsP1Q X-Received: by 2002:a0c:8aaa:: with SMTP id 39mr41144798qvv.17.1561055541293; Thu, 20 Jun 2019 11:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055541; cv=none; d=google.com; s=arc-20160816; b=bxjgvf/EJ/qkEfbcHgWog48t/6wXZiwy56q0SshvIM0+NDQFlG0z2/bIdepuydEC9g gZ4+Xi1PNYwaztlaqCmnC71TwQhxQRyUyP+uORQ4zD2pLRG/OCX5mjiAzLVuxr8opp9/ 15WJwjgPnjDfGDU4C7pdOzSrQlgWHzbaadp9rWILvW/srieCsWj5NrM+CgsOA+isfWGq ZKN5Cnnl203vaWaApEBJQ79Tr/MDGJRxJBpLu3GFvPdYHd2XRNlqlEb6alApG5AVmD2r PyDhv3CEFerx9+LhkrFn0xKxL7Bh5O/PlL56sU7As2rBZLhZ2W2IzrCTyhv1muf4mfox a8mg== 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=uQpYfz0QcLti9TlGeSmXAQpZv1J1992Ia3MIWMYdwBAtf1bfVyS0NFl4qpqUojGTpa GXeFe7f2WvaCWSfNCG3vWA263Hmejx7xdmBh+SNUnfRsOB2p83dIeXm9Y/ghWjgyPlQz GPiEydadZgcypZ03P+xkksBjxmEZdfDA3NjfZKnXjTWhAZ2OUyUxvme/OgGBVMkYlIxS K0bbhaA8pJY2M2InODR+gNKXp04oZEJvcYVjDEoKSGwQ46PxqnA95tF8+G0GEn8Y9/Fw S4Vu+IPNWqv8oyyvoiVoxqkNzBk6iHlPgIDUBIlp216jLkf0Ij302RGqCi7Bs6DtiqNX NhQQ== 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 g187si127981qkc.5.2019.06.20.11.32.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:21 -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-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 37276C18B2EB; Thu, 20 Jun 2019 18:32:04 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FA1619C5B; Thu, 20 Jun 2019 18:31:58 +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 v3 1/6] mm: Section numbers use the type "unsigned long" Date: Thu, 20 Jun 2019 20:31:34 +0200 Message-Id: <20190620183139.4352-2-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.31]); Thu, 20 Jun 2019 18:32:06 +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 18:31:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007657 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 D722D76 for ; Thu, 20 Jun 2019 18:32:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB63B271CB for ; Thu, 20 Jun 2019 18:32:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFA65286A2; Thu, 20 Jun 2019 18:32:27 +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 4EF5C271CB for ; Thu, 20 Jun 2019 18:32:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 191206B0007; Thu, 20 Jun 2019 14:32:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1690B8E0003; Thu, 20 Jun 2019 14:32:26 -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 02FC98E0002; Thu, 20 Jun 2019 14:32:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id D32566B0007 for ; Thu, 20 Jun 2019 14:32:25 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id l16so4791996qkk.9 for ; Thu, 20 Jun 2019 11:32:25 -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=B4bFmb/Jo9hjzmE+P2sEIPwIuVbhHtngeZBcAw9r7ZULN+tiEHXMuCGXsSRGzE2eIW XwhKBlpn9c4u3ZVZ5OxmHVPLuVt+IEt5X/zQe0vWn56TARBvPvtd758dWhqPzaOfkE0a 5mPu2IIfFrKR6lwihdt1dZwhbwCAeFVkX3P+vdrKSWBosLL3WRhQNPz42guTzgO/Zn0R 0WFzTs8oBgXWvEOPZxo4nx5YvHou/mVFW7K3cIcjxYnThHthreRtOXfJM+lpGPCpkFRy yuscKQVIMZXW4+jVOCeM1NQHC6YlB6tnx/ZpQpEiGGaYFpOxT0RMMGRvL7T70V74HLNW QoeQ== 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: APjAAAXJlNHjC/Wy1h9cGa2bG1kHJqtirL0yfucldX177oGOX1ULpUWE yvTHrUwJHZyg6qh5NczaFVOpJQiR/TGmwGw5nBGNpR4xsKJYfRgfscMqlxATJ4Cbg9dFQIXyy9e LrB4NKp6pmD4Gw/YWXYDE0wnUMf0Ua+ZUAkGNWOHqc6caCfPc/Vr1KQM884gR6gtqBQ== X-Received: by 2002:a0c:c146:: with SMTP id i6mr41482870qvh.79.1561055545642; Thu, 20 Jun 2019 11:32:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdA/9VNzw3VU/rWV+XsPFNTTlXTGAgILKuHDKFDu/l6gvJOBDXsXP8PjWMkbPdgCKbOTkh X-Received: by 2002:a0c:c146:: with SMTP id i6mr41482773qvh.79.1561055544626; Thu, 20 Jun 2019 11:32:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055544; cv=none; d=google.com; s=arc-20160816; b=E8mdkNb1nuquKQUgHyC4Cw5F1H+5hF/rBalV3BbnH8wkhLHjR/wmrOg1kJ3Trw3aw3 Q7qkdZVc4JT8RgBNDHb+SOcYWxp9FTKWIEXZl/EWr2sQ+3+2dpeU5oB59QPth66emKR4 fozfN+ZMza2DNiEpFcWK44acjmMUkJY8e5rxLoTWnOIh6iSyMpzF/Uv34P9RW0HwhzUz Zi2BkHX9rAXx8PkjrHerYK/IlCaktJVbCWlmR6SMbRTXqW5W4RXJR+gLwXqSiwbEZpnE HUs2IYKGYp4LHoDPV3XJsy2Z+lNOm+hjLoO8gTmWeGGl1El1gaVEhqV0puummgGflgxs 4TZQ== 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=uE7BVd7xcPKLZRsczojhybtDEmGjhl7rgwJI2roaFPQ0a0eS3l5XorRaqDfojmtC1t PpdyH86qDUVKYy0CRcpzFBaiBLp4PXUH/YuXoMSzvVTuJzXQLBP8vWFCV/wRg8rZru0M mgRSI30TZrEeeR3UzFapXsYaj0EU1QkXLPCS5zzspS+eDifvftASH1TxamtSd/7uG6/r B7uLb/Irg5A9FbeO66jvow7SIMCDY9ZTPG1KKb31bPLm0UQnFeJH42k1HA3s2bQZ9Vsi Az71cK75W5rLMVSi+a1iTXne9TYMWlhAgLtIjqV3C+s3rY7qF+jcOd3zcD8qP5xZqmlw cXOg== 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 n202si100873qkn.233.2019.06.20.11.32.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:24 -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-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 936EA7F769; Thu, 20 Jun 2019 18:32:11 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8358519C77; Thu, 20 Jun 2019 18:32:04 +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 v3 2/6] drivers/base/memory: Use "unsigned long" for block ids Date: Thu, 20 Jun 2019 20:31:35 +0200 Message-Id: <20190620183139.4352-3-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.27]); Thu, 20 Jun 2019 18:32:11 +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 18:31:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007653 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 355F2112C for ; Thu, 20 Jun 2019 18:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 289102866D for ; Thu, 20 Jun 2019 18:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C85A28751; Thu, 20 Jun 2019 18:32:20 +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 96DF32866D for ; Thu, 20 Jun 2019 18:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53E038E0001; Thu, 20 Jun 2019 14:32:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4E99F6B0007; Thu, 20 Jun 2019 14:32:16 -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 3D9D48E0002; Thu, 20 Jun 2019 14:32:16 -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 0FA168E0001 for ; Thu, 20 Jun 2019 14:32:16 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id e39so4796971qte.8 for ; Thu, 20 Jun 2019 11:32:16 -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=gfoXD074oqntlGsUqQLw/XjV/Fgy6SuYFhWXDd8wAbB2JFt4EixJyPLC2pUwJhndyz qodUS35n/HynBzwTqpYgp+UHbbPJZRZlM9fmfVtLSZm1LxQzKSW4d0W7FF8/oZxziCWd M8ME/uuDxfqVLTuamosrGIOFO0G9E3LgLpLz/lDZ/lG8SBcOwUD+GvX2PpLlCeHMMTkA /uAxrYHmLVZ767rGmJPV3h9nIWxGCOx95pVeOp8cO2QZ4mujhGrWEiPO/erUWABHnYG8 634kprjP+fVTop4iN78glzP7zPdl4/CHJHpxBpBi9x+6tPymzNk/nQ9fpQLBULPEvFSQ 14TA== 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: APjAAAWxlrbJtDlrJaUzgYdEC+d6ypHhF1cy/tQcvAqp3rqTTBYf8H6H +WOipvrdnbz/GDTanndyYjdso+QWDKF58P3QkJkgF+5BCgzmq4ory2bjlkehnmg1jkSWB9CVElm 58IskLOgPulSg/JSNyz56F63b1Jt/6L0PIzcQhFTFXWOcfr63/O6sg5ENkrgI5LtMpA== X-Received: by 2002:a0c:876e:: with SMTP id 43mr7875471qvi.61.1561055535818; Thu, 20 Jun 2019 11:32:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfqIBQxi5Z2IySHgJawDOW41ftQEvnw69oPQE2s5FAD3GBtSNhBC3Y/V7HJdwy53Vx8e4I X-Received: by 2002:a0c:876e:: with SMTP id 43mr7875385qvi.61.1561055534843; Thu, 20 Jun 2019 11:32:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055534; cv=none; d=google.com; s=arc-20160816; b=IQXfAv00GUr0VlYn0/6UAXCWyP9v6KT5JSh8sEHaXKLQuhb0S8yA71Q5MPf870fQPL UOWksavuVZTHw2RGCEHsOQPadYpPkTelbkaoY0aJjdwFu+nSAYqSssiKr0Z/pxvA21G7 GLM7BS7mwJo4Dp2zPapTtO1ZlSVxJzYhSe+Ou4kPvJ+3gAVBB7BQYSGvxMUl/LmFmwEy NckdDIidqu/1rlhlln2pv6zf6diNjBHlKajpjIbFPRAgNURCIxzq3GlfUdn/jflqNj3k l36IU5tq3ceH37STBVph3GG3dxXwP3//jREhTIxY8uYLo7MDjfZq/EdGBepKTGZM9xVV ZCQQ== 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=GCX2DpkBCwfu6b51l3o0e7roudZJKaXrn8AWFV0RNZZ/fBVm/tNTwKtgKn8IojbqR+ FkInE74nOJBQsU4nAOBJZwrm/FJ5of3X50+SWO9Q6hF5Z/g09oVXWYu/N3DBygqEVJCa /7YtYqDd+PRxzPgkedOpSnsGZczx740QaBtAvcoCiGhBHpZBfeobUe6/BqioazQp636t 6BIF6bjUcObqLoKuUmD9zgdfwOPX6e93MWrhdHr9UiiKHrJcVhRW1mksIcbL4xpXfReS IdkXQB7h021ElAGsD5ASUQvAV/f4DoJ+xC+c8SMh6gFvLGh0t6L5t86uIt+sP+B7/UA/ 4ZVg== 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 a190si94909qke.379.2019.06.20.11.32.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:14 -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-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 1785475726; Thu, 20 Jun 2019 18:32:14 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id E49CA19C5B; Thu, 20 Jun 2019 18:32:11 +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 v3 3/6] mm: Make register_mem_sect_under_node() static Date: Thu, 20 Jun 2019 20:31:36 +0200 Message-Id: <20190620183139.4352-4-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.25]); Thu, 20 Jun 2019 18:32:14 +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 18:31:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007665 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 6D84A76 for ; Thu, 20 Jun 2019 18:32:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DBF7271CB for ; Thu, 20 Jun 2019 18:32:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51A83286A2; Thu, 20 Jun 2019 18:32:38 +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 02881271CB for ; Thu, 20 Jun 2019 18:32:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 930738E0002; Thu, 20 Jun 2019 14:32:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 907A66B000C; Thu, 20 Jun 2019 14:32:33 -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 7D07D8E0002; Thu, 20 Jun 2019 14:32:33 -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 57C836B000A for ; Thu, 20 Jun 2019 14:32:33 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id p43so4742652qtk.23 for ; Thu, 20 Jun 2019 11:32:33 -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=hI0lNVwwZKmUhvAdqmL17Q/r4/G2LX+gRy1OJvW2mlk=; b=QqQOuyXLJv1uxbGAwcrfPRyfJDdOXbVoM1bw2OIJG08OYNSaHiqsMd8MiK8WJdUyac XXeR6pcjoQAbdg/yvdHaR6ahuK825pW9nsfxjDjuBYIiNlUv4hh/aTaG9M5TX4MmXotC ZO/Yw+j9bpI7Dqq6oopG9bDcd4cAxvwuH0Tt3Xcc0brdgXVDF+cFZzgx+eK8McrjrJvJ 5K0x4aFGyNRnJJenwNyHxzCxZAG2NfdJf5zXJi72ZoimrMDDnBepZ7WeAqi07kO/RZ8u 9Z0D3LncRt+q01bevWL5rQpbTKRCDZxCUacFV4wq/qmuOC5SABAFjR2jEqUqd0J/H3WO TW9Q== 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: APjAAAUwOHPqjLYMj4TnnqdRZZ4HDbp3rvKhJQdN/lmsEbfqyj8SrCPY DLNMnv9HhBTqnEQ/fzsBESeeRNZpeumFjgV8BBnnO/HCgba8BKSKUskhEujJdUvxJjIj9CXnZmB SfV9EoBZyhrIhyoTOU3GCEIAfVFgFlO4XeFphODw+171dVErP0LX23q052jxvWXrIOw== X-Received: by 2002:ac8:394b:: with SMTP id t11mr92216053qtb.286.1561055553099; Thu, 20 Jun 2019 11:32:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjg1q9tNW0rxftntAQNv5Got7f42DUhtJyoRE3oNO1cn78fC9rFbjSuIriPWUPGNqe38nd X-Received: by 2002:ac8:394b:: with SMTP id t11mr92215953qtb.286.1561055551920; Thu, 20 Jun 2019 11:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055551; cv=none; d=google.com; s=arc-20160816; b=v9kCLyBvE2OzhPVoJMVayXq8xAcC14+uh5CmbHo5w5hCl6QdIOhs6c0bHwqhuxScSo k3lrcd2UBNw2i+Xy6fI+EfKQ3QwkG3FkeC80uhM6yZigRhQcvcTG0lF6VmoH5QHSQGrn XOBVmf58AAmL1+XXCpUcxE4yN33dkNygSiChjtCQFye3hzKsPC7phvIrJIY1RXJHggii zJzsTwDcO1/F7GNz/gX834LfOWWkH6RvQ3KokfXoxlvAS13eY0Jhq7EPbCckq3p7iyRd XBjEtPv4cdBHLKZwNg5E7JdQmjMYhYtDqwhRKSPDLSm2J6KQpebGaPgcrE+t/LZyj7UT j1Hg== 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=hI0lNVwwZKmUhvAdqmL17Q/r4/G2LX+gRy1OJvW2mlk=; b=ZL/WTUBkfDrMYRzw0BRfZLZDI8X4bbtFJKvWOJ3BVX2zylkNvPa5oF73+TE6umoORX DCrpeFYRlS1Eh8JDKP1oAsKz53fsSBykFKCRd+QX9Gxg3LL0O5etH48NU63e8bQcBZ7m t356/VgkXwL3b8D9mySust8oFDMgzU0+5zdroB0nHsE+1VwjX36ETUZsh/Z6dn4Mqq+a +peKKVtyhFwHX+KvRgE74tFGhPkAkb80jYw61OnblX2Cnc4M9E98qnm5GSijZll7I/sb aTARQrHma/pTVXcKWmwTkK47j8yXi46WnLIgdoCtKd3nRXXqDguP1zsK/CFQtaze+94U GrWw== 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 5si277111qtr.262.2019.06.20.11.32.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:31 -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-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 E0902223877; Thu, 20 Jun 2019 18:32:20 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D79219C5B; Thu, 20 Jun 2019 18:32:14 +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 v3 4/6] mm/memory_hotplug: Rename walk_memory_range() and pass start+size instead of pfns Date: Thu, 20 Jun 2019 20:31:37 +0200 Message-Id: <20190620183139.4352-5-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.39]); Thu, 20 Jun 2019 18:32:26 +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 | 23 +++++++++++----------- 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(+), 41 deletions(-) diff --git a/arch/powerpc/platforms/powernv/memtrace.c b/arch/powerpc/platforms/powernv/memtrace.c index 5e53c1392d3b..eb2e75dac369 100644 --- a/arch/powerpc/platforms/powernv/memtrace.c +++ b/arch/powerpc/platforms/powernv/memtrace.c @@ -70,23 +70,23 @@ 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) { - u64 end_pfn = start_pfn + nr_pages - 1; + const unsigned long start = PFN_PHYS(start_pfn); + const unsigned long size = PFN_PHYS(nr_pages); - 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 +242,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 18:31:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007661 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 7B17814BB for ; Thu, 20 Jun 2019 18:32:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D6DD271CB for ; Thu, 20 Jun 2019 18:32:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6017C286A2; Thu, 20 Jun 2019 18:32:35 +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 85213271CB for ; Thu, 20 Jun 2019 18:32:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C5406B0008; Thu, 20 Jun 2019 14:32:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 49B828E0003; Thu, 20 Jun 2019 14:32:33 -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 389C38E0002; Thu, 20 Jun 2019 14:32:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 150376B0008 for ; Thu, 20 Jun 2019 14:32:33 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id n190so4818492qkd.5 for ; Thu, 20 Jun 2019 11:32:33 -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=jtbm2N7gIiTCg5Pw8Try/e9q98Xgi5VBj39gd069GoT7e6L2NgBo1POyt+munqfoFC ozBL6yui5brYP0M4UbGnjZdtdvTSQPy/2Rd6/ys8UGgWzrIgKvVGVBxK4UrqVHe1+hJ0 DjV0/bO5DGe2q76SWtOKTdGIBUKRisxW0k/HpqkPcWKjW0K7zZJjVhi96aw57KkKwDUR b6C9KP0LJsf2KhGWUr8/tw/+jWG/8coLCj5jFOu2fP2uMkStdfSnQ6jBX0yGUAd3Puwy +N9oWR4aNP2UCPPHv1tcyIMQhDUao4q4xPMDAzCbddQxQffbGPBXO9fNguVn3ACCnHjL DoXA== 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: APjAAAX+ErGuDUGIM262fyGZjU9M1JPEtboEwobSKD4VHQjTD1CYS2V8 7CZif/JtVVt8jozqjZ3mrtfHMwWMNkRkXtyUUCVrPS9dKUZVdAHXjSp33EwyuSSG8itamLHPpBZ 8EI/P0njStb4t9lJ9+JlqMC1WYLjkIctwa7flzl+Pj7mW1H/HKUv2C9Dnq1kq7muHXg== X-Received: by 2002:ae9:e887:: with SMTP id a129mr13284393qkg.347.1561055552823; Thu, 20 Jun 2019 11:32:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfR6iW1TkylbJeQoyDaByD8/3egF9lbtWXrBLTaDlcCy9OtJ5meMO17e4xi7d1yuGy8scM X-Received: by 2002:ae9:e887:: with SMTP id a129mr13284308qkg.347.1561055551829; Thu, 20 Jun 2019 11:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055551; cv=none; d=google.com; s=arc-20160816; b=wD6iyXGZzvt238aWDhgolwkFduqEDGcpWQLs5Hz97iWtZWaTYhata2H92QyT5dbVCJ SAt0OwNA3JZuJlF+tq+oInO7mU3l/9jXIbadbLsFu5LxXR6rdFVp6p/khREpQF+ZnzVq gVJBVdsw2p+n2vgstodsWRN03OkJowuKUf/8ZhYfdtKYSLWSPmnAejzzFtdfAbwiTtQq t/GjxmcPPm5SoqL3JB0EQQPRjRtrtSB4q97ZbBMeT8uhbgtid5xvYdaq8Z6D05q/oqXe wkxtk0as0sgwfriAih+jATx3efS1Rua5BEtXWVatmT6s45kgdCrjZKmWhh3X2Gg131LD iCdQ== 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=dUre4+fWpbiOMlzHyu98bZPyFQ0JPPq/KmlHEtf4uZIV2/Ua8Rg7T2aWzn/quBmyki DFNNyJk42WCOcZbGBjEEGjQr0j25/YFaGWB2pQ0ViwBNnblaZgkFcKB71qchv4zVovXu uciJEge16yf+k3DbLRildaHlI8aKaLLxws5eqo6qKQI6XiPWW4JEnqWWIiVgAuaRIQaU Fl6/3JfRLgIK6BUhmoNKqimBTTUt23i54GF4j1pOJNyqabKdwM6DsvVs2WUmsSb4FpFg FlfIN02mrjSiOeS0Vjhwz44pb4ABEBYNY1JQYe1dYUqUs68ONSOtHzuogNIcoq7n57Dk U68Q== 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 l28si260041qtc.376.2019.06.20.11.32.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:31 -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-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 A07DD3092667; Thu, 20 Jun 2019 18:32:25 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FEDF19C4F; Thu, 20 Jun 2019 18:32:21 +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 v3 5/6] mm/memory_hotplug: Move and simplify walk_memory_blocks() Date: Thu, 20 Jun 2019 20:31:38 +0200 Message-Id: <20190620183139.4352-6-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.43]); Thu, 20 Jun 2019 18:32:26 +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 18:31:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 11007669 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 A1AEC112C for ; Thu, 20 Jun 2019 18:32:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 956AD271CB for ; Thu, 20 Jun 2019 18:32:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89583286A2; Thu, 20 Jun 2019 18:32:40 +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 F0D7E271CB for ; Thu, 20 Jun 2019 18:32:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5AF5F8E0003; Thu, 20 Jun 2019 14:32:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 587836B000C; Thu, 20 Jun 2019 14:32:38 -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 474878E0003; Thu, 20 Jun 2019 14:32:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 21EA56B000A for ; Thu, 20 Jun 2019 14:32:38 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id q26so4842770qtr.3 for ; Thu, 20 Jun 2019 11:32:38 -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=Ua/1L85XXvxNpLU3txbB6eYF1WAK8cUWmLRonh+Cr9s=; b=RRkVkVZAyIEIPj3btc4gYGHxMhl1hGzwDTvS57Fv/SJXbTY++e38Ztw2zuSz6eJ7tO 7iivTr/8UYYPUmrt6IxNOzGeT4tknDwqJcY8k7wO0ohRz14Ud5aB7sQpe68jE7pqRFo9 O72ZV3jKc2g/6PZLng9zlp5pAtW9nk1xb/NDIkQjUx/GMGo8lnv/87RSX716aOM0/Gny 6EJQgUK1rb/wKM0fdtDKm6ZraBhqYvajbJ31izjuNLmC7tDtBccqGtSYA3puy3VDtBPk mN6B3lWbwNJnWa3qVa8CbxoLtF4eOpb5RofhACon+cKAeBTi32oeEjjmOdGgnRHW8kbJ ZWaA== 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: APjAAAWJqSTJGeifiQWdg7RnrRyMpx7ikQbosszBjKjKUool6bFEDSps a6x/sRDhuDnpVCwx1mIgwBszDsjRtFw5ukTQXHav/iaf2RA95RNg2Z4tmXXTdC9gVL3sQNG0+tR lgqLxaBsyf1+69XEdLag/JszqKvL2bEjV0QP5uXs6cMTTscyVTYAqiQAXoabjoP6wDQ== X-Received: by 2002:aed:24f4:: with SMTP id u49mr109457059qtc.8.1561055557904; Thu, 20 Jun 2019 11:32:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVLVHj5MSs8xAjdg29ZO0PGtyqH+cYNHDziU/7+Iu+0khRKTVo/o/OWa2BW+f7kNoylp4Q X-Received: by 2002:aed:24f4:: with SMTP id u49mr109456977qtc.8.1561055556824; Thu, 20 Jun 2019 11:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561055556; cv=none; d=google.com; s=arc-20160816; b=mE3NBE9PFBfggxf2KX8h/gXyVwfVGCCnejYu0nUhiXgDqKa4WJ2b4LtjFskJYUCPrY 8ACv3uuYzy9qzH7eys2pewrmtNI19pyU4gm+bJIz0DRM3cypGK0n8xFjTN90+2YHHNi3 2XX1jxpqcW3AjseAtEvvhjLmWjFFAoOw/XPwFfN06ezCl/k0Ut6NfwfQQeO7GYEb6C2N zNz9a8Hw68AA9NN1uE44eLVLJfXxCTaM02X/uR2q5kzK9diwrdehrcs5MwbpxirfWxI0 nf1dXYpbjt8wH6X1cW6Nuq4hvQ2sAtl2rl4Xa5pwt6JF3KiOMAxBBTAdRNh3X0Lv03Ir jXsA== 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=Ua/1L85XXvxNpLU3txbB6eYF1WAK8cUWmLRonh+Cr9s=; b=vtKOw+P4Ayx7b6woOInnxo3wC42QeqVr1rQPoDi55eRzMThHfe4SZintFeaR5MmfcV 7NwlEli0iN0rvPAUyVzwQc3LctAJr6wsZap1+wy9JmlVa1sHZvNDprKqRuWctHXJwNJT fSuLOFQ76YIG0ZoCdK4guD0YU8Paiz75UyStIp2vszlpInMAItdgGRrcfEIpbyFlvRL8 +a1rY9hvG7PoEUh4h7ue6JygTF0qaZjraCdTp8fQ5MoMwCkZ1W9XnuFVENfgTzX70Li3 bdQfjz1ohJMBj94eSgp4ZIUl7sjmnVATgUR3rUq7+WnDEXCn73BgbBJcuPYdKjWJnum3 806A== 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 p54si249823qtc.371.2019.06.20.11.32.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 11:32:36 -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-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 CFED74E90E; Thu, 20 Jun 2019 18:32:31 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-71.ams2.redhat.com [10.36.116.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFF9419722; Thu, 20 Jun 2019 18:32:25 +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 v3 6/6] drivers/base/memory.c: Get rid of find_memory_block_hinted() Date: Thu, 20 Jun 2019 20:31:39 +0200 Message-Id: <20190620183139.4352-7-david@redhat.com> In-Reply-To: <20190620183139.4352-1-david@redhat.com> References: <20190620183139.4352-1-david@redhat.com> MIME-Version: 1.0 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.38]); Thu, 20 Jun 2019 18:32:32 +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 | 37 +++++++++++-------------------------- include/linux/memory.h | 2 -- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 0204384b4d1d..195dbcb8e8a8 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -588,30 +588,13 @@ int __weak arch_get_memory_phys_device(unsigned long start_pfn) return 0; } -/* - * 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) +/* A reference for the returned memory block device is acquired. */ +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 +607,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 +660,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 +740,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 +767,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 +867,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,