Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp970252ybl; Wed, 14 Aug 2019 08:43:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOAPfySfyOnKEhC8pTU8Be7Ec5nRNLJobJGHc9y8/3dCGz+XiAuom4mzK75Xr4dzCQtOmB X-Received: by 2002:a62:d0:: with SMTP id 199mr550643pfa.157.1565797409992; Wed, 14 Aug 2019 08:43:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565797409; cv=none; d=google.com; s=arc-20160816; b=zUyKflvVVg/2lI6dvtIJcoK/n09zma7GjjMNcITLYwDSVAKB1uDTjqNGpPzMAYfRRY St0JEt6XWQrOPXIamItz7Kw99qFjvv1/MX1o4Da2zN7ZBhxeu6+5TgPSNcbqPF7+JXnE RGZNsW4EAG6OS+frU4SZ+s7xM94OBzL/gQN9Qp+9t4SsFLyT2k5OEfZx3KAmUas4zbRp St+hvq/EV5jFBjTFWlOFMnKOAb7ftKfILqHr8e0LoFfT/flVthkx45PyBdHJS0cyK2/f iCi4pYvT9LOzSGzX/0cDCK6Zv4oXGMaxIOzOHf1hkd5O61uogYCX9AH0QxmDm77LblVj vSqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3QniSsnB/5H99t6tPA/aqi8Yj7OoA5F5TDM7NWhIF54=; b=cgJnAdz/LtMSTRTSM/jnJ/WW6VHFDt4pq/19cCkolBeTLrnOX/p+zPKMSu2u3dBlVs KEmwyzqeVDJvd/7yy29Mg3MiYrr7iUKTP/BpRSTcnI/Fv4UKBXO1KOk25CtBcPdpqJQt fUjXB2vHBIHG1ckrE16yBn+Vlnv4oufKZcTTVLpwPwqbwOcdkj6zA4utwO26pIdzRO0J ltaSFhqMC61NMTKv7nh75XrYMU5dMAvjqNW87NFoEC4n5lYlD8oeFR14sbUxscxRUt5f Zv+xsr7x9w8vljJRsvvq8q1R8eCfRfN7L04+t4XNmLNDS67Q2TooLKmIorGc1UABna6H ZrXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18si56418918pfa.23.2019.08.14.08.43.14; Wed, 14 Aug 2019 08:43:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727875AbfHNPlV (ORCPT + 99 others); Wed, 14 Aug 2019 11:41:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55132 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726230AbfHNPlS (ORCPT ); Wed, 14 Aug 2019 11:41:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5221351F00; Wed, 14 Aug 2019 15:41:18 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id D540F8069C; Wed, 14 Aug 2019 15:41:15 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Dan Williams , Borislav Petkov , Andrew Morton , Bjorn Helgaas , Ingo Molnar , Dave Hansen , Nadav Amit , Wei Yang , Oscar Salvador , Michal Hocko Subject: [PATCH v2 1/5] resource: Use PFN_UP / PFN_DOWN in walk_system_ram_range() Date: Wed, 14 Aug 2019 17:41:05 +0200 Message-Id: <20190814154109.3448-2-david@redhat.com> In-Reply-To: <20190814154109.3448-1-david@redhat.com> References: <20190814154109.3448-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 14 Aug 2019 15:41:18 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This makes it clearer that we will never call func() with duplicate PFNs in case we have multiple sub-page memory resources. All unaligned parts of PFNs are completely discarded. Cc: Dan Williams Cc: Borislav Petkov Cc: Andrew Morton Cc: Bjorn Helgaas Cc: Ingo Molnar Cc: Dave Hansen Cc: Nadav Amit Cc: Wei Yang Cc: Oscar Salvador Acked-by: Michal Hocko Signed-off-by: David Hildenbrand --- kernel/resource.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 7ea4306503c5..88ee39fa9103 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -487,8 +487,8 @@ int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, while (start < end && !find_next_iomem_res(start, end, flags, IORES_DESC_NONE, false, &res)) { - pfn = (res.start + PAGE_SIZE - 1) >> PAGE_SHIFT; - end_pfn = (res.end + 1) >> PAGE_SHIFT; + pfn = PFN_UP(res.start); + end_pfn = PFN_DOWN(res.end + 1); if (end_pfn > pfn) ret = (*func)(pfn, end_pfn - pfn, arg); if (ret) -- 2.21.0