Message ID | 20221118011025.2178986-8-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 C9F35C4332F for <linux-mm@archiver.kernel.org>; Fri, 18 Nov 2022 01:10:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C495D8E0008; Thu, 17 Nov 2022 20:10:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B34D98E0005; Thu, 17 Nov 2022 20:10:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 910618E0008; Thu, 17 Nov 2022 20:10:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 742F58E0005 for <linux-mm@kvack.org>; Thu, 17 Nov 2022 20:10:42 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 47E9181206 for <linux-mm@kvack.org>; Fri, 18 Nov 2022 01:10:42 +0000 (UTC) X-FDA: 80144783124.09.C946769 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id BEF06A0012 for <linux-mm@kvack.org>; Fri, 18 Nov 2022 01:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668733841; 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=M2c5rXQnd1kf7yTmDBDfaoawKYfDXFaD9281dnoZiZE=; b=D/ZZJvo5cGIr+uUmeTgrRoZ0Ej9vbFPHSteEslytmFJOZyUHrbzacAJkje03m0a5a47Nhp +XDxndNjO/PCTUR6Yfso5ZHufW3VXigcEQJQ6kTAXx/qtKGUQt5FgHRP/HYlP3gcZQ5GOF GYAbE0FIVOfVk1JN6J1sSYH1bwjDIQs= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-581-0DT8o0baOPSZJesFdGPnOQ-1; Thu, 17 Nov 2022 20:10:40 -0500 X-MC-Unique: 0DT8o0baOPSZJesFdGPnOQ-1 Received: by mail-qv1-f72.google.com with SMTP id mo15-20020a056214330f00b004b96d712bccso3255308qvb.22 for <linux-mm@kvack.org>; Thu, 17 Nov 2022 17:10:40 -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=M2c5rXQnd1kf7yTmDBDfaoawKYfDXFaD9281dnoZiZE=; b=MYfcWhWZqwkdzwPSXJ9phkvcaEEXfH1yTcWIGEGA6lKkA8yorbDxdeCL7laqLwjldu gIWP5irmrDZMqrF8phLSdlJtl7UPLyqA+CjREbPkhQDYGQ2p3eoeQPD+TY231TmM7BSs Gu84qq+FDC9g7iThlmoCXFc1w3GfxoJdfylzmlD3DvcRnHjF2RfFuW7+YFQfHM+prJkg jk02bw06GjRq17OpVkx/FWg841Z/qtNskXT0WLFaYEsUA1Fs97/VAdK1c6VWDvRan15b Ev5TrmgXjmt6AAX5i9staphIPTyNdUYwUMdFrEIk/6h+SQMropKCXqI6T+s7qiQ3H1Q1 Bqiw== X-Gm-Message-State: ANoB5plrc6cWIpzz56+WqPwHAevHLtJ2dKIIHHUPoRanmPWx6CyAsk1D Db4AilVzaMzfDQR+Uf8eXIRhCccZ2WIQEZvJsK9kUNGN/ucaNLGHFdeDwbtsqw9dXQPQHtbKVdP 6T8hYeUMCK0Auc/P8+fyj9jKPPbxr3pn0A03hoYnaKtIc/zIityq3RK0CZuuz X-Received: by 2002:a05:620a:10a3:b0:6fa:156e:44c0 with SMTP id h3-20020a05620a10a300b006fa156e44c0mr4093375qkk.293.1668733839464; Thu, 17 Nov 2022 17:10:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KpYFuSckUVSGa4lgr9LFNowF9nCCUTnXJySXZCtSwHy4gRXenmckPtcF9nzTIBjvTUthQDw== X-Received: by 2002:a05:620a:10a3:b0:6fa:156e:44c0 with SMTP id h3-20020a05620a10a300b006fa156e44c0mr4093352qkk.293.1668733839139; Thu, 17 Nov 2022 17:10:39 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 17:10:38 -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 07/12] mm/hugetlb: Use hugetlb walker lock in hugetlb_follow_page_mask() Date: Thu, 17 Nov 2022 20:10:20 -0500 Message-Id: <20221118011025.2178986-8-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=1668733841; a=rsa-sha256; cv=none; b=q+lv8Xlwqa2rfO2WkE6Egw5CxMvRbLNFccNJ7re1ibC1LjP7CRxUZ4fPSvm+W9mMxXTkel 3A55KeOS9qolai/+paoVeih26CpqZj0u88xZUZzExcMVDKp0diOYijHuieVfOdvalHM3yy rl9edW8ORt6CkAh2eVqKAcu0e8zDzKU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/ZZJvo5"; spf=pass (imf25.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668733841; 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=M2c5rXQnd1kf7yTmDBDfaoawKYfDXFaD9281dnoZiZE=; b=AR0uuIn7/W/z5vjS44w9G8IcyBYI6yuf/PijSnE8r1g4pUfP9VNestj7BE4psGqSqVkXXx cmD6uApCJ1vDIMGmcc/86D0ZKjbjeoX+asJHGvktFyHK76UeykfgaIFb78kgQZL9mhO8zz kFF6U3cb/v1CxqcTbqFBqOdzreCpZOM= X-Stat-Signature: sa5j7r9popxbj45krbmosn8n3c35ghg8 X-Rspamd-Queue-Id: BEF06A0012 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="D/ZZJvo5"; spf=pass (imf25.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: rspam04 X-Rspam-User: X-HE-Tag: 1668733841-122053 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/mm/hugetlb.c b/mm/hugetlb.c index 5ef883184885..fc49e3ca8acd 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6222,9 +6222,10 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, if (WARN_ON_ONCE(flags & FOLL_PIN)) return NULL; + hugetlb_walker_lock(); pte = huge_pte_offset(mm, haddr, huge_page_size(h)); if (!pte) - return NULL; + goto out_unlock; ptl = huge_pte_lock(h, mm, pte); entry = huge_ptep_get(pte); @@ -6247,6 +6248,8 @@ struct page *hugetlb_follow_page_mask(struct vm_area_struct *vma, } out: spin_unlock(ptl); +out_unlock: + hugetlb_walker_unlock(); return page; }
Hugetlb walker lock makes sure the pte_t* won't go away from under us. Signed-off-by: Peter Xu <peterx@redhat.com> --- mm/hugetlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)