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=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 E71F4C433ED for ; Fri, 16 Apr 2021 11:07:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8FD0460238 for ; Fri, 16 Apr 2021 11:07:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8FD0460238 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3085B6B0070; Fri, 16 Apr 2021 07:07:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2919E6B0071; Fri, 16 Apr 2021 07:07:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E4DA6B0072; Fri, 16 Apr 2021 07:07:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id E00D46B0070 for ; Fri, 16 Apr 2021 07:07:11 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 99A1A1838A120 for ; Fri, 16 Apr 2021 11:07:11 +0000 (UTC) X-FDA: 78037953462.19.A66AF74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 0D087E000120 for ; Fri, 16 Apr 2021 11:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618571230; 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=GPi+c282xzGJKGtsxEXKiuYYzkH/n0b1SG5+hHDFjQY=; b=WgApvM0b40uNVlkMkytzWlVKqZkCa7LeGfcNxKOWsjkbehjB1lesGsIwj2U1TIU0b0pNy+ GXozk8SHxjd1lcjRoR5RjK3aNQh3vZmPJeL0QqwguodI7GcBFNuGBVCWwA8M1979p37ZoP KzCPl2Usgbz6ALKEoJGwLK0ISxdsqNE= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-536-DmcKO_v6OM-nXY6DsdX2pw-1; Fri, 16 Apr 2021 07:07:08 -0400 X-MC-Unique: DmcKO_v6OM-nXY6DsdX2pw-1 Received: by mail-wr1-f69.google.com with SMTP id t18-20020adfdc120000b02900ffe4432d8bso4301842wri.6 for ; Fri, 16 Apr 2021 04:07:08 -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:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=GPi+c282xzGJKGtsxEXKiuYYzkH/n0b1SG5+hHDFjQY=; b=GesfQuQAV92QZOGjDl5GghYZgCgzAYKoUxa4xQM9ktXqAxaM+brBxhKwRJ73xUougz 5NRiytfOu7QttK8VM6w861lntX/cHUWyhRI+CGbDYqiMeM6nvWZBx/QxRyYTsltW31Oc 4tqoLn52FOUeUYRB4j5S3AY995omeBT1tfCT85ADj5r2rmUkA35ihnlW0Bm+MxvezIS3 Lvh0Vc9pJRenFCV6S6CNuQgK5HkEdbXbDzs8ft2Cv/MRovkH6GGS7GXihbi43NOOPEZV jpgU0rJfuOYQWPzQkiXkOeigM5y7ybNBEJ9dufDRrbcUm+7a3HBjsST2Dws6Q4LxSIOb 5ZSg== X-Gm-Message-State: AOAM531VEd71bNdq2x4SETS4epskA4zS52yF8sfjg+cdLRRem9/YEoxP CvI1md1rfJ2nwCwQECN1NbwzOwqSgEOkRxe9cvC14K52QhhmZwgToWqlLo2POaFDelHbQ38Itk8 JmZKNCPMn4Dc= X-Received: by 2002:a1c:e906:: with SMTP id q6mr7687998wmc.138.1618571227519; Fri, 16 Apr 2021 04:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0mCPuIda0sp2AYe64aqgt78fHBJ/WWgEzW5gY9+iWGAmyRJ/Af2N2BSCTDa29ihnvOvgA1g== X-Received: by 2002:a1c:e906:: with SMTP id q6mr7687976wmc.138.1618571227301; Fri, 16 Apr 2021 04:07:07 -0700 (PDT) Received: from [192.168.3.132] (p5b0c64fb.dip0.t-ipconnect.de. [91.12.100.251]) by smtp.gmail.com with ESMTPSA id m15sm6348716wrx.32.2021.04.16.04.07.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Apr 2021 04:07:07 -0700 (PDT) Subject: Re: [PATCH v8 4/8] mm,memory_hotplug: Allocate memmap from the added memory range To: Oscar Salvador Cc: Andrew Morton , Michal Hocko , Anshuman Khandual , Pavel Tatashin , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210416102153.8794-1-osalvador@suse.de> <20210416102153.8794-5-osalvador@suse.de> <6e659d5b-c3f1-bd72-a3af-235d6bc55b0b@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Fri, 16 Apr 2021 13:07:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0D087E000120 X-Stat-Signature: wcx16wh6cj146p7mxfz39bsozu7qihwe Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618571228-445119 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: > -int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > - int online_type, int nid) > +int mhp_init_memmap_on_memory(unsigned long pfn, unsigned long nr_pages, > + struct zone *zone) > +{ > + unsigned long end_pfn = pfn + nr_pages; > + int ret; > + > + ret = kasan_add_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages)); > + if (ret) > + return ret; > + > + /* > + * Initialize vmemmap pages with the corresponding node, zone links set. The "set" sounds weird. I'd remove that comment completely. > + */ > + move_pfn_range_to_zone(zone, pfn, nr_pages, NULL, MIGRATE_UNMOVABLE); > + > + /* > + * It might be that the vmemmap_pages fully span sections. If that is > + * the case, mark those sections online here as otherwise they will be > + * left offline. > + */ > + if (nr_pages >= PAGES_PER_SECTION) > + online_mem_sections(pfn, ALIGN_DOWN(end_pfn, PAGES_PER_SECTION)); > + > + return ret; > +} > + > +void mhp_deinit_memmap_on_memory(unsigned long pfn, unsigned long nr_pages) > +{ > + unsigned long end_pfn = pfn + nr_pages; > + /* > + * The pages associated with this vmemmap have been offlined, so > + * we can reset its state here. > + */ > + remove_pfn_range_from_zone(page_zone(pfn_to_page(pfn)), pfn, nr_pages); > + kasan_remove_zero_shadow(__va(PFN_PHYS(pfn)), PFN_PHYS(nr_pages)); > + > + /* > + * It might be that the vmemmap_pages fully span sections. If that is > + * the case, mark those sections offline here as otherwise they will be > + * left online. > + */ > + if (nr_pages >= PAGES_PER_SECTION) > + offline_mem_sections(pfn, ALIGN_DOWN(end_pfn, PAGES_PER_SECTION)); It's usually best if you undo stuff in the complete opposite order. For example at this point, the memmap might already have been poisoned, yet pfn_to_online_page() would return true. You should do that first. Apart from that, nothing jumped at me :) Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb