Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5150652pxj; Wed, 9 Jun 2021 10:15:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRNoezAfKoGG9ch4H0lbl8PQHP1E7Z9omvaBJDPCSNlmG2Pn7cYlq7mtfnpAjrkK2gntq3 X-Received: by 2002:a17:906:bcd5:: with SMTP id lw21mr880544ejb.346.1623258940057; Wed, 09 Jun 2021 10:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623258940; cv=none; d=google.com; s=arc-20160816; b=PcmEcLoZEplYWH0RPcplGebenJUGfKD/6bAxcWEY7vMQmd+POUN+RIjUI29z/XSCB6 aR2C8FQT/QoP1/X4XkcYJjwBI1/FOfnTd+FF0TnYoZ0w0+1H02D52Z5V0aS2ebibZGbC YlLa3hSgz/vze03QrZszLb8mIIJXf/Dktht5HGBcUmYGpv3ESXINTZl9eSvzJx7j1R/m eCcMQiTmXn92rRC8Q55h+uz44GSz+3N4CN4Agw3UgwuQmzBKVxi42hU+PbAfUsLg+BWH PJ3cu9OKu8OqmeRuwr+q1939mBae7/wCuWv0gW55A9HKYaOTKicrfX3R9wtNHXD8VH0Z lIWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :references:cc:to:from:subject:dkim-signature; bh=RHwERDV3Ik2w6kA7FU7L2RqGuM08Lzd2/FD6Wyr2HFk=; b=oDyzJyEUIGwU0nFmbAwy1bICMdX3J1LW63jL+WxX1w4Ykj2Em/eMYHkJXHc1S/0ozo WSAa908kg5DFRsW7PpeF2jU8tZ96i/8ciIJGy+wtNjtlRo7Sv2pPJrQA8xT7lWQXn7LM XHnMhwT7fOQ+5dVVCDT/kFMCJ/+3i3N/k5bvohtNARmnmnCC6O7c+6c4QaRp2cMYORfo vOUzEeotpmETW6VQdmNre4XkqeSlS4xQrDgN6Stj/yXR5TGV560ClHy45sgnA28R/Rq+ dmlcqPsrNDLmj2aLJYdmx1FxagDuYeueNm+u1wCyLd13GyfzQnwrKvkdeA8Yl/eqDwjc 6Haw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JZURtaSr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p3si335779ejy.228.2021.06.09.10.15.15; Wed, 09 Jun 2021 10:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JZURtaSr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235927AbhFIKHC (ORCPT + 99 others); Wed, 9 Jun 2021 06:07:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25661 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235914AbhFIKHB (ORCPT ); Wed, 9 Jun 2021 06:07:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623233106; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RHwERDV3Ik2w6kA7FU7L2RqGuM08Lzd2/FD6Wyr2HFk=; b=JZURtaSroKXVbV9oEJA8odheSETiD/feGshvORh/TDtHTyw8jMe047+yeP7I6Yoph/WhUI Oop9ox6VYzzKURis3iGLztgTSf19wraJErJeLqUUAe2qwKKEJ7O6LsLI5lpBvA4LUWx4ra RTwpkcX0BR8AUm0a5CBuECDMG0WRNiQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-304-pBRbubnyPC-FcHbLHmcvDA-1; Wed, 09 Jun 2021 06:05:05 -0400 X-MC-Unique: pBRbubnyPC-FcHbLHmcvDA-1 Received: by mail-wr1-f72.google.com with SMTP id e11-20020a056000178bb0290119c11bd29eso5682138wrg.2 for ; Wed, 09 Jun 2021 03:05:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=RHwERDV3Ik2w6kA7FU7L2RqGuM08Lzd2/FD6Wyr2HFk=; b=COze2/B080f40MNm5/NI4rVogcZuEpGOE4htjKqm9L4MMQ4o9KBz31oSYBSTeqlIsK V90W1NkOPXkeBqmQs8ZAVyEVgUyjy/Q+ON7jS9A3zEgYAhrsLtSWETgnmHVDpFkfqKLy zTm+gpR/cRMa8hY2UoVUlm787CNgByVCIWTj2s3NLVldIZnpCw/i7qLkbgeTjIZGijqw +v5CVqpm6WC+GZ/6Y2y4JSQC1DRP6vHyRMcseeqSG2vxpiuIyH1/wxMAAh2TXYK9P47Q DMfpaBqyyvICQzFoBaqiKw58ZZ9iHjt8bmDUkOdbZ4VRmkZ5MA57kAzETryDFXaB3scu XDUA== X-Gm-Message-State: AOAM530CMB9rL9/66CGaAeOYJgzva89VOe56RApeJj/0bixiDIa6yCxF L3r0PcFXMpy9i7TGdV2UJL4WgLZf6n76KLNdYlN3u86HMI0I8KmPPT2ReVjW031onLGRYOUVnkt HlO03OlmAvySkXwZTEp1Iccvj X-Received: by 2002:adf:d4cc:: with SMTP id w12mr26997720wrk.216.1623233103831; Wed, 09 Jun 2021 03:05:03 -0700 (PDT) X-Received: by 2002:adf:d4cc:: with SMTP id w12mr26997662wrk.216.1623233103520; Wed, 09 Jun 2021 03:05:03 -0700 (PDT) Received: from [192.168.3.132] (p5b0c611d.dip0.t-ipconnect.de. [91.12.97.29]) by smtp.gmail.com with ESMTPSA id l31sm9209629wms.31.2021.06.09.03.05.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 09 Jun 2021 03:05:03 -0700 (PDT) Subject: Re: [PATCH v1 05/12] mm/memory_hotplug: remove nid parameter from remove_memory() and friends From: David Hildenbrand To: Michael Ellerman , linux-kernel@vger.kernel.org Cc: Andrew Morton , Vitaly Kuznetsov , "Michael S. Tsirkin" , Jason Wang , Marek Kedzierski , Hui Zhu , Pankaj Gupta , Wei Yang , Oscar Salvador , Michal Hocko , Dan Williams , Anshuman Khandual , Dave Hansen , Vlastimil Babka , Mike Rapoport , "Rafael J. Wysocki" , Len Brown , Pavel Tatashin , virtualization@lists.linux-foundation.org, linux-mm@kvack.org, linux-acpi@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Vishal Verma , Dave Jiang , Nathan Lynch , Laurent Dufour , "Aneesh Kumar K.V" , Scott Cheloha , Anton Blanchard , linuxppc-dev@lists.ozlabs.org, nvdimm@lists.linux.dev References: <20210607195430.48228-1-david@redhat.com> <20210607195430.48228-6-david@redhat.com> <87y2bkehky.fsf@mpe.ellerman.id.au> <7463b3ed-07d3-7157-629d-a85a3ff558d6@redhat.com> Organization: Red Hat Message-ID: Date: Wed, 9 Jun 2021 12:05:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <7463b3ed-07d3-7157-629d-a85a3ff558d6@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08.06.21 13:18, David Hildenbrand wrote: > On 08.06.21 13:11, Michael Ellerman wrote: >> David Hildenbrand writes: >>> There is only a single user remaining. We can simply try to offline all >>> online nodes - which is fast, because we usually span pages and can skip >>> such nodes right away. >> >> That makes me slightly nervous, because our big powerpc boxes tend to >> trip on these scaling issues before others. >> >> But the spanned pages check is just: >> >> void try_offline_node(int nid) >> { >> pg_data_t *pgdat = NODE_DATA(nid); >> ... >> if (pgdat->node_spanned_pages) >> return; >> >> So I guess that's pretty cheap, and it's only O(nodes), which should >> never get that big. > > Exactly. And if it does turn out to be a problem, we can walk all memory > blocks before removing them, collecting the nid(s). > I might just do the following on top: diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 61bff8f3bfb1..bbc26fdac364 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -2176,7 +2176,9 @@ int __ref offline_pages(unsigned long start_pfn, unsigned long nr_pages, static int check_memblock_offlined_cb(struct memory_block *mem, void *arg) { int ret = !is_memblock_offlined(mem); + int *nid = arg; + *nid = mem->nid; if (unlikely(ret)) { phys_addr_t beginpa, endpa; @@ -2271,10 +2273,10 @@ EXPORT_SYMBOL(try_offline_node); static int __ref try_remove_memory(u64 start, u64 size) { - int rc = 0, nid; struct vmem_altmap mhp_altmap = {}; struct vmem_altmap *altmap = NULL; unsigned long nr_vmemmap_pages; + int rc = 0, nid = NUMA_NO_NODE; BUG_ON(check_hotplug_memory_range(start, size)); @@ -2282,8 +2284,12 @@ static int __ref try_remove_memory(u64 start, u64 size) * All memory blocks must be offlined before removing memory. Check * whether all memory blocks in question are offline and return error * if this is not the case. + * + * While at it, determine the nid. Note that if we'd have mixed nodes, + * we'd only try to offline the last determined one -- which is good + * enough for the cases we care about. */ - rc = walk_memory_blocks(start, size, NULL, check_memblock_offlined_cb); + rc = walk_memory_blocks(start, size, &nid, check_memblock_offlined_cb); if (rc) return rc; @@ -2332,7 +2338,7 @@ static int __ref try_remove_memory(u64 start, u64 size) release_mem_region_adjustable(start, size); - for_each_online_node(nid) + if (nid != NUMA_NO_NODE) try_offline_node(nid); mem_hotplug_done(); -- Thanks, David / dhildenb