From patchwork Wed Jan 30 09:12:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10787945 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 0DA8713B5 for ; Wed, 30 Jan 2019 09:12:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E63A92E4B8 for ; Wed, 30 Jan 2019 09:12:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D82BB2E4E3; Wed, 30 Jan 2019 09:12:32 +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 6D3662E4B8 for ; Wed, 30 Jan 2019 09:12:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B89C68E0003; Wed, 30 Jan 2019 04:12:30 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A26C48E0001; Wed, 30 Jan 2019 04:12:30 -0500 (EST) 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 8C5D18E0003; Wed, 30 Jan 2019 04:12:30 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by kanga.kvack.org (Postfix) with ESMTP id 389BA8E0001 for ; Wed, 30 Jan 2019 04:12:30 -0500 (EST) Received: by mail-wr1-f71.google.com with SMTP id d11so8858762wrq.18 for ; Wed, 30 Jan 2019 01:12:30 -0800 (PST) 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=jqcIWXioD2gkdPhR+3oNYtx3Ld3P23Y8DhdWLsl2n/o=; b=ZsauuH/6Fbjy2UzqTLwqPtPQYDIYrssTQMp2IjbhVKhDXnaRjW/qPaDp2s3P2vPoU3 84r6aefkFna2ZhNNmK4dtOp1UOmk6gc5T0ezU2gsyipHM+9eR9XyyJ2I9fMSyD9Ff/qZ RmwoXT/D3Lh4KQjut4tWBgs9in4tbXdR/o/uO5izwQTvt6qi7j2OUE2AYpjr8Xw5TvhH ow/SgWkbNDA43FjaydJ+y9LQbi+F3LHLrmfXz8IZv43cbLxv4nEMXCh4Q0QT2Z56hQKK fN7K0gYZFSzgHmi+P35zEyCapRKmRjEDlPuq0I/QARdXz/nB2069EUTsGITTtpn+FVEV l0Gg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AHQUAuZStx9HNXgjOqqeWyLxJXcYYbNF2h3lpuLBhxlKEpDHlAegyj/C NWEaOnk/lnofFjp9XWh+MqkH8cGhzQSYkpZ+bnUucxHA0sPmW5a3Yb/4FcUOhBn3b1SXdVyDojh mSxTo6fQ8YGuLrehwRam/nGgRFsBst3Mtf29Guknri26OAsHBQG3TfsHuVVD8dciS+6TBmKmzN6 YyOiUC96F4gByV2ZWkiL9tqU7xCNHJ7NKrtPXg5PKXDbaq7L3gp8RUbyzhiwJVZ5G71TLPu3jNZ 5z6qkRAP7jufYkNRfigzuC7JlVIOQXbaL4ehtKvB2AEMzwedeDH6GmAud40TiGBvlE9xCRbxyn/ OZD0pjerpqwBkivSCextEXCt3srPiU8l4OL9inj92XX7h0wyv9eS4Q0vnzy3+NyYZqSKpD7RGg= = X-Received: by 2002:a1c:23cc:: with SMTP id j195mr13316066wmj.124.1548839549710; Wed, 30 Jan 2019 01:12:29 -0800 (PST) X-Received: by 2002:a1c:23cc:: with SMTP id j195mr13316010wmj.124.1548839548724; Wed, 30 Jan 2019 01:12:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548839548; cv=none; d=google.com; s=arc-20160816; b=g7zOT1nRi2oti0I6p4IuEXUTBrgo/eC665Q5WmkAqT7ieSzCLF4KpUodmfZJ/86a72 D4H1y6ORpSdf+AlNWQX+e2eLA3kjx4qljAljXq4058GYEHwV42plCdPTwAevWJgozUmn XFcaLu0IbxEz+ljPS9TTxXibBJdIuTQApPtPxPGwGhQxxmgHKJ2/EikkKK6VpR7dbXfC /311J6HkuZZGar/DBpEGCeqrrRjHDl0Qx8MYK1c/NPuXjbfsIQEiPPnYpqkS6w47qLeZ Q40L+BsU0eTYgLgbrFwitoJDmikVySUcHjLiZHykleoJD0aLoGk1uddmncaLaSmtbzow my1Q== 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=jqcIWXioD2gkdPhR+3oNYtx3Ld3P23Y8DhdWLsl2n/o=; b=FCwL8ZWis0nVMxXi9bxZjmUpT0h8sUqTui12Sp6OwaQA7ieF2AS8fWz8D1DqhwQ6tj LybMueOIVTOWLS9UJ0XoGpqeA7HhApEno585wTymQaPE/pSHw88VmAPOiMweKwvMHQNW teSxP09oerZUVsjWTUZo22kW4RWkSuyFFPaUjp7IJzIT8TtFVWXY8RXzjJHLNh3jZkgI VkjOeUZtMLP4OtKN7Dsta0F4pHNv8AZAY4ZGF6iqt/dN407NuLXwUH9oUVdeeJhnwFHi LtjReto4uIJdLC0JpqsppdDY9qf7Wn1LR/kVMIvR+iC0idtM3csf/MEReyBvy3pasVqP cPWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z13sor630353wrl.43.2019.01.30.01.12.28 for (Google Transport Security); Wed, 30 Jan 2019 01:12:28 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: ALg8bN4OLx4B36rgVZODDcO0K8ixVFRBva3FhUwiy8i7CxdLOfPVVkqSieNV7/xg/er1aWb+g0RmCA== X-Received: by 2002:adf:e7d0:: with SMTP id e16mr30650251wrn.142.1548839548346; Wed, 30 Jan 2019 01:12:28 -0800 (PST) Received: from tiehlicka.suse.cz (ip-37-188-142-190.eurotel.cz. [37.188.142.190]) by smtp.gmail.com with ESMTPSA id l19sm1491875wme.21.2019.01.30.01.12.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:12:27 -0800 (PST) From: Michal Hocko To: Mikhail Zaslonko , Mikhail Gavrilov Cc: Andrew Morton , Pavel Tatashin , schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, gerald.schaefer@de.ibm.com, , LKML , Michal Hocko , Oscar Salvador Subject: [PATCH v2 1/2] mm, memory_hotplug: is_mem_section_removable do not pass the end of a zone Date: Wed, 30 Jan 2019 10:12:16 +0100 Message-Id: <20190130091217.24467-2-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130091217.24467-1-mhocko@kernel.org> References: <20190130091217.24467-1-mhocko@kernel.org> MIME-Version: 1.0 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 From: Michal Hocko Mikhail has reported the following VM_BUG_ON triggered when reading sysfs removable state of a memory block: page:000003d08300c000 is uninitialized and poisoned page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p)) Call Trace: ([<000000000038596c>] is_mem_section_removable+0xb4/0x190) [<00000000008f12fa>] show_mem_removable+0x9a/0xd8 [<00000000008cf9c4>] dev_attr_show+0x34/0x70 [<0000000000463ad0>] sysfs_kf_seq_show+0xc8/0x148 [<00000000003e4194>] seq_read+0x204/0x480 [<00000000003b53ea>] __vfs_read+0x32/0x178 [<00000000003b55b2>] vfs_read+0x82/0x138 [<00000000003b5be2>] ksys_read+0x5a/0xb0 [<0000000000b86ba0>] system_call+0xdc/0x2d8 Last Breaking-Event-Address: [<000000000038596c>] is_mem_section_removable+0xb4/0x190 Kernel panic - not syncing: Fatal exception: panic_on_oops The reason is that the memory block spans the zone boundary and we are stumbling over an unitialized struct page. Fix this by enforcing zone range in is_mem_section_removable so that we never run away from a zone. Reported-by: Mikhail Zaslonko Debugged-by: Mikhail Zaslonko Tested-by: Gerald Schaefer Tested-by: Mikhail Gavrilov Reviewed-by: Oscar Salvador Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b9a667d36c55..07872789d778 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1233,7 +1233,8 @@ static bool is_pageblock_removable_nolock(struct page *page) bool is_mem_section_removable(unsigned long start_pfn, unsigned long nr_pages) { struct page *page = pfn_to_page(start_pfn); - struct page *end_page = page + nr_pages; + unsigned long end_pfn = min(start_pfn + nr_pages, zone_end_pfn(page_zone(page))); + struct page *end_page = pfn_to_page(end_pfn); /* Check the starting page of each pageblock within the range */ for (; page < end_page; page = next_active_pageblock(page)) { From patchwork Wed Jan 30 09:12:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 10787947 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 4CFF813B5 for ; Wed, 30 Jan 2019 09:12:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36BCB2E4B8 for ; Wed, 30 Jan 2019 09:12:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADEA2E4E3; Wed, 30 Jan 2019 09:12: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 B87ED2E4D1 for ; Wed, 30 Jan 2019 09:12:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 720AC8E0004; Wed, 30 Jan 2019 04:12:32 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 612C28E0001; Wed, 30 Jan 2019 04:12:32 -0500 (EST) 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 458948E0004; Wed, 30 Jan 2019 04:12:32 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by kanga.kvack.org (Postfix) with ESMTP id E6AA78E0001 for ; Wed, 30 Jan 2019 04:12:31 -0500 (EST) Received: by mail-wm1-f70.google.com with SMTP id g3so6819902wmf.1 for ; Wed, 30 Jan 2019 01:12:31 -0800 (PST) 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=IFyaSZDvG5tAIyjheJu+7MuaC7bK/awFyWok5SF8UwQ=; b=jaehZrd8nEK5GGucng0aJOAsmHy1NGCNUScii6I2UEQ7Xn8Wz3nSp0bJ6x5gjkEQmI C1r4RikNsDtv4ttloDMDiVIqxPgDEHTKp3Fh2BtraeMQ108o4/RQzUtkW+AX/4uMobxq /IT7yhWE9nWDfBCyG94kYnxFJcw80jt6JGkWzVipuSujRvWOZJih2m+IRYWvZwd8nURz Bxv5LyzT0X0TUGueOho6YSAOJqhIUCKVxe5BvHLy6kCkU7CTsLwBMaPn2pqDbx0ww9IU aXfe6T5QtE4k+u1PIKv0xe3bjxTGqH/fWhzHe00bBM9cb1Oo8UZQ90FN4u/p/tLWwnZD eQ/A== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Gm-Message-State: AJcUukdd4Q7chBSun/UMACL0GwXN/jO4HFAI3fuEHV2PLhlBOPxdTrqN +zPIfp1wJIx6moGl9auAE9h4Icmo3YDCkxUaoA1dd2POMqK4rdKDJZ0mQckLVxX9sMstiRwmxrN /fSIlR2I/r3bfi0jcJpFCmMa8+BKQkwWhJ9W07E/PtR41N3qAypz7Kt6V06hj5JXEtTURv5kV9d zrrGgZw8mqTAD6S9sJQWg7LlVeKbCaCQn6ZHskhuAy0bWRlUqob4/etgXn01wYEUs0823x+CA43 4gmmetkKGStlrIme1jwI694CFMPkOEgQJrmO9b0NibnOR9sUg6PlJXA56jglsZk32spqRsfwpU7 0bAtoW07HfcC04APEVvF2CahiRSX14oD/grN3ZGdon5t3TDW3kZTByHvBk3ec97UutFJp5uKFQ= = X-Received: by 2002:adf:9061:: with SMTP id h88mr29012139wrh.65.1548839551440; Wed, 30 Jan 2019 01:12:31 -0800 (PST) X-Received: by 2002:adf:9061:: with SMTP id h88mr29012074wrh.65.1548839550526; Wed, 30 Jan 2019 01:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548839550; cv=none; d=google.com; s=arc-20160816; b=DuuFJfjg726+9xHa7CeyB3+YNu9CWBDkPNOprS4bUa9CT4rZUrgyo6tL3sb0W9qqn3 U3nOkUbm6V6Hri2FgHpquRD2D7Y7AjhjKld1Nc1kLpMlZzZcKR+KZJphZ3b6uCzaMoqu bBTtBhh4SpzburDpHxJorAkpdFnbeRZ/UKYU7on4CyKFYBxJuP2QgpdgURbj9GCrLJLb fOnuUr/B56YLCyG0qFYzgaRGIOLU3mV4QxEN63jOKHc+nnS6IGeySN3P9E/WHIu0QqEe RO0CRYY9uBErBTSvwHNjwIOWiPOCTqtX2NCXkR1L0BjWVfLWDX4oyBMPn+K28P6y/v2L aKxw== 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=IFyaSZDvG5tAIyjheJu+7MuaC7bK/awFyWok5SF8UwQ=; b=JuQvkJpawRpuNNdzbrKdEsJlBZ+mmA7i4KT6O9+ZTh957UWHKcSPzxyjWvJk3LwPcl UAdeKXo/WtfRcuGzsz2n8338OCv4Csvaa9NkRuP7m7OQ3QZXXGq1ymyPMvXENl/BaOt3 nOVc++ebIu6E0pNR5uCbwCqmRaodP0bn+zZ9DAK7B5HFdxnp9PJ05GXB24R7XLKC/pau 9HJ6tFFChcQh+Ygfc2uoHCC/v6wllld+IfI1s4/3JzPg21ebEq3KAerkEj2yzN0MlMZ6 +/0p7PzGm4IHX9Z3KMLxC8NesX+6sJlImOdFK+bI05hSMGoBvk3JtqnVxuuL3iPCC2kR mkjQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r4sor910976wmr.10.2019.01.30.01.12.30 for (Google Transport Security); Wed, 30 Jan 2019 01:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of mstsxfx@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=mstsxfx@gmail.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Google-Smtp-Source: AHgI3Iaq8fWIDq9I86+HaQ9zHJ55J5mjfGRbhPSWjN7j9DPfqEzANX5rnBt5mnJftfFn161SONvHRQ== X-Received: by 2002:a1c:c1c9:: with SMTP id r192mr13492549wmf.146.1548839550147; Wed, 30 Jan 2019 01:12:30 -0800 (PST) Received: from tiehlicka.suse.cz (ip-37-188-142-190.eurotel.cz. [37.188.142.190]) by smtp.gmail.com with ESMTPSA id l19sm1491875wme.21.2019.01.30.01.12.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 01:12:29 -0800 (PST) From: Michal Hocko To: Mikhail Zaslonko , Mikhail Gavrilov Cc: Andrew Morton , Pavel Tatashin , schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, gerald.schaefer@de.ibm.com, , LKML , Oscar Salvador , Michal Hocko Subject: [PATCH v2 2/2] mm, memory_hotplug: test_pages_in_a_zone do not pass the end of zone Date: Wed, 30 Jan 2019 10:12:17 +0100 Message-Id: <20190130091217.24467-3-mhocko@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190130091217.24467-1-mhocko@kernel.org> References: <20190130091217.24467-1-mhocko@kernel.org> MIME-Version: 1.0 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 From: Mikhail Zaslonko If memory end is not aligned with the sparse memory section boundary, the mapping of such a section is only partly initialized. This may lead to VM_BUG_ON due to uninitialized struct pages access from test_pages_in_a_zone() function triggered by memory_hotplug sysfs handlers. Here are the the panic examples: CONFIG_DEBUG_VM_PGFLAGS=y kernel parameter mem=2050M -------------------------- page:000003d082008000 is uninitialized and poisoned page dumped because: VM_BUG_ON_PAGE(PagePoisoned(p)) Call Trace: ([<0000000000385b26>] test_pages_in_a_zone+0xde/0x160) [<00000000008f15c4>] show_valid_zones+0x5c/0x190 [<00000000008cf9c4>] dev_attr_show+0x34/0x70 [<0000000000463ad0>] sysfs_kf_seq_show+0xc8/0x148 [<00000000003e4194>] seq_read+0x204/0x480 [<00000000003b53ea>] __vfs_read+0x32/0x178 [<00000000003b55b2>] vfs_read+0x82/0x138 [<00000000003b5be2>] ksys_read+0x5a/0xb0 [<0000000000b86ba0>] system_call+0xdc/0x2d8 Last Breaking-Event-Address: [<0000000000385b26>] test_pages_in_a_zone+0xde/0x160 Kernel panic - not syncing: Fatal exception: panic_on_oops Fix this by checking whether the pfn to check is within the zone. [mhocko@suse.com: separated this change from http://lkml.kernel.org/r/20181105150401.97287-2-zaslonko@linux.ibm.com] Reviewed-by: Oscar Salvador Tested-by: Gerald Schaefer Tested-by: Mikhail Gavrilov Signed-off-by: Mikhail Zaslonko Signed-off-by: Michal Hocko --- mm/memory_hotplug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 07872789d778..7711d0e327b6 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1274,6 +1274,9 @@ int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn, i++; if (i == MAX_ORDER_NR_PAGES || pfn + i >= end_pfn) continue; + /* Check if we got outside of the zone */ + if (zone && !zone_spans_pfn(zone, pfn + i)) + return 0; page = pfn_to_page(pfn + i); if (zone && page_zone(page) != zone) return 0;