From patchwork Wed Jul 20 11:13:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zach O'Keefe X-Patchwork-Id: 12923805 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 06F5EC433EF for ; Wed, 20 Jul 2022 11:13:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 757276B0072; Wed, 20 Jul 2022 07:13:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 705256B0073; Wed, 20 Jul 2022 07:13:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61A2E6B0074; Wed, 20 Jul 2022 07:13:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 531446B0072 for ; Wed, 20 Jul 2022 07:13:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 28E6C1C5EF3 for ; Wed, 20 Jul 2022 11:13:29 +0000 (UTC) X-FDA: 79707217338.04.18BEC44 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by imf08.hostedemail.com (Postfix) with ESMTP id 9F0E9160008 for ; Wed, 20 Jul 2022 11:13:28 +0000 (UTC) Received: by mail-yb1-f202.google.com with SMTP id m11-20020a5b040b000000b0066fcc60d1a0so12761626ybp.19 for ; Wed, 20 Jul 2022 04:13:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=7AI3O+zagcl863XAbWgbhTD3/EaxCu8vZuBuvsHPiBg=; b=BfGruQR8RXl8VvgNqQk95lr6cSjHsm2KdYSPvr7N7q693O1R0B1mZsS0zteqWpIAQX izerV1ZAleD6Jys0GFGp5CdMMWJ2pvy0CdCYfojpbMzhazyVeEp+GQbaRgvkLk+Zpej8 WtT+QcCiL6QlPIUESiT9cKvKsn/pYiLDaQcD+gywTGFu+gFuztGQlGzsnCt9BVFh0cR4 D5HcKAv6eA0oJuCfSzz4qINtHm1KC5l951uH20YXKgsuHa+Jt+w/z4Ue1YghsdgDya14 rMhPTrQ/Ijo8ujdN0yDJS8OhJIbqZjubneslmit83ZrO2Bx9uIhIhxAGlhJetEMdREek g8hA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=7AI3O+zagcl863XAbWgbhTD3/EaxCu8vZuBuvsHPiBg=; b=kiyWVFa11RtLE+TxdM9Vm6iN6a1sDljmD+6/aGZl+qRXcEYMd2C7xcQE+oNSG2qyIx DyEJwQeM0JOqWDfj80i4WixWE/EebqQEwCe1w/yit44nJoLJtAnmAzWdJZzYAlZx5hNO TUVOTx1+lCKImBcqeZItkqaSCrGVrHeFGZ4PhCAX7zjbEx55Xt+C3Yx/frMavZjYrYEg n2e9F2DhDOvfrjbbrnt9U9rgF8ihCIBYWT2AtWxbpEOTX1tombXtAAXO989s3597lRUL oBDLnV4dtNIONtFNM7aNQTMjX9bntLVhReeYRosBrBUrBqhNSyze2+wsJ4uagsC8PlBx IQbw== X-Gm-Message-State: AJIora80dFYwLVmIXGFUlcVU434H35a+lyhkb7WVcmM2F+PaBuKOujGH qghjWrsZWV5FQ7dLv2FvFrUVe93q1lZM X-Google-Smtp-Source: AGRyM1uEIMmLObiMgFCQ7rXopftC5+sGGYKUFbYMvCroF5TvxbE/hTngpZheb9pO7zCV3DRG5OA0CPrYPi4D X-Received: from zokeefe3.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1b6]) (user=zokeefe job=sendgmr) by 2002:a81:670a:0:b0:31e:738c:f57f with SMTP id b10-20020a81670a000000b0031e738cf57fmr523851ywc.445.1658315607772; Wed, 20 Jul 2022 04:13:27 -0700 (PDT) Date: Wed, 20 Jul 2022 04:13:18 -0700 Message-Id: <20220720111318.1831708-1-zokeefe@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [PATCH mm-unstable] Revert "mm/khugepaged: remove redundant transhuge_vma_suitable() check" From: "Zach O'Keefe" To: Andrew Morton , linux-mm@kvack.org Cc: Hugh Dickins , Yang Shi , "Zach O'Keefe" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658315608; a=rsa-sha256; cv=none; b=ejd9/vsEGMkJkHfzGLdXQf2vL5pDk3XuECMxv7nn1MiscyaknywaBhW3HV+Rq7kZokpNDH nPgUJDjEEnRSUNKEs/D7DCsjmbWjU8ude462efWoqcmCi380WdjvvY2roemrhYV/nTugm1 tcHZaTgeppSRJpVdU+W8oJcZ9iwosO8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BfGruQR8; spf=pass (imf08.hostedemail.com: domain of 3V-PXYgcKCJoTIE8898AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--zokeefe.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3V-PXYgcKCJoTIE8898AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658315608; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=7AI3O+zagcl863XAbWgbhTD3/EaxCu8vZuBuvsHPiBg=; b=8Qguq44I4lAX0LLkyKDwfYC2vI6pvOroxQahrC9gc51Rgcatjqcb0J+C230UEJCEE4iDdQ FDcloE0Kku4JSSQi85M3GbRcMmvOEshZS+A2auyeUUnKuGb+j3+yB1j5HINEKw5yA8CXvW uklQmCMd+oQsnE8w3+5X5crsQBKOvBk= X-Rspam-User: X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9F0E9160008 Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=BfGruQR8; spf=pass (imf08.hostedemail.com: domain of 3V-PXYgcKCJoTIE8898AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--zokeefe.bounces.google.com designates 209.85.219.202 as permitted sender) smtp.mailfrom=3V-PXYgcKCJoTIE8898AIIAF8.6IGFCHOR-GGEP46E.ILA@flex--zokeefe.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 1b8bkriew8odppnxfuq58u66i7mtn58d X-HE-Tag: 1658315608-482492 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: A pmd should not cross a VMA boundary, which is normally enforced by vma_adjust_trans_huge(), and assumed by e.g. __split_huge_pmd_locked(). In this regard, the transhuge_vma_suitable() check in hugepage_vma_check() is not redundant with the transhuge_vma_suitable() check previously in hugepage_vma_revalidate(). The former validates the VMA itself, and checks that *some* memory in the VMA is suitable to collapse while the latter validates if collapsing at a specific address is suitable. By removing the check on the faulting address, we've inadvertently allowed collapse of a pmd that can cross vma->vm_end. Revert this change. Fixes: 143776e7512e ("mm/khugepaged: remove redundant transhuge_vma_suitable() check") Signed-off-by: Zach O'Keefe Reviewed-by: Yang Shi --- Apologies, Andrew. I think you've put the series description into this first patch (thank you). Do you mind moving it into the next patch in the series, "mm: khugepaged: don't carry huge page to the next loop for !CONFIG_NUMA"? Note that the "mm: userspace hugepage collapse, v7" series doesn't actually depend on this patch, it was just a cleanup (and thus perhaps I shouldn't have included it in the series in the first place). --- mm/khugepaged.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2db6d0dd2981..69990dacde14 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -855,6 +855,8 @@ static int hugepage_vma_revalidate(struct mm_struct *mm, unsigned long address, if (!vma) return SCAN_VMA_NULL; + if (!transhuge_vma_suitable(vma, address)) + return SCAN_ADDRESS_RANGE; if (!hugepage_vma_check(vma, vma->vm_flags, false, false, cc->is_khugepaged)) return SCAN_VMA_CHECK;