Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4075413yba; Tue, 7 May 2019 11:40:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMeow4vEZj5Vf9Q7hs8yqICTepu5iuCKqjz07MTU4S9s5TJbC8kC5YPMBYQCyok+2Qz/Lh X-Received: by 2002:a17:902:7685:: with SMTP id m5mr13422483pll.330.1557254451615; Tue, 07 May 2019 11:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557254451; cv=none; d=google.com; s=arc-20160816; b=R71+uQH5jpBYO9rhrKGhvIBxuP3F9f2Kpyf7cSSjQWLvJIbBZog7ed832j+Lb+Zn8V z46GjWLROmytlP1kHNdrMD51Zgm39eCHHhh1nhHOXAjpzNMVQCsBCFreYFo77ER1Irjc p9CA0vKiGfARElEnmJkm1XBzaAZ9T/Ndv3whjWo3sO92MRIWTvM8IuTMTRMdspsp6WXX /Tn6twpHP2raif3EID4TYRZdbYW7RhK2lvSOpwid/I86UWGgSttCKEW61yoqXf/gRVm2 Ru7v714X3+GVuD06xm4bHco/T5cte8c7Ft5tBeUNPLx+W1Rq58W5tMGk/vgnrSXqCOWB oU3g== 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=X3Se80q1dKdim+vPqx/FPGIOapUfHtVIBKJDjYe8V8k=; b=yIifzEU+87JFfr/aldEvPD1HgHYMDkegD0WSLVWLwO8C5LrKQYklEdPo2eXazH7G7X kiGJu2+j+aa3hnrXX5UTf0if99nhizLZhvfT5FXRWzmeybLpkf9jRTMumDOT1DSBOAD1 XqWtlKONoTrDVAU5oNq6piCYd/+Y7TqlKbe24ee59trFAKsSPZXp6LI0N8CO/BrhbbSG 6GL+QPTOrbCgFivzC1MO4kxDR4YF9QmBuivAR310b+gwLVZOf1xK8BI6AoUgbHgpHLM2 /PJkYxW0XC4vFZH6l8QQs/EBR7/Ni5gD4j6ApKBjQDcEFCEIs4VgkcHYg+0NrgOYc/rP 9xbA== 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 b7si22088187plb.273.2019.05.07.11.40.35; Tue, 07 May 2019 11:40:51 -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 S1727634AbfEGSiY (ORCPT + 99 others); Tue, 7 May 2019 14:38:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43722 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726091AbfEGSiX (ORCPT ); Tue, 7 May 2019 14:38:23 -0400 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 5F73F83F3C; Tue, 7 May 2019 18:38:23 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-95.ams2.redhat.com [10.36.116.95]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B9301778E; Tue, 7 May 2019 18:38:20 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, akpm@linux-foundation.org, Dan Williams , David Hildenbrand , Oscar Salvador , Michal Hocko , Pavel Tatashin , Qian Cai , Wei Yang , Arun KS , Mathieu Malaterre Subject: [PATCH v2 1/8] mm/memory_hotplug: Simplify and fix check_hotplug_memory_range() Date: Tue, 7 May 2019 20:37:57 +0200 Message-Id: <20190507183804.5512-2-david@redhat.com> In-Reply-To: <20190507183804.5512-1-david@redhat.com> References: <20190507183804.5512-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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]); Tue, 07 May 2019 18:38:23 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org By converting start and size to page granularity, we actually ignore unaligned parts within a page instead of properly bailing out with an error. Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: David Hildenbrand Cc: Pavel Tatashin Cc: Qian Cai Cc: Wei Yang Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 328878b6799d..202febe88b58 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1050,16 +1050,11 @@ int try_online_node(int nid) static int check_hotplug_memory_range(u64 start, u64 size) { - unsigned long block_sz = memory_block_size_bytes(); - u64 block_nr_pages = block_sz >> PAGE_SHIFT; - u64 nr_pages = size >> PAGE_SHIFT; - u64 start_pfn = PFN_DOWN(start); - /* memory range must be block size aligned */ - if (!nr_pages || !IS_ALIGNED(start_pfn, block_nr_pages) || - !IS_ALIGNED(nr_pages, block_nr_pages)) { + if (!size || !IS_ALIGNED(start, memory_block_size_bytes()) || + !IS_ALIGNED(size, memory_block_size_bytes())) { pr_err("Block size [%#lx] unaligned hotplug range: start %#llx, size %#llx", - block_sz, start, size); + memory_block_size_bytes(), start, size); return -EINVAL; } -- 2.20.1