From patchwork Tue Oct 4 19:33:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 12998645 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 1B9B0C433F5 for ; Tue, 4 Oct 2022 19:34:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EF366B0074; Tue, 4 Oct 2022 15:34:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA376B0078; Tue, 4 Oct 2022 15:34:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A8146B0075; Tue, 4 Oct 2022 15:34:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 66F9A6B0073 for ; Tue, 4 Oct 2022 15:34:09 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 6B5D7C0E3D for ; Tue, 4 Oct 2022 19:34:08 +0000 (UTC) X-FDA: 79984267776.18.EF0CDE3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id EC7D31A000F for ; Tue, 4 Oct 2022 19:34:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664912047; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4nzBQiXcgt3UF9Pzmx/yx9uJYBtOMvv3jFBGynNQW0E=; b=UTg/C/cGQWPjMgNX2nPW5K+BPM548NoAcP3aZejjIkAKjBxFcBQRlZ2oKC+dpVIso2Z3DD Nnltr6PTDa9tlDcDyo6zsMgV3p412UPtkfCh8Pkb2XlU8CED8SqvzSiIdqthelNt38fQ1I yOqS0nopnK5Ot77iBqx7sr2n6R45Sqo= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-577-_mQvLJicM7CskDn4CydUpA-1; Tue, 04 Oct 2022 15:34:06 -0400 X-MC-Unique: _mQvLJicM7CskDn4CydUpA-1 Received: by mail-qk1-f200.google.com with SMTP id bk21-20020a05620a1a1500b006be9f844c59so12412857qkb.9 for ; Tue, 04 Oct 2022 12:34:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=4nzBQiXcgt3UF9Pzmx/yx9uJYBtOMvv3jFBGynNQW0E=; b=ieZEU1h9CZTGCsBp+9x0hn25yXplfMqvp34MhV0UWv9ZlfojS96/YxqsUx9jbQlDgT tyepfjfkvnXRqFW2DOKQofRNZDppl46RUJ4+bOIigqFlphNVeFMsmmsYlG1YcORr6fwt rpJaT7kG9vnW6+jDy1ma/4MyE3722OASfTrDdtmPhBE7J6GBIqNbdMb/6HiFNtF7dEFM VPkKXeJA56UALS8+epvFiFuEA+QTwYCPEP0A2gHvt9CNqC6l0cYokA44hGf8kfFJVUbN icBiwGNLqOWUOOWQlQsVnGeIHEsxSGabmDV2XFIqyAGXMo7ffAUa9XC+RVaWz78hujUw OItQ== X-Gm-Message-State: ACrzQf2wDVqJ8yK6SV4wmBgYYhcEnWCg25Jhd+yatsOi0ODeVdpKHVyh +uZfLl/MrP63c6BkN7I+9nEJ92HUcsEeLn2eeEFHUkDSyEnonlOfa8Fgvw+kB6VjFSI/PwkdyGO 1nWK11WuwFneYO1OM7v2vLtrCsVPyrJnIy36RJZ5FfZLc50sHQIW6XGvmmzHB X-Received: by 2002:a05:622a:4c11:b0:35c:bbb2:d177 with SMTP id ey17-20020a05622a4c1100b0035cbbb2d177mr21244346qtb.314.1664912045541; Tue, 04 Oct 2022 12:34:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4kmipNt7Cgqge3wbSWm8qUnwYOKzrhBe+9IEVXWDGwMDz0ZKmsU4IruRK26u/ijQtioiyaFw== X-Received: by 2002:a05:622a:4c11:b0:35c:bbb2:d177 with SMTP id ey17-20020a05622a4c1100b0035cbbb2d177mr21244308qtb.314.1664912045240; Tue, 04 Oct 2022 12:34:05 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id z5-20020a05622a028500b00342fb07944fsm13299811qtw.82.2022.10.04.12.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 12:34:04 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Mike Rapoport , peterx@redhat.com, David Hildenbrand , Andrew Morton , Andrea Arcangeli , Nadav Amit , Axel Rasmussen , Mike Kravetz Subject: [PATCH v3 2/3] mm/hugetlb: Use hugetlb_pte_stable in migration race check Date: Tue, 4 Oct 2022 15:33:59 -0400 Message-Id: <20221004193400.110155-3-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221004193400.110155-1-peterx@redhat.com> References: <20221004193400.110155-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664912048; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4nzBQiXcgt3UF9Pzmx/yx9uJYBtOMvv3jFBGynNQW0E=; b=E3F5iX+K1f3X04jSSoERX5kvENiYcDqGTc+RnL+qySWopF6oK4T3AcMmTosOWQ6PO8brTP Y7/r18WquvTLauCjGICuSg2KCd6vCmE4e3tfQ3KTI97gB33wO0NsyidJjZvSyAjPJp0rkD 8yU+xA2Gi1fNaHU9wKbGdcgpvE+oteo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="UTg/C/cG"; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664912048; a=rsa-sha256; cv=none; b=dnVcWKyO8pBtBeiwwC8UhfNy8FwjNQyH2ky6VScxv2eIVoHdhbF0nEmgY4mG3EsrzarWFR 2Va7BvNFv+renMKREd5eWmBKEQfRaShaw9/RuKAA/ZPrcJI/lzjjZh8zARSdckhH9Ltw9W +aH+nPFXwbFZrz0AXDY3nflt9/MYTuk= X-Rspamd-Queue-Id: EC7D31A000F Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="UTg/C/cG"; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspam-User: X-Stat-Signature: afcea3tb34zt7qq5rkrjfmbdgop4b56k X-HE-Tag: 1664912047-109238 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: After hugetlb_pte_stable() introduced, we can also rewrite the migration race condition against page allocation to use the new helper too. Reviewed-by: Mike Kravetz Reviewed-by: David Hildenbrand Signed-off-by: Peter Xu --- mm/hugetlb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 1f059acc38f3..63fe47a0240a 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -5623,11 +5623,10 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm, * here. Before returning error, get ptl and make * sure there really is no pte entry. */ - ptl = huge_pte_lock(h, mm, ptep); - ret = 0; - if (huge_pte_none(huge_ptep_get(ptep))) + if (hugetlb_pte_stable(h, mm, ptep, old_pte)) ret = vmf_error(PTR_ERR(page)); - spin_unlock(ptl); + else + ret = 0; goto out; } clear_huge_page(page, address, pages_per_huge_page(h));