Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1293602ybi; Fri, 14 Jun 2019 12:01:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPXLRFEHjLKmRIxKsMvXgcUQ+ghK4FmRwERiuJqzZIZML3NJJmiWnQe8BEvaGe+GJe5L10 X-Received: by 2002:a17:90a:3787:: with SMTP id v7mr12647921pjb.33.1560538864911; Fri, 14 Jun 2019 12:01:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560538864; cv=none; d=google.com; s=arc-20160816; b=gRBDR2KHN40xiLBw2Ksjw89B3l6jsdR/Seho0iBEF4UAFFgxSClHFPv2PoJK5pyd3G Ob82aSIeArwgslJ5EN9OUcTL63h7xXdmFZlwu8EfMdidlT+pOOe/QWsYjraxdpsrReWt yacfCCCvyRM7Vu+21V4u9uRtRW5nG6RPpksP8TttphQgEC/pBV5ZyMXf3Fi9k89/mrRq fCa92Yh8QME5cUUa+aYYW0GRM+mp1nzmEnFkv2kAM+NDVS3utE3GUEBAkETUTkxL37Zk 3LqfT3RozIeF3stj+A+uF+dv45TZynDAbicnFyYgMNBUNfQjiXhDLnbi1VVevd9v2/eg ZfaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=42tVzP969KSuSvAVe/L566sbhyraQii/h1IwyWVNDUc=; b=Ye0QiH/RnB/2NBZNlk4aqluo7tCHKuWI1X66gBnmiJnrKWqI7GdfBoYxy+cBn/U+Or SqQwv89E14kKkgkr/y4giSKnjBqt1rrBNCnFoAPcvQt9Vr//ufK/8A0JX080eyPy3+j0 TZW4bUsnyg9g9enJfitKJR4oJGqkJju68xFU2i56MszW+Ztr3vDbgyNj4v5Lf1+Kjr9/ R+mwBZFFhCU+lMVir6a3OmS6w/nxHHGhMHh/booY2p06sKhTPO/oA+wTqfgIHA+wS4iG vLk0iUGysxJNdeIN/D5ktxrBMQE3+QnDHBKdVjiFaQyFKyWgi1cnu6b9saAGOkIVkhe4 jNqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vyoR8waO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f34si3046414plf.258.2019.06.14.12.00.48; Fri, 14 Jun 2019 12:01:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vyoR8waO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbfFNTAi (ORCPT + 99 others); Fri, 14 Jun 2019 15:00:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:47334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725802AbfFNTAi (ORCPT ); Fri, 14 Jun 2019 15:00:38 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C09DD21473; Fri, 14 Jun 2019 19:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560538837; bh=9luYIMc1miTz2FraniCesV9+ZaFoX/edSHhy+mT9JIY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vyoR8waOE1q5W/EKmFkQ9Obg/5StU3mMk8E+LGCQxdywY0BsyK2eX1sdrt42y9dRV wYeOCumqHytulVpdq9L/T+kBFZ7QQeib24BW3MLVlfdYP1kco4m9Vt74OTz/3IltiR zqJDvkwvBiUrUZcglCfj5SjZmdUbtzRIl2y26arw= Date: Fri, 14 Jun 2019 12:00:36 -0700 From: Andrew Morton To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, Dan Williams , linuxppc-dev@lists.ozlabs.org, linux-acpi@vger.kernel.org, linux-mm@kvack.org, 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: Re: [PATCH v1 1/6] mm: Section numbers use the type "unsigned long" Message-Id: <20190614120036.00ae392e3f210e7bc9ec6960@linux-foundation.org> In-Reply-To: <20190614100114.311-2-david@redhat.com> References: <20190614100114.311-1-david@redhat.com> <20190614100114.311-2-david@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Jun 2019 12:01:09 +0200 David Hildenbrand wrote: > 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. > > ... > > - int i, ret, section_count = 0; > + unsigned long i; > > ... > > - unsigned int i; > + unsigned long i; Maybe I did too much fortran back in the day, but I think the expectation is that a variable called "i" has type "int". This? s/unsigned long i/unsigned long section_nr/ --- a/drivers/base/memory.c~mm-section-numbers-use-the-type-unsigned-long-fix +++ a/drivers/base/memory.c @@ -131,17 +131,17 @@ static ssize_t phys_index_show(struct de static ssize_t removable_show(struct device *dev, struct device_attribute *attr, char *buf) { - unsigned long i, pfn; + unsigned long section_nr, pfn; int ret = 1; struct memory_block *mem = to_memory_block(dev); if (mem->state != MEM_ONLINE) goto out; - for (i = 0; i < sections_per_block; i++) { - if (!present_section_nr(mem->start_section_nr + i)) + for (section_nr = 0; section_nr < sections_per_block; section_nr++) { + if (!present_section_nr(mem->start_section_nr + section_nr)) continue; - pfn = section_nr_to_pfn(mem->start_section_nr + i); + pfn = section_nr_to_pfn(mem->start_section_nr + section_nr); ret &= is_mem_section_removable(pfn, PAGES_PER_SECTION); } @@ -695,12 +695,12 @@ static int add_memory_block(unsigned lon { int ret, section_count = 0; struct memory_block *mem; - unsigned long i; + unsigned long section_nr; - for (i = base_section_nr; - i < base_section_nr + sections_per_block; - i++) - if (present_section_nr(i)) + for (section_nr = base_section_nr; + section_nr < base_section_nr + sections_per_block; + section_nr++) + if (present_section_nr(section_nr)) section_count++; if (section_count == 0) @@ -823,7 +823,7 @@ static const struct attribute_group *mem */ int __init memory_dev_init(void) { - unsigned long i; + unsigned long section_nr; int ret; int err; unsigned long block_sz; @@ -840,9 +840,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 (section_nr = 0; section_nr <= __highest_present_section_nr; + section_nr += sections_per_block) { + err = add_memory_block(section_nr); if (!ret) ret = err; } _