Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp171340ybb; Tue, 7 Apr 2020 19:49:10 -0700 (PDT) X-Google-Smtp-Source: APiQypIl7PvHHpQSeTc6tnzEy+RJUPLZdxg7H7JuJyLvdOcS9D8lLZuACE359Rlf+JhvSNHbAa7F X-Received: by 2002:aca:f07:: with SMTP id 7mr906134oip.68.1586314150594; Tue, 07 Apr 2020 19:49:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586314150; cv=none; d=google.com; s=arc-20160816; b=fEnXtviF5gX8nh4Rme2mx4iohhPK9B08BtP1vTbrqSXu8CssiE9dxuq/I4k7jwpdJy FvVXs+Gz380Y/J2rVgcwwgVQBiL6KfdwprYGgmMEx7iHb9fsCN7F9Ut7s5MVQx8bMlam AyxRza7584qEP/R4Gb+Ezjjo63d10Ig34HzPNzMzp1eHboFqokVzcwwLa3IxeuoqV53K ip9TS+OHkeCE6w54v6GAEWrSWxPh/PpLDyidGqSxOpmG0gqxIGH/FkIcAcWF3Sk4VziP xV0vEFOLreaPkkHTXerUFkKifdTxRd4V1lU9AvfETd5nfBfazA2jzEbY8SYHBbEzbalV 6E3A== 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:dkim-signature; bh=t7WtQTqpQRwbXCbBXBwtx+Gjb6wbq7lij7qXduh5wW4=; b=QjwcPcwGAVSJL6y13x7R+8Al/bGjxOMKLu9WbMxRbr1EmVY9ZzvrStPtJYlo9yh2mh 7fP7k33WtPKxZyoZBgQ/G8iWuh9eGIgTOrojeKnYNJbc+Z+SRP0TzUM/QpxmJkrzcfu1 07L0bnkEGed99qsNmBZxJWT9q+UZJkTwwyEUIQVH8DYTdZ8AgxpAyd2Yq6A/junizBWK vaKVQZIcM+AVdYdaCRpJh/QzGyqMQ0ke+XkXxLqXlyDbKUf1L0p7PhCU28gIERIc/4Mq UWNz7HKh+N/eXwqfOsIbjHAWiWFINgsB5SEtemGnrWhbGFiQ/a7922VP9e+hWFEpnQPx b44g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c4+cAEb/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3si2044626otc.58.2020.04.07.19.48.55; Tue, 07 Apr 2020 19:49:10 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="c4+cAEb/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726475AbgDHCqn (ORCPT + 99 others); Tue, 7 Apr 2020 22:46:43 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:32396 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726416AbgDHCqn (ORCPT ); Tue, 7 Apr 2020 22:46:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1586314002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t7WtQTqpQRwbXCbBXBwtx+Gjb6wbq7lij7qXduh5wW4=; b=c4+cAEb/eRAIpHwG5pMZFXkUjZ8JQRaqBSKtPTYY28pBhl83HV3ctQJrJfG/hAdAs3qWsf a3R5oKpL5ZnSm8YvOarl8PXgy/ypLP6TY5eiF6w37RAmODbkWZp5K+Os1BuqBn705b1TpD mwGfGbHm3SpKzy1bSPCK32Az5MjEDc8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-8QLOYcr_Mtmnyo-dByffww-1; Tue, 07 Apr 2020 22:46:39 -0400 X-MC-Unique: 8QLOYcr_Mtmnyo-dByffww-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BF628017F3; Wed, 8 Apr 2020 02:46:37 +0000 (UTC) Received: from localhost (ovpn-13-77.pek2.redhat.com [10.72.13.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 281CA60BFB; Wed, 8 Apr 2020 02:46:33 +0000 (UTC) Date: Wed, 8 Apr 2020 10:46:30 +0800 From: Baoquan He To: David Hildenbrand , piliu@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, Nathan Fontenot , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Michal Hocko , Andrew Morton , Oscar Salvador , Wei Yang Subject: Re: [PATCH v1 1/2] powerpc/pseries/hotplug-memory: stop checking is_mem_section_removable() Message-ID: <20200408024630.GQ2402@MiWiFi-R3L-srv> 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> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add Pingfan to CC since he usually handles ppc related bugs for RHEL. On 04/07/20 at 03:54pm, 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. Pingfan, can you have a look at this change on PPC? Please feel free to give comments if any concern, or offer ack if it's OK to you. > > 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. > > 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 >