From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5656FC433E1 for ; Wed, 19 Aug 2020 13:16:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 23C2E20738 for ; Wed, 19 Aug 2020 13:16:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23C2E20738 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C602C8D0037; Wed, 19 Aug 2020 09:16:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C107A8D0034; Wed, 19 Aug 2020 09:16:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B00288D0037; Wed, 19 Aug 2020 09:16:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0088.hostedemail.com [216.40.44.88]) by kanga.kvack.org (Postfix) with ESMTP id 99C328D0034 for ; Wed, 19 Aug 2020 09:16:22 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5994B364A for ; Wed, 19 Aug 2020 13:16:22 +0000 (UTC) X-FDA: 77167367004.01.swim26_5e12e0a27028 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 748E81004C79D for ; Wed, 19 Aug 2020 13:16:18 +0000 (UTC) X-HE-Tag: swim26_5e12e0a27028 X-Filterd-Recvd-Size: 3496 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Wed, 19 Aug 2020 13:16:17 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 43FAAAB9F; Wed, 19 Aug 2020 13:16:43 +0000 (UTC) Date: Wed, 19 Aug 2020 15:16:15 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Andrew Morton , Wei Yang , Baoquan He , Pankaj Gupta , Oscar Salvador , Charan Teja Reddy Subject: Re: [PATCH v1 11/11] mm/memory_hotplug: mark pageblocks MIGRATE_ISOLATE while onlining memory Message-ID: <20200819131615.GP5422@dhcp22.suse.cz> References: <20200819101157.12723-1-david@redhat.com> <20200819101157.12723-12-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200819101157.12723-12-david@redhat.com> X-Rspamd-Queue-Id: 748E81004C79D X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: On Wed 19-08-20 12:11:57, David Hildenbrand wrote: > Currently, it can happen that pages are allocated (and freed) via the buddy > before we finished basic memory onlining. > > For example, pages are exposed to the buddy and can be allocated before > we actually mark the sections online. Allocated pages could suddenly > fail pfn_to_online_page() checks. We had similar issues with pcp > handling, when pages are allocated+freed before we reach > zone_pcp_update() in online_pages() [1]. > > Instead, mark all pageblocks MIGRATE_ISOLATE, such that allocations are > impossible. Once done with the heavy lifting, use > undo_isolate_page_range() to move the pages to the MIGRATE_MOVABLE > freelist, marking them ready for allocation. Similar to offline_pages(), > we have to manually adjust zone->nr_isolate_pageblock. > > [1] https://lkml.kernel.org/r/1597150703-19003-1-git-send-email-charante@codeaurora.org > > Cc: Andrew Morton > Cc: Michal Hocko > Cc: Wei Yang > Cc: Baoquan He > Cc: Pankaj Gupta > Cc: Oscar Salvador > Cc: Charan Teja Reddy > Signed-off-by: David Hildenbrand Acked-by: Michal Hocko Yes this looks very sensible and we should have done that from the beginning. I just have one minor comment below > @@ -816,6 +816,14 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > if (ret) > goto failed_addition; > > + /* > + * Fixup the number of isolated pageblocks before marking the sections > + * onlining, such that undo_isolate_page_range() works correctly. > + */ > + spin_lock_irqsave(&zone->lock, flags); > + zone->nr_isolate_pageblock += nr_pages / pageblock_nr_pages; > + spin_unlock_irqrestore(&zone->lock, flags); > + I am not entirely happy about this. I am wondering whether it would make more sense to keep the counter in sync already in memmap_init_zone. Sure we add a branch to the boot time initialization - and it always fails there - but the code would be cleaner and we wouldn't have to do tricks like this in caller(s). -- Michal Hocko SUSE Labs