Message ID | 7ae6836b-b612-23f1-63e0-babda6e96e2c@google.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 3C7B7EB64DC for <linux-mm@archiver.kernel.org>; Tue, 20 Jun 2023 07:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D1F7F8D0002; Tue, 20 Jun 2023 03:45:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD02C8D0001; Tue, 20 Jun 2023 03:45:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B988F8D0002; Tue, 20 Jun 2023 03:45:34 -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 A9D328D0001 for <linux-mm@kvack.org>; Tue, 20 Jun 2023 03:45:34 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7ECD81C8427 for <linux-mm@kvack.org>; Tue, 20 Jun 2023 07:45:34 +0000 (UTC) X-FDA: 80922341388.16.C6D6FA9 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf07.hostedemail.com (Postfix) with ESMTP id AA0884000B for <linux-mm@kvack.org>; Tue, 20 Jun 2023 07:45:32 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=jZI7lGkG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687247132; 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:in-reply-to:references:references:dkim-signature; bh=7tbEFbFk5pzLjwVra+37SCseEW8dJexk2Np2YDtZH+c=; b=IVfMx+SFh5oRs65A789JtE0p23vi3jRI5KZeRokV15wIZd86pGhGxW8YkALYAD8pVYlMik 8FHiLL4BYKwvgxWNtBI2H0UkT86dG5tDtEqXuq6Jvn11SeV3HARm4uuY/g5npFsVVMnplP OQj647qR1JXUK5PrBM5anGCFj8uOXx4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=jZI7lGkG; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf07.hostedemail.com: domain of hughd@google.com designates 209.85.128.182 as permitted sender) smtp.mailfrom=hughd@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687247132; a=rsa-sha256; cv=none; b=bTm74q3c2u9qjwADLZXKxtYEaDZFlhky2obLy3xAEP8dugrZlN1MMzFjkq6NseZl4L9Tjw Ofr2RbgXhAOzMxGn9+YzFhYs1blKO+GtHGdLAoPsgPuqkLagCsjagSzWtcOAifM850zgvD 7ZWRVJ6nZEywxE5zBWWmn73gz5/Lqzg= Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-5701810884aso39616777b3.0 for <linux-mm@kvack.org>; Tue, 20 Jun 2023 00:45:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687247132; x=1689839132; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=7tbEFbFk5pzLjwVra+37SCseEW8dJexk2Np2YDtZH+c=; b=jZI7lGkGOA9VplRFSG9/39QEHLqEHFn81AVfRltHoq/8iNx7aAWlNrNyFe+XyF0lml Bnzro2qd7JBTjoGR7k3DplV7l1biYn3/LoxKNyegFiBFIRoYqaL2y+rd8Ux0pQmhTgvs IUPCYgX4z0WdKLSspIafzLUn3c05nMTizwc56jirtYHMfRSc/oqFfK7oTa/fwkNDoThq 2HdR/Am0ViDDg3zBY7MZWP/MVjmD1Yx9xMfwqoDnIfAkP9LmxM3rFBDQvW9AFIfnglmj paE2iSuMCCu/tpYLxht5C/v0kudDdPO6A0RSV0ftjBtK/MFrCHoTJHxirOjy2uYrAODS XFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247132; x=1689839132; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7tbEFbFk5pzLjwVra+37SCseEW8dJexk2Np2YDtZH+c=; b=DUscB6R2mnAwYuaCyj+dEedYoXXyK+UkRmtJcNV96kMfU89LXzg+VopOWeILOVoTOM mfZJPKNikV1e7+r/+NZQLsTJOZSGIY8ONlJQvt3h1fMQeZYN3FSE2fdOuWt2ImxWC9Vb BxqISAryHmaSqVcESVF4+4gu79DJDP3dlBHwP8l33GSEqZEfawDmZuwdoSZnLGTy2KOK Cf3OZPjSUySHOGuHRHEIi462XQ0kwxIX8RKWHUXftv5NF6PDpxRLh/keDtWz7AabEdIk RVsv846I8E2Oq0rXARCd93OIyvGVnwOFG/mQey1kp11K7PITVlcgHDysYfok6icW/RlS 4xYg== X-Gm-Message-State: AC+VfDwjWLHHT5Hw8zymHaLixgQfKqX8G5Uf6F/iNFWWOqN0E0eBtH34 LafK1x5leK2DkaJ8nketvXqHFw== X-Google-Smtp-Source: ACHHUZ6lVvN31sBriyHtQUo4iIlWjUc8vgsx+qnIrz5Kb8Jhe8UJO9QGV+cM44ErYZUti1LdEdlZpw== X-Received: by 2002:a81:7189:0:b0:54f:9cd0:990 with SMTP id m131-20020a817189000000b0054f9cd00990mr2846044ywc.18.1687247131680; Tue, 20 Jun 2023 00:45:31 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id o9-20020a0dcc09000000b0056d2fce4e09sm379759ywd.42.2023.06.20.00.45.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:45:31 -0700 (PDT) Date: Tue, 20 Jun 2023 00:45:26 -0700 (PDT) From: Hugh Dickins <hughd@google.com> X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton <akpm@linux-foundation.org> cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>, Vasily Gorbik <gor@linux.ibm.com>, Mike Kravetz <mike.kravetz@oracle.com>, Mike Rapoport <rppt@kernel.org>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Matthew Wilcox <willy@infradead.org>, David Hildenbrand <david@redhat.com>, Suren Baghdasaryan <surenb@google.com>, Qi Zheng <zhengqi.arch@bytedance.com>, Yang Shi <shy828301@gmail.com>, Mel Gorman <mgorman@techsingularity.net>, Peter Xu <peterx@redhat.com>, Peter Zijlstra <peterz@infradead.org>, Will Deacon <will@kernel.org>, Yu Zhao <yuzhao@google.com>, Alistair Popple <apopple@nvidia.com>, Ralph Campbell <rcampbell@nvidia.com>, Ira Weiny <ira.weiny@intel.com>, Steven Price <steven.price@arm.com>, SeongJae Park <sj@kernel.org>, Lorenzo Stoakes <lstoakes@gmail.com>, Huang Ying <ying.huang@intel.com>, Naoya Horiguchi <naoya.horiguchi@nec.com>, Christophe Leroy <christophe.leroy@csgroup.eu>, Zack Rusin <zackr@vmware.com>, Jason Gunthorpe <jgg@ziepe.ca>, Axel Rasmussen <axelrasmussen@google.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Pasha Tatashin <pasha.tatashin@soleen.com>, Miaohe Lin <linmiaohe@huawei.com>, Minchan Kim <minchan@kernel.org>, Christoph Hellwig <hch@infradead.org>, Song Liu <song@kernel.org>, Thomas Hellstrom <thomas.hellstrom@linux.intel.com>, Russell King <linux@armlinux.org.uk>, "David S. Miller" <davem@davemloft.net>, Michael Ellerman <mpe@ellerman.id.au>, "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>, Heiko Carstens <hca@linux.ibm.com>, Christian Borntraeger <borntraeger@linux.ibm.com>, Claudio Imbrenda <imbrenda@linux.ibm.com>, Alexander Gordeev <agordeev@linux.ibm.com>, Jann Horn <jannh@google.com>, Vishal Moola <vishal.moola@gmail.com>, Vlastimil Babka <vbabka@suse.cz>, linux-arm-kernel@lists.infradead.org, sparclinux@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 04/12] powerpc: assert_pte_locked() use pte_offset_map_nolock() In-Reply-To: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> Message-ID: <7ae6836b-b612-23f1-63e0-babda6e96e2c@google.com> References: <54cb04f-3762-987f-8294-91dafd8ebfb0@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: AA0884000B X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: f5s44m7g8hqjcrg8wsyxs7ucp5apms9g X-HE-Tag: 1687247132-613256 X-HE-Meta: U2FsdGVkX18J7WXDzkDQI/s00/Rnh7uA0A1igJTP6oswuDMX8CASfdrS8tA9g8q5dwpsiF7RtckYsH6yaJOE+6v4OZIYfAAVsn/uOTaycYid8uQc7RqZXAqL0xplpjLr2YFxy7rEs9LB1gEliL0JD7nhFg4XG6fRGPslsj/XWqmLzRSscSdfw++crwFFmVPcYINpcgRaCOEGAvwTc9LUk2oDQeJITeAgTcLoZbFhlyioRZhKSeKKlETEChyUH3AHV+BgibYdMp+4fsgqZbkgslkS3Cwrt9OsI2TbIrfGzd2N5DxvRZ4PZM3hC/fVdma/nHVbwB3bgOWtVDVzk1rulSBfKuiAjKGy9htqKwqosAYAQ6MMS/qHg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9Dq+M0m/leh+e0eU3HA08JF8vQaVGM+3fUtZUf0F3+qyb 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: free retracted page table by RCU
|
expand
|
diff --git a/arch/powerpc/mm/pgtable.c b/arch/powerpc/mm/pgtable.c index cb2dcdb18f8e..16b061af86d7 100644 --- a/arch/powerpc/mm/pgtable.c +++ b/arch/powerpc/mm/pgtable.c @@ -311,6 +311,8 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr) p4d_t *p4d; pud_t *pud; pmd_t *pmd; + pte_t *pte; + spinlock_t *ptl; if (mm == &init_mm) return; @@ -321,16 +323,10 @@ void assert_pte_locked(struct mm_struct *mm, unsigned long addr) pud = pud_offset(p4d, addr); BUG_ON(pud_none(*pud)); pmd = pmd_offset(pud, addr); - /* - * khugepaged to collapse normal pages to hugepage, first set - * pmd to none to force page fault/gup to take mmap_lock. After - * pmd is set to none, we do a pte_clear which does this assertion - * so if we find pmd none, return. - */ - if (pmd_none(*pmd)) - return; - BUG_ON(!pmd_present(*pmd)); - assert_spin_locked(pte_lockptr(mm, pmd)); + pte = pte_offset_map_nolock(mm, pmd, addr, &ptl); + BUG_ON(!pte); + assert_spin_locked(ptl); + pte_unmap(pte); } #endif /* CONFIG_DEBUG_VM */
Instead of pte_lockptr(), use the recently added pte_offset_map_nolock() in assert_pte_locked(). BUG if pte_offset_map_nolock() fails: this is stricter than the previous implementation, which skipped when pmd_none() (with a comment on khugepaged collapse transitions): but wouldn't we want to know, if an assert_pte_locked() caller can be racing such transitions? This mod might cause new crashes: which either expose my ignorance, or indicate issues to be fixed, or limit the usage of assert_pte_locked(). Signed-off-by: Hugh Dickins <hughd@google.com> --- arch/powerpc/mm/pgtable.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)