Message ID | 20221118011025.2178986-10-peterx@redhat.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 2B473C433FE for <linux-mm@archiver.kernel.org>; Fri, 18 Nov 2022 01:10:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9B058E000A; Thu, 17 Nov 2022 20:10:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A22178E0005; Thu, 17 Nov 2022 20:10:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 825198E000A; Thu, 17 Nov 2022 20:10:45 -0500 (EST) 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 6F6788E0005 for <linux-mm@kvack.org>; Thu, 17 Nov 2022 20:10:45 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4C491A084E for <linux-mm@kvack.org>; Fri, 18 Nov 2022 01:10:45 +0000 (UTC) X-FDA: 80144783250.13.85AC971 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id E84D0180003 for <linux-mm@kvack.org>; Fri, 18 Nov 2022 01:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668733844; 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=ap7neQhploF5O2byy6eWIJyWsli20vMRANWIX9Kzu5I=; b=P1IX7psOa/NnYfYPqPJ1kd126SeNdbqEdLG3F67xKHFwx82gdpYlvjqYnUVIxhuiv7MJPj fa80cpwvPLKMbRwzghTDILBdNXnT0yTkhBMIBhHW9MBmyniD/aIcafM7KrdltGg0Cu3/14 IxWVERb6Lf3sVcFuqRx73T8dkoExFLw= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-594-sEibE29kM5es_afH7Tm_Og-1; Thu, 17 Nov 2022 20:10:43 -0500 X-MC-Unique: sEibE29kM5es_afH7Tm_Og-1 Received: by mail-qt1-f200.google.com with SMTP id f4-20020a05622a114400b003a57f828277so3424377qty.22 for <linux-mm@kvack.org>; Thu, 17 Nov 2022 17:10:43 -0800 (PST) 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=ap7neQhploF5O2byy6eWIJyWsli20vMRANWIX9Kzu5I=; b=U720Rk7tQXk2EZep4ylwTAZ0CZxk9BpNn4mkofKGh6UdT2RNRaHaQr1xwMFr+A9bRB rlBgArjCrfsWaUBjUokA6KTF4NXeNZFdlzSuOvozT11pc9DSbZPchxhqz3aJn1ZarIN2 qQmSOWKjbunPd/QIrLiq0QDivooTyHJSRZEy6KBtDzQss0xhji2VO4g/Qg0i2a+mFSus 71DM3c4D3QfAsWYuJ9HdP8O+gi93ANfN4I/lK2ld/XpPwWkGdf+msWA1iLn2Ela+ND5Z ozrZXTccvt/iyHSV4faEJvDaFcMTD0NnVe+1xzoj8GG7ui0JXxNFuBq2FlyfMMxDGKK+ 6HOw== X-Gm-Message-State: ANoB5pldM3DwrR+gdvhhsdypcoUtkEziG+nItNitIy9GkGttSfNfyUwq RAfeykrDCo+dghDxyR2pFwsrATkQRv6CXarqXIDITGoLE+XKAN2MmPG789RVPm29fM2/y1K5fPY g/orjbc/TaQ+5KgdrUdyUBTIDZA13hEFXGawVIhUHDfWRxqw/nVK7BEoWyLey X-Received: by 2002:a0c:c682:0:b0:4c6:80d9:844d with SMTP id d2-20020a0cc682000000b004c680d9844dmr4921265qvj.34.1668733842432; Thu, 17 Nov 2022 17:10:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ri6W+Ys/uE6Yihgvm71dHXQ64Qx2xPRu/QHx/egaYRiWuxzZqmcFd9on3+WOH893ouf3hGw== X-Received: by 2002:a0c:c682:0:b0:4c6:80d9:844d with SMTP id d2-20020a0cc682000000b004c680d9844dmr4921236qvj.34.1668733842116; Thu, 17 Nov 2022 17:10:42 -0800 (PST) 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 u7-20020a05620a430700b006eed75805a2sm1491342qko.126.2022.11.17.17.10.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 17:10:41 -0800 (PST) From: Peter Xu <peterx@redhat.com> To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Rik van Riel <riel@surriel.com>, Muchun Song <songmuchun@bytedance.com>, Andrew Morton <akpm@linux-foundation.org>, peterx@redhat.com, James Houghton <jthoughton@google.com>, Nadav Amit <nadav.amit@gmail.com>, Andrea Arcangeli <aarcange@redhat.com>, David Hildenbrand <david@redhat.com>, Miaohe Lin <linmiaohe@huawei.com>, Mike Kravetz <mike.kravetz@oracle.com> Subject: [PATCH RFC v2 09/12] mm/hugetlb: Use hugetlb walker lock in hugetlb_vma_maps_page() Date: Thu, 17 Nov 2022 20:10:22 -0500 Message-Id: <20221118011025.2178986-10-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221118011025.2178986-1-peterx@redhat.com> References: <20221118011025.2178986-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain Content-Transfer-Encoding: 8bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668733845; a=rsa-sha256; cv=none; b=pIpm7NTjERExPH16U3/SaqPMROS/o8itCR8OXxrVLf6XOJxMMKJzzy+A+16QWkOPz9dM7Y siUa49WBHFjppD62O4cN7dK7V8/cPDP7f1IJ+C5/LuS/PU0hSWeoDW4Q8hVOwxipLCYnID QjotQplytLj0IwSo0ntYW/Mlzjp0bJY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P1IX7psO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668733845; 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=ap7neQhploF5O2byy6eWIJyWsli20vMRANWIX9Kzu5I=; b=TVkuGywXH1MVttN86XmsbONXzdaqIPIrqNCWKs8rQdBjajjU2SF7VTzxp4DydEb+qcok+F DQmd+NDQf1r90SV08g8aKD4v9WLKs2k4xPap0zytv72ch0h0dqehKOuNGRgHGT+3emXOEr KxEezkC8bLOKAi9aPKDveTKhhJ9zrCk= Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=P1IX7psO; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Stat-Signature: qnwb8omo3mgciu4n5oozryzh7m8mg5pd X-Rspamd-Queue-Id: E84D0180003 X-Rspamd-Server: rspam11 X-HE-Tag: 1668733844-118745 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: <linux-mm.kvack.org> |
Series |
mm/hugetlb: Make huge_pte_offset() thread-safe for pmd unshare
|
expand
|
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index fdb16246f46e..265508981ba1 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -387,21 +387,24 @@ static bool hugetlb_vma_maps_page(struct vm_area_struct *vma, unsigned long addr, struct page *page) { pte_t *ptep, pte; + bool result = false; + hugetlb_walker_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: + hugetlb_walker_unlock(); + return result; } /*
Hugetlb walker lock makes sure the pte_t* won't go away from under us. Signed-off-by: Peter Xu <peterx@redhat.com> --- fs/hugetlbfs/inode.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)