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=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 46B79C2BA80 for ; Tue, 7 Apr 2020 13:58:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E4C72074F for ; Tue, 7 Apr 2020 13:58:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E4C72074F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 81DE28E002D; Tue, 7 Apr 2020 09:58:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D03B8E002A; Tue, 7 Apr 2020 09:58:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70D088E002D; Tue, 7 Apr 2020 09:58:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id 593D98E002A for ; Tue, 7 Apr 2020 09:58:57 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0C6FF181AEF39 for ; Tue, 7 Apr 2020 13:58:57 +0000 (UTC) X-FDA: 76681215114.03.cord04_885323425374e X-HE-Tag: cord04_885323425374e X-Filterd-Recvd-Size: 6410 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Apr 2020 13:58:56 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id y44so458849wrd.13 for ; Tue, 07 Apr 2020 06:58:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7oMqieg8pNA5U1Gqo/zdJwJNHWJR141xdDvdPejtqTI=; b=LThr417Ar0QyLtNwMLQeFlUmmBIGqVF+zVjfKWxp1Qr4x+p/aWTND1iYclsrdoSl0S EzCBiQoCUu+XD1fDe4lVwgTDq5vNRj/UwxrgKORAOJ1H+Qk+hLfiIZR4MWPOMgE82iKB 6RAgMeL7H+MV+v3QGjOslqq1vunEMs6a42aTVj2OHC75bR17jji6ebhUVuxs/TsnE08I xSJbOf1O/TnEppqoNuGMgFhrep8LZsabLZjUpUs1OfWgk8oMS5DiwOHR5kkV9TpP1dn5 dal/p4q4iWY7jhCWaXCOGGBWBc6hbj8+5rVqH1YwqV3/UJewo06GfhMkaM7ILRW8RuGg 5h9Q== X-Gm-Message-State: AGi0PuYo0sFdD++jDR5iT4gGhS6sbiWXXiGnTU0Kb8NHMiqDphkLGgze Dd8rVIRtrwr4HJvgqeG6X5I= X-Google-Smtp-Source: APiQypIdi/9iwz570aPHnT8xTis1j6JkFOGqdxShbVn1+GBG3wNO5p8MwoE4Mp2kP0hFvEiBaR1e7w== X-Received: by 2002:adf:bbc5:: with SMTP id z5mr2992228wrg.168.1586267935643; Tue, 07 Apr 2020 06:58:55 -0700 (PDT) Received: from localhost (ip-37-188-180-223.eurotel.cz. [37.188.180.223]) by smtp.gmail.com with ESMTPSA id v186sm2357359wme.24.2020.04.07.06.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 06:58:54 -0700 (PDT) Date: Tue, 7 Apr 2020 15:58:53 +0200 From: Michal Hocko To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Nathan Fontenot , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Andrew Morton , Oscar Salvador , Baoquan He , Wei Yang Subject: Re: [PATCH v1 1/2] powerpc/pseries/hotplug-memory: stop checking is_mem_section_removable() Message-ID: <20200407135853.GQ18914@dhcp22.suse.cz> References: <20200407135416.24093-1-david@redhat.com> <20200407135416.24093-2-david@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200407135416.24093-2-david@redhat.com> 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 Tue 07-04-20 15:54:15, David Hildenbrand wrote: > In commit 53cdc1cb29e8 ("drivers/base/memory.c: indicate all memory > blocks as removable"), the user space interface to compute whether a memory > block can be offlined (exposed via > /sys/devices/system/memory/memoryX/removable) has effectively been > deprecated. We want to remove the leftovers of the kernel implementation. > > When offlining a memory block (mm/memory_hotplug.c:__offline_pages()), > we'll start by: > 1. Testing if it contains any holes, and reject if so > 2. Testing if pages belong to different zones, and reject if so > 3. Isolating the page range, checking if it contains any unmovable pages > > Using is_mem_section_removable() before trying to offline is not only racy, > it can easily result in false positives/negatives. Let's stop manually > checking is_mem_section_removable(), and let device_offline() handle it > completely instead. We can remove the racy is_mem_section_removable() > implementation next. > > We now take more locks (e.g., memory hotplug lock when offlining and the > zone lock when isolating), but maybe we should optimize that > implementation instead if this ever becomes a real problem (after all, > memory unplug is already an expensive operation). We started using > is_mem_section_removable() in commit 51925fb3c5c9 ("powerpc/pseries: > Implement memory hotplug remove in the kernel"), with the initial > hotremove support of lmbs. I am not familiar with this code but it makes sense to make it sync with the global behavior. > Cc: Nathan Fontenot > Cc: Michael Ellerman > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michal Hocko > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Baoquan He > Cc: Wei Yang > Signed-off-by: David Hildenbrand > --- > .../platforms/pseries/hotplug-memory.c | 26 +++---------------- > 1 file changed, 3 insertions(+), 23 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/hotplug-memory.c b/arch/powerpc/platforms/pseries/hotplug-memory.c > index b2cde1732301..5ace2f9a277e 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-memory.c > +++ b/arch/powerpc/platforms/pseries/hotplug-memory.c > @@ -337,39 +337,19 @@ static int pseries_remove_mem_node(struct device_node *np) > > static bool lmb_is_removable(struct drmem_lmb *lmb) > { > - int i, scns_per_block; > - bool rc = true; > - unsigned long pfn, block_sz; > - u64 phys_addr; > - > if (!(lmb->flags & DRCONF_MEM_ASSIGNED)) > return false; > > - block_sz = memory_block_size_bytes(); > - scns_per_block = block_sz / MIN_MEMORY_BLOCK_SIZE; > - phys_addr = lmb->base_addr; > - > #ifdef CONFIG_FA_DUMP > /* > * Don't hot-remove memory that falls in fadump boot memory area > * and memory that is reserved for capturing old kernel memory. > */ > - if (is_fadump_memory_area(phys_addr, block_sz)) > + if (is_fadump_memory_area(lmb->base_addr, memory_block_size_bytes())) > return false; > #endif > - > - for (i = 0; i < scns_per_block; i++) { > - pfn = PFN_DOWN(phys_addr); > - if (!pfn_in_present_section(pfn)) { > - phys_addr += MIN_MEMORY_BLOCK_SIZE; > - continue; > - } > - > - rc = rc && is_mem_section_removable(pfn, PAGES_PER_SECTION); > - phys_addr += MIN_MEMORY_BLOCK_SIZE; > - } > - > - return rc; > + /* device_offline() will determine if we can actually remove this lmb */ > + return true; > } > > static int dlpar_add_lmb(struct drmem_lmb *); > -- > 2.25.1 -- Michal Hocko SUSE Labs