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=-10.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 4EFD3C433ED for ; Fri, 21 May 2021 07:25:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A83E61363 for ; Fri, 21 May 2021 07:25:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235815AbhEUH0t (ORCPT ); Fri, 21 May 2021 03:26:49 -0400 Received: from foss.arm.com ([217.140.110.172]:40262 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232281AbhEUH0s (ORCPT ); Fri, 21 May 2021 03:26:48 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D747511B3; Fri, 21 May 2021 00:25:25 -0700 (PDT) Received: from [10.163.81.51] (unknown [10.163.81.51]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECC053F73D; Fri, 21 May 2021 00:25:21 -0700 (PDT) Subject: Re: [PATCH v2] mm: migrate: fix missing update page_private to hugetlb_page_subpool To: Muchun Song , akpm@linux-foundation.org, osalvador@suse.de, mike.kravetz@oracle.com, mhocko@suse.com, david@redhat.com, willy@infradead.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, zhengqi.arch@bytedance.com, fam.zheng@bytedance.com, Randy Dunlap References: <20210521022747.35736-1-songmuchun@bytedance.com> From: Anshuman Khandual Message-ID: Date: Fri, 21 May 2021 12:56:06 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210521022747.35736-1-songmuchun@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/21/21 7:57 AM, Muchun Song wrote: > Since commit d6995da31122 ("hugetlb: use page.private for hugetlb specific > page flags") converts page.private for hugetlb specific page flags. We > should use hugetlb_page_subpool() to get the subpool pointer instead of > page_private(). > > This 'could' prevent the migration of hugetlb pages. page_private(hpage) > is now used for hugetlb page specific flags. At migration time, the > only flag which could be set is HPageVmemmapOptimized. This flag will > only be set if the new vmemmap reduction feature is enabled. In > addition, !page_mapping() implies an anonymous mapping. So, this will > prevent migration of hugetb pages in anonymous mappings if the vmemmap > reduction feature is enabled. > > In addition, that if statement checked for the rare race condition of a > page being migrated while in the process of being freed. Since that > check is now wrong, we could leak hugetlb subpool usage counts. > > The commit forgot to update it in the page migration routine. So fix it. > > Fixes: d6995da31122 ("hugetlb: use page.private for hugetlb specific page flags") > Reported-by: Anshuman Khandual > Reported-by: Randy Dunlap > Signed-off-by: Muchun Song > Reviewed-by: Mike Kravetz Tested on all page size configs and HugeTLB migrations work as expected. Tested-by: Anshuman Khandual #arm64