Message ID | 20221030212929.335473-4-peterx@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1972462wru; Sun, 30 Oct 2022 14:32:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7UBc+bFArV1QrOqV2bBeHuEz99UljyBQd3fTImc7CY0TRhPXxl0vm8HNTBlPsSeK3lYXNH X-Received: by 2002:a63:350:0:b0:44c:2476:12ff with SMTP id 77-20020a630350000000b0044c247612ffmr10009402pgd.50.1667165525129; Sun, 30 Oct 2022 14:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667165525; cv=none; d=google.com; s=arc-20160816; b=t6aEKFNGahVj0KEOISoUG/tR0dI7dnnAHUtTsCLn+B+YIFsCxoNXclY9hs+JM2QMR3 QviQeVXzcIXfZrl5xl9w3CzEt3jZtllsBsPueC6F3OmeEr5UD8qCWouCWmL9+e+26oTM 88Qs1O3OT+tDdcOy3z7fOw4FoHrn3jJTPlDFGXkXw613e8jptd7oOnPUoqBr3TK/ZZ+2 peQGW1DnqiySyOqf3SUQfEVak3YTDXCVyb5ntK6Hdj9GKwOeoR4ysPyHrCZjVWwbrNet 1wzz5tXmg7ZuW8MPJ9wcoRxQOfu3oA4Hgxtlejput2cerhtv3MyuK+48yfsgy/EajBZi AW1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wagvClDr96VqW50v7EvOelntcB2vHhVhi8l6aUJsy+c=; b=NaQLytRjHLr3Vd7TLD4XTYlW132mIlQuaX2pm6iehABB4bLtD2YcEZh2VRsym5h2/J cmlwswtzmvGem6Hv4zCmaoWfjI4GTGBC1x0pIfWonKQ1Krg52mVKxrytcnp0C/y5leiC X7y8cluB1+EInO2iklIAvCq5OZmR5RySgN8fXtY6fMlBpa04MyMfPvjni/aOXKDiP0pV rkUfEgZ0d6VS/Lwno2nz/jmY1czZG0Unxpw9IR9D6Lx42Jx7eXzNTwoD35Lt4knHAttH yUH0pdML6zg1nECL7zQK1WmeO0mnipEniFhQ71SmoDe7MSSPNraZ93o3oFq4moMTzMcN Vqmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ento34bf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pq5-20020a17090b3d8500b001fe1c9436b1si6533742pjb.86.2022.10.30.14.31.52; Sun, 30 Oct 2022 14:32:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ento34bf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229770AbiJ3Van (ORCPT <rfc822;makky5685@gmail.com> + 99 others); Sun, 30 Oct 2022 17:30:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbiJ3Vag (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 30 Oct 2022 17:30:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0CDEA1A2 for <linux-kernel@vger.kernel.org>; Sun, 30 Oct 2022 14:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667165380; 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=wagvClDr96VqW50v7EvOelntcB2vHhVhi8l6aUJsy+c=; b=Ento34bfcoEHMbFUVUOCg31FX7uM/ax295P8Y1/3QXPs8X+T8nNyFqtijJAaJBm6onyiJK sSHA310fpO4p72xxZnGsD+d+P4G90nrKm7TZKEGIIsYKRRGu26jfXQrbu5+kMqyQqIh2B2 tJUUVVHoLWiCgLMgAdz1UoFSJmUvzZY= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-458-crETd6G8NlypahQZeKVAnA-1; Sun, 30 Oct 2022 17:29:38 -0400 X-MC-Unique: crETd6G8NlypahQZeKVAnA-1 Received: by mail-qt1-f197.google.com with SMTP id fp9-20020a05622a508900b003a503ff1d4cso5118129qtb.22 for <linux-kernel@vger.kernel.org>; Sun, 30 Oct 2022 14:29:38 -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:message-id:reply-to; bh=wagvClDr96VqW50v7EvOelntcB2vHhVhi8l6aUJsy+c=; b=lWvpk+lu9CsX+oW1BccnEs2RyoCD3LwUAZHETZlUh8dTC+s0vFVYdnXJmJvlpdG+n7 Pb6qaDfiVHCcpL1NegUalfncL+0fI3os3jK1HMeikkrJGSVTpwTRJiYtqGOtzoCaxAb4 g7VUQjiimYdm0saLsr+ABs/VLcVTii0b/7I+dbc1Y+710KFn8Hz8AoQxJ9WKKft3gc3V ghIvAR+mqtiNO0t96zCt+Rkg6vExa9KCmMv6cQtMF2Kdu0CVqtZoTWVgAR8v7fhg97Wo 3N8Tkr/4GZg7NxCe7rxgTwsSUydsnDZhOTT8KCR3UVJICgyiXwMaQxKwe7rdfR4Lhoo8 L7IQ== X-Gm-Message-State: ACrzQf3zBcLTPK3wQm6GyxAePxP+WpuwjNXxxZjenFsHwfc6PZ3aDsKE Zdm0MgGFzJxSaPwariv4YQyecMvpcApdYFfQ1Cd6qh3Lw7EkwoZAR3GLqbiyA9W06Hjf7AJ8ugc PwDPj2n0CX3S2ukgOuZxcbsWCl8negb0kx+e4E2+HCVK4kIk9N9m/AfAsGaJr/rTb5WDa2A8PKw == X-Received: by 2002:a05:620a:270e:b0:6df:7dba:f45a with SMTP id b14-20020a05620a270e00b006df7dbaf45amr6855707qkp.661.1667165377674; Sun, 30 Oct 2022 14:29:37 -0700 (PDT) X-Received: by 2002:a05:620a:270e:b0:6df:7dba:f45a with SMTP id b14-20020a05620a270e00b006df7dbaf45amr6855682qkp.661.1667165377401; Sun, 30 Oct 2022 14:29:37 -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 a1-20020ac81081000000b003a4b88b886esm2654781qtj.96.2022.10.30.14.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Oct 2022 14:29:36 -0700 (PDT) From: Peter Xu <peterx@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Andrew Morton <akpm@linux-foundation.org>, James Houghton <jthoughton@google.com>, Miaohe Lin <linmiaohe@huawei.com>, David Hildenbrand <david@redhat.com>, Muchun Song <songmuchun@bytedance.com>, Andrea Arcangeli <aarcange@redhat.com>, Nadav Amit <nadav.amit@gmail.com>, Mike Kravetz <mike.kravetz@oracle.com>, peterx@redhat.com, Rik van Riel <riel@surriel.com> Subject: [PATCH RFC 03/10] mm/hugetlb: Make hugetlb_vma_maps_page() RCU-safe Date: Sun, 30 Oct 2022 17:29:22 -0400 Message-Id: <20221030212929.335473-4-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221030212929.335473-1-peterx@redhat.com> References: <20221030212929.335473-1-peterx@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748149757963094090?= X-GMAIL-MSGID: =?utf-8?q?1748149757963094090?= |
Series |
mm/hugetlb: Make huge_pte_offset() thread-safe for pmd unshare
|
|
Commit Message
Peter Xu
Oct. 30, 2022, 9:29 p.m. UTC
RCU makes sure the pte_t* won't go away from under us. Please refer to the
comment above huge_pte_offset() for more information.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
fs/hugetlbfs/inode.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index ac3a69fe29c3..b9e7825079c7 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -387,21 +387,26 @@ static bool hugetlb_vma_maps_page(struct vm_area_struct *vma, unsigned long addr, struct page *page) { pte_t *ptep, pte; + bool result = false; + + /* For huge_pte_offset() */ + rcu_read_lock(); ptep = huge_pte_offset(vma->vm_mm, addr, huge_page_size(hstate_vma(vma))); if (!ptep) - return false; + goto out; pte = huge_ptep_get(ptep); if (huge_pte_none(pte) || !pte_present(pte)) - return false; + goto out; if (pte_page(pte) == page) - return true; - - return false; + result = true; +out: + rcu_read_unlock(); + return result; } /*