From patchwork Sun Feb 27 02:25:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 12761518 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 32624C433EF for ; Sun, 27 Feb 2022 02:25:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B279F8D0015; Sat, 26 Feb 2022 21:25:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD7538D0007; Sat, 26 Feb 2022 21:25:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ED0B8D0015; Sat, 26 Feb 2022 21:25:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 9329E8D0007 for ; Sat, 26 Feb 2022 21:25:18 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 53ADC203EE for ; Sun, 27 Feb 2022 02:25:18 +0000 (UTC) X-FDA: 79186967916.08.72704C4 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf26.hostedemail.com (Postfix) with ESMTP id E269A140003 for ; Sun, 27 Feb 2022 02:25:17 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id a1so9807039qvl.6 for ; Sat, 26 Feb 2022 18:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:mime-version; bh=ZT/+q9dNBSLcgjlN3SJ5+1Yj8vgLHAugbOdQcBKIfxY=; b=F4SnOsdsUpqy9Dh3XAGAdr4uySWlOmbJijjyaU/uVVo/tp0yVZFdz3tCn9oLpW4k5f MQ3/Scu+VouIVui2NTyNvRlUu8Idq07xX0X2Fz8EgRA+bV+LiDHmvCW/iLH42AgjvvJF 8HhnID1Eq5lToU2rv9OaVlQ3dJVbgNXpLfrkfT6aGsLT+HUfxMIgZxn02FP9F1XzroBU rWjOOqoTWByA6i/YltHquGR7l7tYgyDGeGAhQ5siUfRd2pCTEt1yoXpTgSX9GURmR+5C pDjSo/DTcr1LHpXakUqQJpdGCOLVql52A0RT9jC0lvbTROVwpMGV7rocQtowIWljvjPB htWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version; bh=ZT/+q9dNBSLcgjlN3SJ5+1Yj8vgLHAugbOdQcBKIfxY=; b=0UrjGlTXbonqmf8g9sWnP1askK7z85iOx+k/DfLpN0E+Cuo5cILMKBHfwHpClqu2ln 1tl5d0EiyaDWwxwG2tPIiXFlEDtjNA9+1Zeix1Dtj2F/UcXrpymldTSY7P4+Xld6Rgfl ZlfaSaZDaCPNvZKBdivg7sdbePtYVLuA7CAOeqCLwP3YmsqNvnRANXcE+X6mJDUHE/++ W/MHDvzGjC9BZwiTv0isURz3/yEs3HIMfPMDWYUVSVP97+AHMXpkaAtY8HXDyED3WFJ0 vMp33rVTZTKH7P94g2omnX4l1nXfexkdKQVgsCnvfeEJ/rosn84gHDJHl490HN9vJeok lj3A== X-Gm-Message-State: AOAM5331XM3ac+WWOSzgBP4nBFxV8+H8q8XkYYPMZj+B8omu/4S5Tw9K KKEQj40U/kKaJkLoAy+1/vbQvg== X-Google-Smtp-Source: ABdhPJxfrEuPobOVaV23MJwxDp8JklmIfshf0IhpzBrIeactCe6Iqz89FhRU41LIRU5L/0nZB2MA0A== X-Received: by 2002:a05:6214:1947:b0:432:bb20:4b38 with SMTP id q7-20020a056214194700b00432bb204b38mr8513388qvk.96.1645928717019; Sat, 26 Feb 2022 18:25:17 -0800 (PST) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id k125-20020a378883000000b006491db6dbb1sm3215102qkd.84.2022.02.26.18.25.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Feb 2022 18:25:16 -0800 (PST) Date: Sat, 26 Feb 2022 18:25:15 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@ripple.anvils To: Matthew Wilcox cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH next] mm/migrate: fix remove_migration_pte() of hugetlb entry Message-ID: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E269A140003 X-Stat-Signature: 7r5zduz4uzkhoyb71kunfh1ftxp4zy7i Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=F4SnOsds; spf=pass (imf26.hostedemail.com: domain of hughd@google.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com X-HE-Tag: 1645928717-59875 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: The foliation of remove_migration_pte() is currently wrong on hugetlb anon entries, causing LTP move_pages12 to crash on BUG_ON(!PageLocked) in hugepage_add_anon_rmap(). Fixes: b4010e88f071 ("mm/migrate: Convert remove_migration_ptes() to folios") Signed-off-by: Hugh Dickins --- Please just fold in if you agree. mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- mmotm/mm/migrate.c +++ linux/mm/migrate.c @@ -182,7 +182,8 @@ static bool remove_migration_pte(struct struct page *new; unsigned long idx = 0; - if (!folio_test_ksm(folio)) + /* Skip call in common case, plus .pgoff is invalid for KSM */ + if (pvmw.nr_pages != 1 && !folio_test_hugetlb(folio)) idx = linear_page_index(vma, pvmw.address) - pvmw.pgoff; new = folio_page(folio, idx);