Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp4048724imm; Mon, 30 Jul 2018 07:51:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdhSgWTcvYCSWfvBQgV+VR19Y3Oa4aWZjrP4IacHJmQUUtHcR1AlUpnS4rg3clMF/SqkpKc X-Received: by 2002:a63:4b5a:: with SMTP id k26-v6mr16177638pgl.384.1532962303071; Mon, 30 Jul 2018 07:51:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532962303; cv=none; d=google.com; s=arc-20160816; b=VN5bog45LNKE6q8T6qtmjHB17Cx3IUqUrKJrCFpCms7b+NeI4ml9bHcRJSWhYBoBYs fntDj2KDYsOQmvNulNfveQ6+OBzPbFAFcQJdsNH6thbByC//HxOnwXnKfXSVRecaovjW BZXQy+8mEGGebkxZcB+0DPe0amXSXrDcYb85UKuI9mmWDE7N8vWNaJam5Zjjr/ZC1g8z ZRrOi+gcLYNWICDdq+3WrOduxxSmvAkZFMPodt7qnRCh9XGFqzklbP7UhUix6xan/0hw xAoe+WtwS7/mzr8BLi7GtTrE+2jWrAhFb9YPJOPTws3Ki1LT2FIJP72kUJMZdhx+p/HR mcpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=8SkdL9WChoIUI7G2qvo2DhRcne42T2+MDBBqsfEJRbQ=; b=mXOTYq4F//vuxUqCf1sPYl7P59Ca7CWuafkB6hbF/2EYkNNSqLR0pPfzMpTlMh5zrW Y2TpNVnMUrdJ33OwgQRilObjcn9nnKpabGMUiuys0WdJdY5o0UKGF+VBnvS08fmFY2g/ +5q9j+c3y0BMQoErPqS5/O+lP+HcDMbYfJZIlj2K6psQ+MtS5Rxu1rcQaKglX+szxlxw t/4eZgCs70ZlUSN1eXrmPhfsBb9EXz2sTE0EeC6Ex09l66y7uc3RB9ooNf1Gh8NuW06k TYkGxFIJywjWOZBxJec29a4bNQPUIqG01FqCJ1rkqsx29QHdko4lIGHX5roU8MLt9yJb gKKw== 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13-v6si10791796pgh.642.2018.07.30.07.51.28; Mon, 30 Jul 2018 07:51:43 -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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731288AbeG3Q0B (ORCPT + 99 others); Mon, 30 Jul 2018 12:26:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:42676 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726911AbeG3Q0B (ORCPT ); Mon, 30 Jul 2018 12:26:01 -0400 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 E0E8DADEF; Mon, 30 Jul 2018 14:50:37 +0000 (UTC) Date: Mon, 30 Jul 2018 16:50:35 +0200 From: Michal Hocko To: David Hildenbrand Cc: Pavel Tatashin , Linux Memory Management List , LKML , gregkh@linuxfoundation.org, mingo@kernel.org, Andrew Morton , dan.j.williams@intel.com, jack@suse.cz, mawilcox@microsoft.com, jglisse@redhat.com, Souptick Joarder , kirill.shutemov@linux.intel.com, Vlastimil Babka , osalvador@techadventures.net, yasu.isimatu@gmail.com, malat@debian.org, Mel Gorman , iamjoonsoo.kim@lge.com Subject: Re: [PATCH v1] mm: inititalize struct pages when adding a section Message-ID: <20180730145035.GY24267@dhcp22.suse.cz> References: <20180727165454.27292-1-david@redhat.com> <20180730113029.GM24267@dhcp22.suse.cz> <6cc416e7-522c-a67e-2706-f37aadff084f@redhat.com> <20180730120529.GN24267@dhcp22.suse.cz> <7b58af7b-5187-2c76-b458-b0f49875a1fc@redhat.com> <56e97799-fbe1-9546-46ab-a9b8ee8794e0@redhat.com> <20180730141058.GV24267@dhcp22.suse.cz> <80641d1a-72fe-26b2-7927-98fcac5e5d71@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80641d1a-72fe-26b2-7927-98fcac5e5d71@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 30-07-18 16:42:27, David Hildenbrand wrote: > On 30.07.2018 16:10, Michal Hocko wrote: > > On Mon 30-07-18 15:51:45, David Hildenbrand wrote: > >> On 30.07.2018 15:30, Pavel Tatashin wrote: > > [...] > >>> Hi David, > >>> > >>> Have you figured out why we access struct pages during hot-unplug for > >>> offlined memory? Also, a panic trace would be useful in the patch. > >> > >> __remove_pages() needs a zone as of now (e.g. to recalculate if the zone > >> is contiguous). This zone is taken from the first page of memory to be > >> removed. If the struct pages are uninitialized that value is random and > >> we might even get an invalid zone. > >> > >> The zone is also used to locate pgdat. > >> > >> No stack trace available so far, I'm just reading the code and try to > >> understand how this whole memory hotplug/unplug machinery works. > > > > Yes this is a mess (evolution of the code called otherwise ;) [1]. > > So I guess I should not feel bad if I am having problems understanding > all the details? ;) > > > Functionality has been just added on top of not very well thought > > through bases. This is a nice example of it. We are trying to get a zone > > to 1) special case zone_device 2) recalculate zone state. The first > > shouldn't be really needed because we should simply rely on altmap. > > Whether it is used for zone device or not. 2) shouldn't be really needed > > if the section is offline and we can check that trivially. > > > > About 2, I am not sure if this is the case and that easy. To me it looks > more like remove_pages() fixes up things that should be done in > offline_pages(). Especially, if the same memory was onlined/offlined to > different zones we might be in trouble (looking at code on a very high > level view). Well, this might be possible. Hotplug remove path was on my todo list for a long time. I didn't get that far TBH. shrink_zone_span begs for some attention. > "if the section is offline and we can check that trivially" is not was > is being used here. It is "of the section was online and is now offline". yes. > Accessing a zone when removing memory sounds very wrong. offline_pages() > should cleanup everything that online_pages() did. > > Removing memory with pages that are still online should not be allowed. > And I think this is already enforced via check_memblock_offlined_cb(). yes. -- Michal Hocko SUSE Labs