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=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no 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 6566AC433E0 for ; Wed, 17 Feb 2021 14:24:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3999A64E5B for ; Wed, 17 Feb 2021 14:24:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233487AbhBQOY0 (ORCPT ); Wed, 17 Feb 2021 09:24:26 -0500 Received: from mx2.suse.de ([195.135.220.15]:46814 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233374AbhBQOYW (ORCPT ); Wed, 17 Feb 2021 09:24:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D3039B8FA; Wed, 17 Feb 2021 14:23:39 +0000 (UTC) Date: Wed, 17 Feb 2021 15:23:37 +0100 From: Oscar Salvador To: David Hildenbrand Cc: Michal Hocko , Andrew Morton , Mike Kravetz , Muchun Song , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm: Make alloc_contig_range handle free hugetlb pages Message-ID: <20210217142321.GA651@linux> References: <20210217100816.28860-1-osalvador@suse.de> <20210217100816.28860-2-osalvador@suse.de> <182f6a4a-6f95-9911-7730-8718ab72ece2@redhat.com> <5f50c810-3f49-a162-6d1d-cf621c515f45@redhat.com> <5d70b340-2db0-ef1f-1564-e5d39354c11c@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d70b340-2db0-ef1f-1564-e5d39354c11c@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 17, 2021 at 03:08:04PM +0100, David Hildenbrand wrote: > On 17.02.21 14:59, Michal Hocko wrote: > > On Wed 17-02-21 14:53:37, David Hildenbrand wrote: > > > On 17.02.21 14:50, Michal Hocko wrote: > > [...] > > > > Do we have any real life examples? Or does this fall more into, let's > > > > optimize an existing implementation category. > > > > > > > > > > It's a big TODO item I have on my list and I am happy that Oscar is looking > > > into it. So yes, I noticed it while working on virtio-mem. It's real. > > > > Do not take me wrong, I am not opposing to the functionality. I am > > asking for the specific usecase. > > Makes sense, and a proper motivation should be included in the patches/cover > letter. So here comes a quick-n-dirty example: Definitely. I took it for granted that the problem was obvious. > Start a VM with 4G. Hotplug 1G via virtio-mem and online it to ZONE_MOVABLE. > Allocate 512 huge pages. > > [root@localhost ~]# cat /proc/meminfo > MemTotal: 5061512 kB > MemFree: 3319396 kB > MemAvailable: 3457144 kB > ... > HugePages_Total: 512 > HugePages_Free: 512 > HugePages_Rsvd: 0 > HugePages_Surp: 0 > Hugepagesize: 2048 kB > > > The huge pages get partially allocate from ZONE_MOVABLE. Try unplugging 1G > via virtio-mem (remember, all ZONE_MOVABLE). Inside the guest: > > [ 180.058992] alloc_contig_range: [1b8000, 1c0000) PFNs busy > [ 180.060531] alloc_contig_range: [1b8000, 1c0000) PFNs busy > [ 180.061972] alloc_contig_range: [1b8000, 1c0000) PFNs busy > [ 180.063413] alloc_contig_range: [1b8000, 1c0000) PFNs busy > [ 180.064838] alloc_contig_range: [1b8000, 1c0000) PFNs busy > [ 180.065848] alloc_contig_range: [1bfc00, 1c0000) PFNs busy > [ 180.066794] alloc_contig_range: [1bfc00, 1c0000) PFNs busy > [ 180.067738] alloc_contig_range: [1bfc00, 1c0000) PFNs busy > [ 180.068669] alloc_contig_range: [1bfc00, 1c0000) PFNs busy > [ 180.069598] alloc_contig_range: [1bfc00, 1c0000) PFNs busy > > > I succeed in unplugging 540MB - 484 MB remain blocked by huge pages ("which > did not end up there by pure luck"). These pages are movable (and even > free!) and can easily be reallocated. Thanks for providing such a detailed case David. I will gather the bits and prepare a v2 once I gather more feedback. -- Oscar Salvador SUSE L3