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=unavailable 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 B69AAC433E0 for ; Tue, 12 Jan 2021 14:19:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 549EC222F9 for ; Tue, 12 Jan 2021 14:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbhALOTH (ORCPT ); Tue, 12 Jan 2021 09:19:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbhALOTG (ORCPT ); Tue, 12 Jan 2021 09:19:06 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA1AC061786 for ; Tue, 12 Jan 2021 06:18:26 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id z21so1543190pgj.4 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=TQjE5m0dYDxNK2IhgvEz1Pisbfas4kNJ/XfxSe3BxKGblBcaVlXY/wjAftb4pzUBUA mDBwLcEbXRO4xPTSb/Bx6ghJiJzoiS/J8d/7Kc4bIRE188M5ctdIlvjH8JRvYo5j3O1H H531e1birOwtrPc+jV8aR5FXShhskZJ4seEyzVMTgYIZomBqJSltwJcE7NENtwJ8hrU1 6Z7MlSbaJquySWgBc6CTdqND02NvW9pf2uqonc59vEnb4xVi2wWrc5LrepyCrjcFIJnz KJmM6i4BtpMxeFjDKmjfSXtivjtD0XUMlkhojZzsXMNfd9ndzBjTLGdT6DslnTi1i7UO DQlg== X-Gm-Message-State: AOAM5313r7Gj/Tf2bWOjvGYv9Vy0E4sJz6SHhaFgcEBRWhl+nrAxIcpm av/LFcdubz4OTLs/dx34yIK2tCzPIKImbnSndz/cZw== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >