From patchwork Fri Apr 8 20:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807179 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 317ECC433F5 for ; Fri, 8 Apr 2022 20:08:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7F9D6B0073; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A61836B0074; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 945AE6B0075; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 822ED6B0073 for ; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3DDE1182895A9 for ; Fri, 8 Apr 2022 20:08:55 +0000 (UTC) X-FDA: 79334800230.26.18ED455 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id C01121C000A for ; Fri, 8 Apr 2022 20:08:54 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DB20961DAE; Fri, 8 Apr 2022 20:08:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40FD9C385A3; Fri, 8 Apr 2022 20:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448533; bh=skQ4+SSthFwNXEUSPxFB30AaiHqqZjOmrlj9xVcgnkk=; h=Date:To:From:In-Reply-To:Subject:From; b=BKrsdFk73utuvqjSyEUscWJAyAaZ5FM/xIs8jmNtD8FsiwQxY6gFzuGZvgsr1DxcC 9D4/wu+TmfmcwBoNk5ARjFrVHJf1DDvNUAIxC7VPpTCwsB4V6SRYqLKxMbGF1cApeG EIZjnkZGrVB3R1n9LRSN6TGJFmfp68aizE+aJEW8= Date: Fri, 08 Apr 2022 13:08:52 -0700 To: willy@infradead.org,naoya.horiguchi@linux.dev,mhocko@kernel.org,ziy@nvidia.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 1/9] mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation. Message-Id: <20220408200853.40FD9C385A3@smtp.kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C01121C000A X-Stat-Signature: gtnt1oqmi35j5gxt97auhht4fgq9kh5i X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=BKrsdFk7; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1649448534-353657 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: From: Zi Yan Subject: mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation. Fix a VM_BUG_ON_FOLIO(folio_nr_pages(old) != nr_pages) crash. With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration. Link: https://lkml.kernel.org/r/20220404165325.1883267-1-zi.yan@sent.com Link: https://lore.kernel.org/linux-mm/20220404132908.GA785673@u2004/ Fixes: d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache") Reported-by: Naoya Horiguchi Signed-off-by: Zi Yan Cc: Matthew Wilcox Cc: Michal Hocko Signed-off-by: Andrew Morton --- mm/mempolicy.c | 2 +- mm/migrate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/mm/mempolicy.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +++ a/mm/mempolicy.c @@ -1209,7 +1209,7 @@ static struct page *new_page(struct page struct page *thp; thp = alloc_hugepage_vma(GFP_TRANSHUGE, vma, address, - HPAGE_PMD_ORDER); + thp_order(page)); if (!thp) return NULL; prep_transhuge_page(thp); --- a/mm/migrate.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +++ a/mm/migrate.c @@ -1547,7 +1547,7 @@ struct page *alloc_migration_target(stru */ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; - order = HPAGE_PMD_ORDER; + order = thp_order(page); } zidx = zone_idx(page_zone(page)); if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE)