Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp969625ybl; Wed, 14 Aug 2019 08:42:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBseaCmOo8TCreRCnSgichZhibcMvc/RzMAJat4zUEp0IqQw06UPKyA8eJyitTAZRDiDfT X-Received: by 2002:aa7:914e:: with SMTP id 14mr593822pfi.136.1565797374447; Wed, 14 Aug 2019 08:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565797374; cv=none; d=google.com; s=arc-20160816; b=AoR3kd+4qwPtMhHVj6q084Vvi4GprKkVRr5K0POCGtAczdQcIqQBFAuhXhfcxhOO5s GzQHmcCP0yb85Kfopi4tlkSLY4s1AVYHphGXehLcHbWvU+Xn9VLkPy54M1G2LPEbEEpd 449AxlucnwxOOzfQ1efKCqkx9bDYTApRXsnwD5D7oapsHOsrwhaYQIudbNZzqVSM4Vbj BWsoVOE3+Na0cvxrsoFoFeLwdD5b70rGmH9RwWgR0+hvwW9K9cQ75NZ3CP4ubrQcSSlC mLGhWe6HOP8A1gdE6rQwKYXtLvizbAtOEfUuwyMCMRHPQdd/FFXUU7hfA0F6L50JAb9T KgcA== 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=7+HmX8nCHRIJLi+Fw8akk4mHpa0fNI2yNYpF0tlT718=; b=VBOqJyBPSyqOhl8mtduGpKLrMOC9C0308/UUaF65fIwQXDsvmt00A7EL4qjc7kIz8W Jwv6EzJq/iJngfz5lS7laa1HAQueFvHVEMBr96yelrZd1M9C4TJcxAdVmGWSF3b0bXH1 TwZwKdbfGEumfciu9RpPTPx7cUiZD2JA2rP3n18DunpD+vIzJoGFtStPYQWTxu6C3kGG IDFa/EXXM7e7jal1Y7ciADeEGhFjepfFocrYKCrh3S7fnNxUzXeXRYZaCshMESyyEdxR ucsbR/ezBSJwqm/8Xkdry/8p0GSSQmO+LeqgRDw1qkCjWmKRqhC1M1vUuR9MZ5e5PhGk /vDg== 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 d63si126924pld.139.2019.08.14.08.42.37; Wed, 14 Aug 2019 08:42:54 -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 S1728219AbfHNPl0 (ORCPT + 99 others); Wed, 14 Aug 2019 11:41:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59718 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728152AbfHNPlY (ORCPT ); Wed, 14 Aug 2019 11:41:24 -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 788F88E592; Wed, 14 Aug 2019 15:41:24 +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 A234E80693; Wed, 14 Aug 2019 15:41:22 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, David Hildenbrand , Arun KS , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Dan Williams Subject: [PATCH v2 4/5] mm/memory_hotplug: Make sure the pfn is aligned to the order when onlining Date: Wed, 14 Aug 2019 17:41:08 +0200 Message-Id: <20190814154109.3448-5-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.28]); Wed, 14 Aug 2019 15:41:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit a9cd410a3d29 ("mm/page_alloc.c: memory hotplug: free pages as higher order") assumed that any PFN we get via memory resources is aligned to to MAX_ORDER - 1, I am not convinced that is always true. Let's play safe, check the alignment and fallback to single pages. Cc: Arun KS Cc: Andrew Morton Cc: Oscar Salvador Cc: Michal Hocko Cc: Pavel Tatashin Cc: Dan Williams Signed-off-by: David Hildenbrand --- mm/memory_hotplug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 63b1775f7cf8..f245fb50ba7f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -646,6 +646,9 @@ static int online_pages_range(unsigned long start_pfn, unsigned long nr_pages, */ for (pfn = start_pfn; pfn < end_pfn; pfn += 1ul << order) { order = min(MAX_ORDER - 1, get_order(PFN_PHYS(end_pfn - pfn))); + /* __free_pages_core() wants pfns to be aligned to the order */ + if (unlikely(!IS_ALIGNED(pfn, 1ul << order))) + order = 0; (*online_page_callback)(pfn_to_page(pfn), order); } -- 2.21.0