From patchwork Wed Jul 17 09:07:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 11047497 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 63630112C for ; Wed, 17 Jul 2019 09:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5253328702 for ; Wed, 17 Jul 2019 09:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 462A528714; Wed, 17 Jul 2019 09:07: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 CF3D728702 for ; Wed, 17 Jul 2019 09:07:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4D726B0003; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BB1506B0008; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) 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 A88AD8E0001; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id 5C6F46B0005 for ; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id y24so17623392edb.1 for ; Wed, 17 Jul 2019 02:07:31 -0700 (PDT) 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; bh=Bti46f+Y06Sv2tAwUIdnw52o5JPz/p0dtD24RrvbZvE=; b=dnt7yg+RsjaYlwrO4qdARhrkVr/6F69KIi0+16v1wdPQZFXSwtR9tH/4E+qPjVHcar loUfEklHwPAu0shV/uTrPpDFfNgASWimB2YOLx0HxEbG4XnzhC/rSQI4V1x9FHSUcBi1 WKKLeTD38kEmYke4/0qc0tN2aOKjr9JfAQ5NviaxuhqnCa8EUtaL7kTWsqRfz6R5Jziv 6ql6U0bE+IeUiaaLwvVoR1YnRwlrwZ/Pqjqz+ygKzag+DMSum9Ud3rHBhxTRLk0aFU35 8JqVKniCqwLkHadDL+A5aZXsSyL+gny3BSjpAuVrLXReF1i/umZGTzxm0zZ5kLm+qnIc hiZA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Gm-Message-State: APjAAAU5K9Kg+jsS+/IijxlA9FXzJ8qQVssFH2HqEr4uG5MltiHIvfUm JnDUPU2IYgJXMK8vxZ+l0NyTSNAevkTt2nNaSsVJrgze6T4vu7P1IjfwSqKwCax0zAjWqYK1mNG VHhmz8L1FUUsPSf/7eamJNtHgSUDLIo6LnrnDox4zyziQvchConj5s/q3Diasmzq/MQ== X-Received: by 2002:a50:aed6:: with SMTP id f22mr33956504edd.59.1563354450947; Wed, 17 Jul 2019 02:07:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSDyzJAL+k9FCzp5ZKimUDNU3Y6Gw+fPzx6QkD9DwokBK5nw5G3KHu4scO0NW6NmiVnDJf X-Received: by 2002:a50:aed6:: with SMTP id f22mr33956448edd.59.1563354450014; Wed, 17 Jul 2019 02:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563354450; cv=none; d=google.com; s=arc-20160816; b=MNdqdVreh0ik7nayW9zTr2iDh3piXH9irk8jvpSI+Yaot8Kj9o/ufDpOzab9wQSO86 fLLWV8x9drfKBcvHKOVrT9WKVPR+ttjFMtvFY6KifumwDoOWkdmmbJhwqp3oDiUGpiMc 9hjNzbVzq68qD5vyzrTVQoydBtyxLeakHKB3SeVsqz5/mB2nJMp4S3Kquwg4HJZRdOYh m94IhmAcM8q4pXFCD+yOzMN1tUKjK7noEhw7CT/1iLMDXGeR/cR7fpidygC1mVymYNNC 4ngVQorqq8HcbXwOycO6EWOYuPYRGE//2VZkLH7MVQrfpCcruDyNiSv/k7su2Dj3rOrF 6g6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=Bti46f+Y06Sv2tAwUIdnw52o5JPz/p0dtD24RrvbZvE=; b=QFp4xiqm1yI95IfcV5sM3K/xHCstjnKA3giMT+BEgOd7GYrM3y5i2N4zp+KWieBxQz 70l/9l0106NKK4gIfuCsrtYKP59SNQi3M53A6/AgEk+Envj+hXYnQA7M+UsgJWluSTeX nEtgCv2fqSNuY8iOtRF463EZT9uL3W2j/hl8ohuVlcp+Yy3zZIrS65s+Vv4zQ//U7WHt kVJLK7yuEb9zO6ka5PPY51zJsGLPrHHx6sX/3zbUY+YUXpOBnwcTquHNxbZbM+t7pdr/ Mv13JM9p8FeICISJEom/fAx2WTHNTiZXKgVAhNPtPdK+CZSeVpbWjkmvelTRXIfraT7i 7Raw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id m55si14317651edm.55.2019.07.17.02.07.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 02:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 62F82AF40; Wed, 17 Jul 2019 09:07:29 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: dan.j.williams@intel.com, david@redhat.com, pasha.tatashin@soleen.com, mhocko@suse.com, aneesh.kumar@linux.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 1/2] mm,sparse: Fix deactivate_section for early sections Date: Wed, 17 Jul 2019 11:07:24 +0200 Message-Id: <20190717090725.23618-2-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20190717090725.23618-1-osalvador@suse.de> References: <20190717090725.23618-1-osalvador@suse.de> 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 deactivate_section checks whether a section is early or not in order to either call free_map_bootmem() or depopulate_section_memmap(). Being the former for sections added at boot time, and the latter for sections hotplugged. The problem is that we zero section_mem_map, so the last early_section() will always report false and the section will not be removed. Fix this checking whether a section is early or not at function entry. Fixes: mmotm ("mm/sparsemem: Support sub-section hotplug") Signed-off-by: Oscar Salvador Reviewed-by: Aneesh Kumar K.V Reviewed-by: Dan Williams --- mm/sparse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 3267c4001c6d..1e224149aab6 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -738,6 +738,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, DECLARE_BITMAP(map, SUBSECTIONS_PER_SECTION) = { 0 }; DECLARE_BITMAP(tmp, SUBSECTIONS_PER_SECTION) = { 0 }; struct mem_section *ms = __pfn_to_section(pfn); + bool section_is_early = early_section(ms); struct page *memmap = NULL; unsigned long *subsection_map = ms->usage ? &ms->usage->subsection_map[0] : NULL; @@ -772,7 +773,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, if (bitmap_empty(subsection_map, SUBSECTIONS_PER_SECTION)) { unsigned long section_nr = pfn_to_section_nr(pfn); - if (!early_section(ms)) { + if (!section_is_early) { kfree(ms->usage); ms->usage = NULL; } @@ -780,7 +781,7 @@ static void section_deactivate(unsigned long pfn, unsigned long nr_pages, ms->section_mem_map = sparse_encode_mem_map(NULL, section_nr); } - if (early_section(ms) && memmap) + if (section_is_early && memmap) free_map_bootmem(memmap); else depopulate_section_memmap(pfn, nr_pages, altmap); From patchwork Wed Jul 17 09:07:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 11047499 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 C49056C5 for ; Wed, 17 Jul 2019 09:07:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B334A28702 for ; Wed, 17 Jul 2019 09:07:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7B0E28714; Wed, 17 Jul 2019 09:07:37 +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 4671128702 for ; Wed, 17 Jul 2019 09:07:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02B0F6B0005; Wed, 17 Jul 2019 05:07:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E6FED6B000A; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) 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 C4AD58E0001; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 736836B0003 for ; Wed, 17 Jul 2019 05:07:31 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id f19so17597328edv.16 for ; Wed, 17 Jul 2019 02:07:31 -0700 (PDT) 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; bh=m4HIcYVa3ra0WJB1AuQ2/08UF86bylQj4T0ONjGQM1g=; b=Go6qJZeFRJz3WqLnvhqp2NAheu4bJqwDzJxSa0ym1I5RnkOAtyuLd6aX7sV39rRH+4 pYxBfDOiKC1+PCvg9VSfm41VuIlVbE5FN7YkI7E3AOkOmCxo1c6ehVbMFa/9CVldUoTH K7sXjg5LRgmsbR6fPd5noboBuuPmU/f2p7T3TzSXIdgyHvBHYeR+xsjRNIxhnbZ8ihRd e4aWBXOUPfV7G6wYWFk+3/TGk6UUbv3KpO36cK3hYZ5RHDoArgdaapxsDNTH0Os7I+T3 cEVxm9I4xMu8p1pBAEPsPe5z9O4UF31zE2dZMFr4mrSEP4uag9oy7j/rJlLPSj24Vp2K tb6Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Gm-Message-State: APjAAAVJsEoHyudec4P9ked2hL44CMiRPq8ouZFCiD3/FuBGD2dWeSkw oYL/wE5/C3oh24K8zEzg8QHnfrOQIumLt3TasbmYfddGapLjFp1hu0zVfHZfdZb94i0b/z4AqEo quLMo+swGO7hfWXXK45ED6e4nSJb8kyxKJGzmYnRWFGhydak86rod/pjkKfMgnHPoEQ== X-Received: by 2002:a17:906:e91:: with SMTP id p17mr30254537ejf.217.1563354451055; Wed, 17 Jul 2019 02:07:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJcs/m1Zgd3rxKRo7/7hPN0wJcJzjafE57mDtspggsON/Xvh7gIf47MzmSMCXzR1kpkNEV X-Received: by 2002:a17:906:e91:: with SMTP id p17mr30254475ejf.217.1563354450301; Wed, 17 Jul 2019 02:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563354450; cv=none; d=google.com; s=arc-20160816; b=e2fltTj+XqKECKj1dmq+UU8NKYIAHY3oQymy8XPsaQGrSdMyXozgZiEUlmWjSFHluQ mf7s/j/qFrOPebTBJRJhcwQ26e9Il/gKC7W64Imbn1by5O6lc7MA7Ssaau/dhozJKrjP EjOknu+ESGk2yChERUZsFeDCkl0rKo9y4FYs0Rfn9zuo6smOcUp/l0Jl3z6FBCp6PD43 07p7UdW8LELkjqUALtaoF7ymHOMmQFFRzD0T83v/STcADI+FkVTTm8DAwh+0vl6hiMWn jZ0KmVSpZMrWwvvnWo2ced20b5Be68j4oZz0kWEaPXKWtDLynBldTfGAKCs4uMfFnv4s A1Iw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=m4HIcYVa3ra0WJB1AuQ2/08UF86bylQj4T0ONjGQM1g=; b=DZuaPupn+tlThYssEXJYuXvziIpTKxjZ4fqpG7Jf/A2rH7/hIcf8DbSsimeFRoxxrX FMr3eozc81/3T/3tnCTpYixP8Nc7YolW7bN2LUwUIXBMLN26qWJUJ6kiGj4D4UE8+aQo zmplOViJKcjTeRypmOCGl2IGPuW2WCzt8KOb/CM1eeJBSL0OYswKFwknxxEpLjUH91dk 99TF9gindj2nIDkkDIbev+ZmX8B8s4qX885KqfmnKwxbLf8FAQSMjVOxcdxlzVzIaCa9 eQjBSQ3d2qzaVLunwh3RDXtnrdsQSN5PlAwODRYddeWNaW6pgCAwu57rJYdPCxCign2D 833g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id c14si11516746ejz.208.2019.07.17.02.07.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 02:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.220.15 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EBF48AF57; Wed, 17 Jul 2019 09:07:29 +0000 (UTC) From: Oscar Salvador To: akpm@linux-foundation.org Cc: dan.j.williams@intel.com, david@redhat.com, pasha.tatashin@soleen.com, mhocko@suse.com, aneesh.kumar@linux.ibm.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [PATCH v2 2/2] mm,memory_hotplug: Fix shrink_{zone,node}_span Date: Wed, 17 Jul 2019 11:07:25 +0200 Message-Id: <20190717090725.23618-3-osalvador@suse.de> X-Mailer: git-send-email 2.13.7 In-Reply-To: <20190717090725.23618-1-osalvador@suse.de> References: <20190717090725.23618-1-osalvador@suse.de> 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 Since [1], shrink_{zone,node}_span work on PAGES_PER_SUBSECTION granularity. We need to adapt the loop that checks whether a zone/node contains only holes, and skip the whole range to be removed. Otherwise, since sub-sections belonging to the range to be removed have not yet been deactivated, pfn_valid() will return true on those and we will be left with a wrong accounting of spanned_pages, both for the zone and the node. Fixes: mmotm ("mm/hotplug: prepare shrink_{zone, pgdat}_span for sub-section removal") Signed-off-by: Oscar Salvador Reviewed-by: Dan Williams --- mm/memory_hotplug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index b9ba5b85f9f7..2a9bbddb0e55 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -422,8 +422,8 @@ static void shrink_zone_span(struct zone *zone, unsigned long start_pfn, if (page_zone(pfn_to_page(pfn)) != zone) continue; - /* If the section is current section, it continues the loop */ - if (start_pfn == pfn) + /* Skip range to be removed */ + if (pfn >= start_pfn && pfn < end_pfn) continue; /* If we find valid section, we have nothing to do */ @@ -487,8 +487,8 @@ static void shrink_pgdat_span(struct pglist_data *pgdat, if (pfn_to_nid(pfn) != nid) continue; - /* If the section is current section, it continues the loop */ - if (start_pfn == pfn) + /* Skip range to be removed */ + if (pfn >= start_pfn && pfn < end_pfn) continue; /* If we find valid section, we have nothing to do */