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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 BDC4CC433ED for ; Fri, 21 May 2021 06:32:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4267B613BB for ; Fri, 21 May 2021 06:32:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4267B613BB Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8BF7F940017; Fri, 21 May 2021 02:32:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86E5894000D; Fri, 21 May 2021 02:32:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 75E22940017; Fri, 21 May 2021 02:32:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id 43E8F94000D for ; Fri, 21 May 2021 02:32:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id BA178181AEF3C for ; Fri, 21 May 2021 06:32:11 +0000 (UTC) X-FDA: 78164268462.15.B018454 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf23.hostedemail.com (Postfix) with ESMTP id 16C7CA0001C0 for ; Fri, 21 May 2021 06:32:08 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1621578730; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MgAsTlp/G2cmqkGxmaaSKExDAxwHonea1c7OuAsPn3g=; b=KbojoLVxdsFbYDX5ZYujXe03f0TzPM28jH6utKeSnZqeVey6sy9x5mvuJsn9YPWPK3R9zW G8+qf31tsUptxJgXS2z87+fa7sA2NwW6q7cQ587JpV0VocZHVIUks62mNLqqc8Wm0STpQ5 OtBvjfuyTg4Y6FPwNCIkRIi3EV6wkM4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D6FD5AC47; Fri, 21 May 2021 06:32:09 +0000 (UTC) Date: Fri, 21 May 2021 08:32:09 +0200 From: Michal Hocko To: Muchun Song Cc: akpm@linux-foundation.org, osalvador@suse.de, mike.kravetz@oracle.com, david@redhat.com, willy@infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, zhengqi.arch@bytedance.com, fam.zheng@bytedance.com, Anshuman Khandual , Randy Dunlap Subject: Re: [PATCH v2] mm: migrate: fix missing update page_private to hugetlb_page_subpool Message-ID: References: <20210521022747.35736-1-songmuchun@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210521022747.35736-1-songmuchun@bytedance.com> Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=KbojoLVx; spf=pass (imf23.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.15 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 16C7CA0001C0 X-Stat-Signature: nrjhzzj3jnjhobmwesf6dgk7p9fniir1 X-HE-Tag: 1621578728-802383 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 Fri 21-05-21 10:27:47, 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 The patch looks good to me. I hope Fixes tag will not confuse stable backporters as this is a non issue for any released kernel. Acked-by: Michal Hocko > --- > Changeslog in v2: > 1. Update commit log suggested by Mike and Andrew. > 2. Fix compiler error when !CONFIG_HUGETLB_PAGE reported by Randy. > > Thanks. > > include/linux/hugetlb.h | 5 +++++ > mm/migrate.c | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index 9f192ce44088..e11a2e9aa514 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -915,6 +915,11 @@ static inline bool is_hugetlb_free_vmemmap_enabled(void) > #else /* CONFIG_HUGETLB_PAGE */ > struct hstate {}; > > +static inline struct hugepage_subpool *hugetlb_page_subpool(struct page *hpage) > +{ > + return NULL; > +} > + > static inline int isolate_or_dissolve_huge_page(struct page *page, > struct list_head *list) > { > diff --git a/mm/migrate.c b/mm/migrate.c > index 066b1e4e8bde..0692fc2638aa 100644 > --- a/mm/migrate.c > +++ b/mm/migrate.c > @@ -1292,7 +1292,7 @@ static int unmap_and_move_huge_page(new_page_t get_new_page, > * page_mapping() set, hugetlbfs specific move page routine will not > * be called and we could leak usage counts for subpools. > */ > - if (page_private(hpage) && !page_mapping(hpage)) { > + if (hugetlb_page_subpool(hpage) && !page_mapping(hpage)) { > rc = -EBUSY; > goto out_unlock; > } > -- > 2.11.0 -- Michal Hocko SUSE Labs