Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6506282pxb; Wed, 17 Feb 2021 06:27:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzE4m153VBUxfKPMm7gCBtFxc7r2br4HsPr70KpFCkhtxKamWQHSApOIaNPnb1WydNC6GHc X-Received: by 2002:a17:906:af10:: with SMTP id lx16mr2962703ejb.192.1613572029639; Wed, 17 Feb 2021 06:27:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613572029; cv=none; d=google.com; s=arc-20160816; b=o0xV+zIF83edYkS3vGR2qkrVNA0OvA5xe4pUGFRx4dI+r86vae94zmPZy0b9CdIfCK 43lzmwsWVkMqKkOYONW8IN/ogV+zaw9ixJEclru9V9WB01tSk/NBlsQ5/AXBh5eKAEqF LsKl964Qg3BOsGIDslXvVMal3MG14xhjQcM1irsNjkNQbCEDSFQKyyiWksPQGx3hqS7Q 2d5CZDu0BtwsbRXeL8ya8ukqUky9O6KpKsViRauCB1cAOak/xe0wXH8B/LOFAKME9spn BsMptRXVro8s7O3aPnkHUM/8Yl9O9serjs6X013hytju4Szt2ncw1Bn1x7G/DymssgXz +mwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=3nhAumsQsPnBfS59HLgscYOKVp1NpaQOyCJ28lSFc7Y=; b=d8YKy/gjkOidlwJYd5YKwN605l2uDnyOvXIMYmGjTxvuwMNvTMedXMeiqypbAV17yL CSmBM3F50YDdEsyMQm0ezYggVL4nPNvfeSmym+7ZyyuH0N39JuHQ6ITm5YvaSC8cwjEz pdtabOsekttK2A2XLKEf4njwWqrEaxNHh5QQ4ATR1ZPTECnAx+QjIvSsKC2H9cUiDaos mE+Rrxg51OBEwfF7+m23AL9FYILf9EJuOusZjzm6TjTjIDTTwgINZ7GeAo8gi0mQiaHO mDu4FQtSNiHsVoI8Zzkf7XTkzwxmH+4wsC9l+xAc4di648bKKFYLnLxhpBm5T+FCJaOT j7JA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si1318782edg.300.2021.02.17.06.26.45; Wed, 17 Feb 2021 06:27:09 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233481AbhBQOYX (ORCPT + 99 others); Wed, 17 Feb 2021 09:24:23 -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