Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4407101ybb; Tue, 7 Apr 2020 06:59:58 -0700 (PDT) X-Google-Smtp-Source: APiQypKrc07vhLJbWjza7wJh7zhB+QeKf7SMHrRdqiosn5KMDCeBok7i5A1ZNKEYz6vnVzltsG2h X-Received: by 2002:a05:6830:146:: with SMTP id j6mr1642804otp.352.1586267997906; Tue, 07 Apr 2020 06:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586267997; cv=none; d=google.com; s=arc-20160816; b=j7WSB+lVM7XOEnWqWW1FYt8yS9RKwMj/87Id31jlYyHXhddkP/uyD4KJnG6Ed5+/58 uCWeQwkK4Eb/TKy8s6x3S3v5V/mgSv3z0oZXZEszv5nXL9DsjGhvat0ENxZVXhupt/n8 ATFialnFlTVglR68pAP4umWjwBE1tKtSvwEGkSUqmZgq8+gKNw+zpIwqLu6fIC46vkcZ MjxtQS0Ssh8h6zv2HdmDtfxHOZRnxnk3nv/zBmQkshyXGbkbO2ahu7uVWCEFimjhx+IE fOwi+61FRFoPKST9YY2FdvpLwFvR8pH78lATY3FXAtTt2wPKG5TVrSXSgbeaB4k+PpXK 7pFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=7oMqieg8pNA5U1Gqo/zdJwJNHWJR141xdDvdPejtqTI=; b=ufL1JZCCQOj5gLihYbLc0+pP+4XHj+HYjuGPGa/Bw6VTW3BEGdSLeX16mvdpcSfj3m xiflg2QOXFbDO9mWJKVikwJ6ROy5JQBXRzJer07/IN6KenAuyEYotobjMmgz1BM6Q096 BiYqPqfb8BnsoVbglNdsF8upsSFDBby5Pkp6aeg65UdFl4Lends0U/FNCAVOgOgCFoWy w/5D9n95YEcRbcDd91Wz9WoBz8JgsXvrTxbwdes4PiMc0ld+2RcnKcovyKv8luXZAFoM dQ4HN8zx3c3ykMvvnzATVIKrST9bUd3iEe52gtBPasTIzIAMLLMC6+RiLizshmWJwqGN d1vA== 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 9si692028oip.112.2020.04.07.06.59.45; Tue, 07 Apr 2020 06:59:57 -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 S1728861AbgDGN67 (ORCPT + 99 others); Tue, 7 Apr 2020 09:58:59 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43039 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728573AbgDGN67 (ORCPT ); Tue, 7 Apr 2020 09:58:59 -0400 Received: by mail-wr1-f66.google.com with SMTP id w15so3993755wrv.10 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=b4su2Sw+PKa3q4vSvSRGFjpf72kXH1D3IlZmGQIL6U9jMNvviqxohwJiPO8ZDji01u WLjgCGk/fSXkNWEnzPNwjS77xx73vHj3OwtHpbR0+izLOAf7E+sDzPaT9+RgVpXrFjT/ Ut7WHOMNAdIsfCT1+oUliZmJNhx3d5xDslX0/Wj8mbHtDDrUc8HfHDl5uIpTN+k3B01G E3+7zt6YxMauV+S088j/RHwAnLFaGVf4IMhkrFPjXX7Nfn28RVjWMBCe0N7OKE2Kb28e tb6X+k99hlzYHIB8cl5qtETibgdQTQ9M8EOWDyMkBkCc+t3tAT9RNgAio7cHAgVNRo3t tHvw== X-Gm-Message-State: AGi0Pub5qyQCtDIscGQDivE8JoV86g8fmeF1BtOi7E+MLvp6gFswOl30 1Tr/kPsRgRYmrqkqXexeNi8= 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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