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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 37E44C433E6 for ; Tue, 12 Jan 2021 14:18:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5BFEE2311D for ; Tue, 12 Jan 2021 14:18:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5BFEE2311D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9C3B46B00DC; Tue, 12 Jan 2021 09:18:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9768D6B013D; Tue, 12 Jan 2021 09:18:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 814C66B015A; Tue, 12 Jan 2021 09:18:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0041.hostedemail.com [216.40.44.41]) by kanga.kvack.org (Postfix) with ESMTP id 689816B00DC for ; Tue, 12 Jan 2021 09:18:28 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 240C8181AEF09 for ; Tue, 12 Jan 2021 14:18:28 +0000 (UTC) X-FDA: 77697328296.20.clam04_2117c3327516 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id F184B180C07A3 for ; Tue, 12 Jan 2021 14:18:27 +0000 (UTC) X-HE-Tag: clam04_2117c3327516 X-Filterd-Recvd-Size: 5776 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Jan 2021 14:18:27 +0000 (UTC) Received: by mail-pf1-f178.google.com with SMTP id a188so1455086pfa.11 for ; Tue, 12 Jan 2021 06:18:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZP/OKsBTHa1Ku/1C8+jY1uZ9XXWnbjWQbbJ1iqiQI90=; b=KXJDcyT04KY1E1/QvWwWjUF36RQI+5Bu+t3pUk2IHBywPVmHdqc+vzoj6oysXqV9RT U357Xxhes9/2bjHM8hT2AKu97rn+qbyiAC/hTrSSHupPcpPEzGvuaHx9KHUY1bXWOSWI FdXitRT2Wj6V+xJFgjqWpqzgGrumEPB12ESZ0NYtdDoaV9weEiBbEmuHNkblO/dquesr 3fA21BrKCYy262yV7usZurMZwsjpyKY1apcI9hJU2/DyA/k+Kl4kWvrUPNoViA6SC0nL dfgI2d1OHb15tB2ry8KHen2cQEqXwIF5i6RViXC68QYIq0e7WE8m23+vXPKXUyJ4v0lE Vjwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZP/OKsBTHa1Ku/1C8+jY1uZ9XXWnbjWQbbJ1iqiQI90=; b=o7P9StOKo2j8vJmaRzBbKZe404F0S5sYkDucM5syvpdfkaklQvDUHzdyEgV25ZlOlW oMvNbIaxsie7YclAZAnl2kv7c8A02ILiMQANRbVySvObdYCt5fNgFdNSDISyuCOFVG9P xObAlpa9FEKfbSxNiuf31IXt7sQrfroeu7PQYqN1PQfnBGlBsDstcEDw4n2dMtASzA8M kGnEbZ7hlGW1n6J79Vr7IHThmMOaepF2aC1aofspGUZR6gEfo5OJgDfgWvCwR5CEb/mb KWXpfkyBQWodJOetBz7XqefWWtdMhvVoFHa9JeeJXeXR8xL06I1f99ctoIj8HzhmDtBd fOKw== X-Gm-Message-State: AOAM531FYbxd7zW512bkvm3qLFcFPEUnE3lwiVX7udywFP10I6hb6ABl z9rsFd6jBEATp4/I0Px4GHA0qpFUZwZCfmYZUXgTKg== X-Google-Smtp-Source: ABdhPJymg7ZZpekPq1atCLekTkcjQv4GQ0IAuUDaK2XbFHH8P04lOSQ9bOJNTYSLi5qlu4NStP7+Xv+mzMDUmx1MI+I= X-Received: by 2002:a63:50a:: with SMTP id 10mr4974342pgf.273.1610461106114; Tue, 12 Jan 2021 06:18:26 -0800 (PST) MIME-Version: 1.0 References: <20210110124017.86750-1-songmuchun@bytedance.com> <20210110124017.86750-2-songmuchun@bytedance.com> <1b39d654-0b8c-de3a-55d1-6ab8c2b2e0ba@redhat.com> <423ee403-bba7-acf6-8934-9db36d3a719a@redhat.com> In-Reply-To: <423ee403-bba7-acf6-8934-9db36d3a719a@redhat.com> From: Muchun Song Date: Tue, 12 Jan 2021 22:17:42 +0800 Message-ID: Subject: Re: [External] Re: [PATCH v3 1/6] mm: migrate: do not migrate HugeTLB page whose refcount is one To: David Hildenbrand Cc: Mike Kravetz , Andrew Morton , Naoya Horiguchi , Andi Kleen , mhocko@suse.cz, Linux Memory Management List , LKML , Yang Shi Content-Type: text/plain; charset="UTF-8" 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: On Tue, Jan 12, 2021 at 9:51 PM David Hildenbrand wrote: > > On 12.01.21 14:40, Muchun Song wrote: > > On Tue, Jan 12, 2021 at 7:11 PM David Hildenbrand wrote: > >> > >> On 12.01.21 12:00, David Hildenbrand wrote: > >>> On 10.01.21 13:40, Muchun Song wrote: > >>>> If the refcount is one when it is migrated, it means that the page > >>>> was freed from under us. So we are done and do not need to migrate. > >>>> > >>>> This optimization is consistent with the regular pages, just like > >>>> unmap_and_move() does. > >>>> > >>>> Signed-off-by: Muchun Song > >>>> Reviewed-by: Mike Kravetz > >>>> Acked-by: Yang Shi > >>>> --- > >>>> mm/migrate.c | 6 ++++++ > >>>> 1 file changed, 6 insertions(+) > >>>> > >>>> diff --git a/mm/migrate.c b/mm/migrate.c > >>>> index 4385f2fb5d18..a6631c4eb6a6 100644 > >>>> --- a/mm/migrate.c > >>>> +++ b/mm/migrate.c > >>>> @@ -1279,6 +1279,12 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, > >>>> return -ENOSYS; > >>>> } > >>>> > >>>> + if (page_count(hpage) == 1) { > >>>> + /* page was freed from under us. So we are done. */ > >>>> + putback_active_hugepage(hpage); > >>>> + return MIGRATEPAGE_SUCCESS; > >>>> + } > >>>> + > >>>> new_hpage = get_new_page(hpage, private); > >>>> if (!new_hpage) > >>>> return -ENOMEM; > >>>> > >>> > >>> Question: What if called via alloc_contig_range() where we even want to > >>> "migrate" free pages, meaning, relocate it? > >>> > >> > >> To be more precise: > >> > >> a) We don't have dissolve_free_huge_pages() calls on the > >> alloc_contig_range() path. So we *need* migration IIUC. > > > > Without this patch, if you want to migrate a HUgeTLB page, > > the page is freed to the hugepage pool. With this patch, > > the page is also freed to the hugepage pool. > > I didn't see any different. I am missing something? > > I am definitely not an expert on hugetlb pools, that's why I am asking. > > Isn't it, that with your code, no new page is allocated - so > dissolve_free_huge_pages() might just refuse to dissolve due to > reservations, bailing out, no? Without this patch, the new page can be allocated from the hugepage pool. The dissolve_free_huge_pages() also can refuse to dissolve due to reservations. Right? > > (as discussed, looks like alloc_contig_range() needs to be fixed to > handle this correctly) > > -- > Thanks, > > David / dhildenb >