From patchwork Wed Dec 8 13:39:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 12664443 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 72A4CC433EF for ; Wed, 8 Dec 2021 13:40:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B79AD6B0072; Wed, 8 Dec 2021 08:39:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B01A26B0073; Wed, 8 Dec 2021 08:39:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C8CA6B0074; Wed, 8 Dec 2021 08:39:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay030.a.hostedemail.com [64.99.140.30]) by kanga.kvack.org (Postfix) with ESMTP id 8C4A76B0072 for ; Wed, 8 Dec 2021 08:39:49 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5B38B20EE0 for ; Wed, 8 Dec 2021 13:39:39 +0000 (UTC) X-FDA: 78894734478.11.86FF662 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf01.hostedemail.com (Postfix) with ESMTP id D72FD40008 for ; Wed, 8 Dec 2021 13:39:38 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id k37so5719295lfv.3 for ; Wed, 08 Dec 2021 05:39:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yJxZP7IqD6WpnzN05ApsKwsWjKyIVhUIlqTgjymXUBI=; b=cn5ntZIw16U5O19YoY6sNZcGoaSd5oxi5GOC+kkSXtZfNe5dYYTpEDQ5kLgv/MW2FB gTgM0llDBA2jPxHJ4cdQzOEMgTgy2azvO7f4Ot/L6yFR7JskAkiEeMF93ri6l9JUhjrg WHEU2vFhsUadpFMEIPJiAqJ22W4pysEE23+wOskuljuxwIvvQ62wfJjjAHUvrhHoz0jR bVEJ7EHo/CbwHhUcee/+686MZwMQUqIw/GBRDecmOb7D/BS6q7soClM3LtXXCi8jwivs LH9LYdQrZAhK6cHH+nAMMtiDI7w1x2h7MIqabQmuSFnedQioJmgZjx2fLYqf8K7Jeu8g IkHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yJxZP7IqD6WpnzN05ApsKwsWjKyIVhUIlqTgjymXUBI=; b=empIid/pl8XLa1f1aa12EPuQnMqSRutzqd7kWoZqE2H+zKw8CpKb31K928+bGRMNk+ XEOystBdTDNtMHVFOr6XmWCCvhAS31fWAJF4XjS/Jlth8DBfPStZK7aBDxPgTsaFdHtk 3IQnuAmFuhGZ+6qoFx6yyiWsS4qr/CuAOFXzWEyRzDHIIyobFRNbTou7dsYvgX7onpji 5enjhqRplm0UklKAvSDDXiRGdiM9KFRQp3KnKF2juDAWasJAG5x0EixmgZW4CJA64eoN QFYE9nmqbGnCKOK+ttYOqEPuI3jZGglpVZqoXEhheepFQvkMlE/7KNofYDJG77+MnBKA BU7Q== X-Gm-Message-State: AOAM531GWLOMOCm2/P/JKw2EZADhmgA3//qkAIeH7exyx93yrflNCXw1 8nacc3XhJihaFJtl/+tDa7JSW0z6N7sPvQ== X-Google-Smtp-Source: ABdhPJxlc2TIEiV0n2EB2vM6V1NvTLz2+xZgUVK/hM6J0IEfnR2929k0PYvLtHzWlSJe/XNcOv1rtg== X-Received: by 2002:a05:6512:2252:: with SMTP id i18mr50220395lfu.679.1638970777238; Wed, 08 Dec 2021 05:39:37 -0800 (PST) Received: from localhost.localdomain ([131.228.2.20]) by smtp.gmail.com with ESMTPSA id f10sm257463lfu.122.2021.12.08.05.39.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Dec 2021 05:39:36 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: akpm@linux-foundation.org Subject: [PATCH] mm/gup.c: stricter check on THP migration entry during follow_pmd_mask Date: Wed, 8 Dec 2021 21:39:30 +0800 Message-Id: <20211208133930.599253-1-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: D72FD40008 X-Stat-Signature: 6x77u53z34wha4ktpsbtwkpwdng5s3ui Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=cn5ntZIw; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of lixinhai.lxh@gmail.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=lixinhai.lxh@gmail.com X-HE-Tag: 1638970778-589621 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: When BUG_ON check for THP migration entry, we need also consider !thp_migration_supported() case, becaouse it is invalid at the code context. Now, make this check been covered without adding extra cost. Because pmdval instead of *pmd is read, so just call pmd_migration_entry_wait(). Signed-off-by: Li Xinhai --- mm/gup.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 2c51e9748a6a..49f490bae030 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -644,10 +644,9 @@ static struct page *follow_pmd_mask(struct vm_area_struct *vma, if (!pmd_present(pmdval)) { if (likely(!(flags & FOLL_MIGRATION))) return no_page_table(vma, flags); - VM_BUG_ON(thp_migration_supported() && + VM_BUG_ON(!thp_migration_supported() || !is_pmd_migration_entry(pmdval)); - if (is_pmd_migration_entry(pmdval)) - pmd_migration_entry_wait(mm, pmd); + pmd_migration_entry_wait(mm, pmd); pmdval = READ_ONCE(*pmd); /* * MADV_DONTNEED may convert the pmd to null because