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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB791C433EF for ; Fri, 10 Dec 2021 18:02:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D61A66B0072; Fri, 10 Dec 2021 13:00:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D11E66B0073; Fri, 10 Dec 2021 13:00:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB2D16B0074; Fri, 10 Dec 2021 13:00:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0165.hostedemail.com [216.40.44.165]) by kanga.kvack.org (Postfix) with ESMTP id A91C66B0072 for ; Fri, 10 Dec 2021 13:00:10 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7457186E85 for ; Fri, 10 Dec 2021 18:00:00 +0000 (UTC) X-FDA: 78902648160.08.7188CBA Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by imf02.hostedemail.com (Postfix) with ESMTP id 2C79880004 for ; Fri, 10 Dec 2021 17:59:59 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id w1so32220433edc.6 for ; Fri, 10 Dec 2021 09:59:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Q4cSh71dzUGeiXZRE4QW36EmwcI8AZrCxMvROIrZS14=; b=hZuwqUyMx6p4vq+XxIbn+14N9qyb4VjVKFc+XlT24PuxI8wuTRByd6L5UShZbYCPn6 hFJEMkb+ZcKlIYkUV0tDiyObLesBR7irNUCiCMAa2lVRi3CC57aTV1alPZFU5Ysazrph YFhWPMKpxva8rtigETs3FTPO6R5mZn5VOWtBPJXZadHgtSqBE5wuIb/YuK6Qz1CH7KoK hnKUK9t4YQwu/yKgZT3oT89+N75FsEO9VhEY0F2y2bLckImDe4uov8SNI0AQgrJ3ZD5d S7s4cNZ1Mv66posmbYafTGVHKgSQlseJKI92d9yXya7GxXHGbGAnv0tL4KEZr7IYPLWc FeuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Q4cSh71dzUGeiXZRE4QW36EmwcI8AZrCxMvROIrZS14=; b=MDzV7IQ7kEGd1SH93+P8npyPrLZQcEPbUjQQstWB6zc6xUl8rcdm4UjBUoyYWmKhst a0eQvisf+0A3CC3XY4AL6Zp9r/nUBSV9bc5WzkC9gXsfvi/+YfocGuYfXTbyciF47X2W 8vMTJuOSWAzR1LvMr5xgbhxbp2U2Ul7xs/+noQNNEfk1pPh0fXK6C3T55W4uy1oyytD5 22YbncuYVro/MvVSHP5U3oTiiuc5j8F1mBte2k/TxjSY6LOTYQ4AIGOG9KKiSDDIWZsv MOSoyKVYJ9Gyd6Yu0CHylaphHeWguQ0haA0arKeAThXKNmm5jfFVtcRoJchuph0NKHwO TjkQ== X-Gm-Message-State: AOAM530Mg/I6kR2oleAbzEcjJ5Q71FRvedANOGyPGBk3sb6ARWlzTrY8 uhUmp3EBhZCPNmVad/8PZ6AW2sA+hIH9byf9Jmg= X-Google-Smtp-Source: ABdhPJyMR1vnybSwdT0dzOqAU1cPEp/zYKbnjixRaU/JBnWxGfH4bMnkNn+t2j/Uf7ySIMQBrI/ELelqVgOUVCZ6KxY= X-Received: by 2002:a50:e003:: with SMTP id e3mr40230046edl.374.1639159198508; Fri, 10 Dec 2021 09:59:58 -0800 (PST) MIME-Version: 1.0 References: <20211209230414.2766515-1-zi.yan@sent.com> <20211209230414.2766515-4-zi.yan@sent.com> <84807a03-f7d1-83cb-16df-bacc58de4529@gmail.com> <971750C3-DAEC-4EE8-B838-2DD3CBC29781@nvidia.com> In-Reply-To: <971750C3-DAEC-4EE8-B838-2DD3CBC29781@nvidia.com> From: Yang Shi Date: Fri, 10 Dec 2021 09:59:46 -0800 Message-ID: Subject: Re: [RFC PATCH v2 3/7] mm: migrate: allocate the right size of non hugetlb or THP compound pages. To: Zi Yan Cc: Eric Ren , David Hildenbrand , Linux MM , Linux Kernel Mailing List , Michael Ellerman , Christoph Hellwig , Marek Szyprowski , Robin Murphy , linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, iommu@lists.linux-foundation.org, Vlastimil Babka , Mel Gorman Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2C79880004 X-Stat-Signature: mg7awubtt748941ut6rapr81idk3f7xn Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=hZuwqUyM; spf=pass (imf02.hostedemail.com: domain of shy828301@gmail.com designates 209.85.208.44 as permitted sender) smtp.mailfrom=shy828301@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1639159199-733668 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, Dec 10, 2021 at 8:08 AM Zi Yan wrote: > > On 10 Dec 2021, at 2:53, Eric Ren wrote: > > > Hi, > > > > On 2021/12/10 07:04, Zi Yan wrote: > >> From: Zi Yan > >> > >> alloc_migration_target() is used by alloc_contig_range() and non-LRU > >> movable compound pages can be migrated. Current code does not allocate the > >> right page size for such pages. Check THP precisely using > >> is_transparent_huge() and add allocation support for non-LRU compound > >> pages. > > Could you elaborate on why the current code doesn't get the right size? how this patch fixes it. > > The current code only check PageHuge() and PageTransHuge(). Non-LRU compound > pages will be regarded as PageTransHuge() and an order-9 page is always allocated > regardless of the actual page order. This patch makes the exact check for > THPs using is_transparent_huge() instead of PageTransHuge() and checks PageCompound() > after PageHuge() and is_transparent_huge() for non-LRU compound pages. > > > > > The description sounds like it's an existing bug, if so, the patch subject should be changed to > > "Fixes ..."? > > I have not seen any related bug report. > > > > >> > >> Signed-off-by: Zi Yan > >> --- > >> mm/migrate.c | 8 ++++++-- > >> 1 file changed, 6 insertions(+), 2 deletions(-) > >> > >> diff --git a/mm/migrate.c b/mm/migrate.c > >> index d487a399253b..2ce3c771b1de 100644 > >> --- a/mm/migrate.c > >> +++ b/mm/migrate.c > >> @@ -1563,7 +1563,7 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) > >> return alloc_huge_page_nodemask(h, nid, mtc->nmask, gfp_mask); > >> } > >> - if (PageTransHuge(page)) { > >> + if (is_transparent_hugepage(page)) { > >> /* > >> * clear __GFP_RECLAIM to make the migration callback > >> * consistent with regular THP allocations. > >> @@ -1572,13 +1572,17 @@ struct page *alloc_migration_target(struct page *page, unsigned long private) > > if (PageTransHuge(page)) { // just give more code context > > ... > >> gfp_mask |= GFP_TRANSHUGE; > >> order = HPAGE_PMD_ORDER; > > order assigned here > >> } > >> + if (PageCompound(page)) { > >> + gfp_mask |= __GFP_COMP; > >> + order = compound_order(page); > > re-assinged again as THP is a compound page? > > Ah, you are right. Will use else if instead. Thanks. You don't have to use else if, you could just do: if (PageCompound(page)) { gfp_mask |= __GFP_COMP; order = compound_order(page); } if (is_transparent_hugepage(page)) { /* Manipulate THP specific gfp mask */ .... } > > > Thanks, > > Eric > >> + } > >> zidx = zone_idx(page_zone(page)); > >> if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE) > >> gfp_mask |= __GFP_HIGHMEM; > >> new_page = __alloc_pages(gfp_mask, order, nid, mtc->nmask); > >> - if (new_page && PageTransHuge(new_page)) > >> + if (new_page && is_transparent_hugepage(page)) > >> prep_transhuge_page(new_page); > >> return new_page; > > > -- > Best Regards, > Yan, Zi