Message ID | 9df4aba7-fd2f-2da3-1543-fc6b4b42f5b9@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1213496vqo; Sun, 21 May 2023 22:10:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4zAipxNnCXKJo1CDQa04/zhbXCWjpgPg54orRi+U9HKjn0nkScU6fZBLM9XrRyRTD4YmFl X-Received: by 2002:a05:6a00:248a:b0:64d:5b4b:8429 with SMTP id c10-20020a056a00248a00b0064d5b4b8429mr5986283pfv.18.1684732248108; Sun, 21 May 2023 22:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684732248; cv=none; d=google.com; s=arc-20160816; b=sE9jSXmk2tz/3cu1GXwTy2UBeiwJw0kySdiP9l/Tmi2JI/R83onaNtEYG0eYFmHaYl uxQ7/ID8FA9hSX6jUHzrY30ViYnDrqgncoq+edJ2J4eT+Q4iCzDWLCURkv7ujqR5FpWx 42vu1+xVhcq1pnlND/mv79hfVKe9bwBlUQtvUqPZt53SZ2sBTh5kOfQa4aht9MvoJVg5 CAg9YDvknMoCorXK837OgkUkkmi7PKAK8HP9xEo+SZByLUBDYZS1W6uD0MGy9+H2q84/ HYWQ76pNvlHFEOAv8kP/AcCDDXlb4Z8uhS4e8lY2RgqMluitQjea7FkZzMWy3N3jTiF6 04Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=lc/g6LXQOs93yTgCiGczTkkFK+sAgodNjTysgahDEVw=; b=nT02dSA9+lxiKlWo0eaVNA+5NxKKoUzNMFPA8pk1l1dPGYweBUeKEGGJw4k6XBIFns mWLwzbDf0FndutMRnOuGsVUae/lQU4Kr4ifyV4JMjkxa2SxvieRUZUnVvm9TnZTJ1o02 IgfKk7WgRE+zBKYOwNcLYtjcFJJQGLyMiN+dyZTop5jRz4kSF6X1LXfmX3pSqOYqdK85 LkV0H84E5V6070eRbb8+FAoWppc21ov1HGaP1QUaxddT+T8rlZEc2a4c++jE205l3iZO aMESL0mkOy/JKm5fUII27JZ+7ctFgBEF5y0U1O9xybX068nTtSF8XVt6R7WZDNQWo19V Di+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=y0KD6rBK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h187-20020a6253c4000000b00643b54acbd0si4057089pfb.231.2023.05.21.22.10.36; Sun, 21 May 2023 22:10:48 -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=@google.com header.s=20221208 header.b=y0KD6rBK; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231516AbjEVEwi (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Mon, 22 May 2023 00:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjEVEwg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 00:52:36 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C634BBB for <linux-kernel@vger.kernel.org>; Sun, 21 May 2023 21:52:35 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-561bcd35117so70007567b3.3 for <linux-kernel@vger.kernel.org>; Sun, 21 May 2023 21:52:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684731155; x=1687323155; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=lc/g6LXQOs93yTgCiGczTkkFK+sAgodNjTysgahDEVw=; b=y0KD6rBKhVlt+/hQTMgxrgHr2ryOWmswWrxwVwW1aFZ79LkRBOC59dixF5L/cDZc4B qnUQhKlaq1KoTySTp2vqiuM8rApR8HI8YhApmutmEIgesAjWn3Zc6GfqRJFCVIZETmFo Ve2TuK1DkPJI4FLOOGkjpX3SgGZwTv9PexqmJixY6pwUW+8F8Muuz17KmV5M/4+hZQ/g NOfOuuy9xT5Aq5lXVwksnHlv6Vlink7vPREGhAD7sqE7v5xbbRTG+tMaRpWIb/f65tVQ 6KthNz49DESDlvL8PCw3g3sz72EdxO0SmuuSbMBDwQ700O/IFokzhDePdlcNOBT1Ipvs 7n6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684731155; x=1687323155; 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=lc/g6LXQOs93yTgCiGczTkkFK+sAgodNjTysgahDEVw=; b=X/aaKhL6/S0/F2VAAvvi6H28sfJbZ2k889yvEb/LN3q7gcsUz9VoRnVvoBV25qKH70 zuLXGW0rL9YGWxlNH1IsPJhnPS4FJK9Z5a95TlIQNUI3NS3cIA6UGF1WbQIavO3u/Qw/ E5TJxpxpZgt25xJEMCUfh34VZaFGXtwyLydeLQjPTeX2zvnWSWsKE/xbI1Qs+JldE6t/ TeLrebYA9wHbQzbXjGw1UH5oCjNhp+5lPqTVXRzWVGUNEq08smkIbC1QQriUQkAkMJBy BREWWOSwAzWiY3Q/xm7eXqmZ3CwYbWS1H08lUycRvvYweSCGDhN+SBu8arqFhFKQh5rE TUug== X-Gm-Message-State: AC+VfDwhrP3DRIYXNxaLLRcx6TvOsbWIWKvuEsOKLXzJu0PZhKxr/Zku fGhyndr5mdqWa8EWXpDnfR/HhA== X-Received: by 2002:a0d:d901:0:b0:55a:9e43:7efe with SMTP id b1-20020a0dd901000000b0055a9e437efemr10375067ywe.44.1684731154895; Sun, 21 May 2023 21:52:34 -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 w6-20020a814906000000b0054f8b201c70sm1786111ywa.108.2023.05.21.21.52.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 21:52:34 -0700 (PDT) Date: Sun, 21 May 2023 21:52:31 -0700 (PDT) From: Hugh Dickins <hughd@google.com> X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton <akpm@linux-foundation.org> cc: 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>, 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>, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/31] mm/pgtable: kmap_local_page() instead of kmap_atomic() In-Reply-To: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> Message-ID: <9df4aba7-fd2f-2da3-1543-fc6b4b42f5b9@google.com> References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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?1766569801757853285?= X-GMAIL-MSGID: =?utf-8?q?1766569801757853285?= |
Series |
mm: allow pte_offset_map[_lock]() to fail
|
|
Commit Message
Hugh Dickins
May 22, 2023, 4:52 a.m. UTC
pte_offset_map() was still using kmap_atomic(): update it to the
preferred kmap_local_page() before making further changes there, in case
we need this as a bisection point; but I doubt it can cause any trouble.
Signed-off-by: Hugh Dickins <hughd@google.com>
---
include/linux/pgtable.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Sun, May 21, 2023 at 09:52:31PM -0700, Hugh Dickins wrote: > pte_offset_map() was still using kmap_atomic(): update it to the > preferred kmap_local_page() before making further changes there, in case > we need this as a bisection point; but I doubt it can cause any trouble. > > Signed-off-by: Hugh Dickins <hughd@google.com> > --- > include/linux/pgtable.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 8ec27fe69dc8..94235ff2706e 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -96,9 +96,9 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address) > > #if defined(CONFIG_HIGHPTE) > #define pte_offset_map(dir, address) \ > - ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \ > + ((pte_t *)kmap_local_page(pmd_page(*(dir))) + \ > pte_index((address))) > -#define pte_unmap(pte) kunmap_atomic((pte)) > +#define pte_unmap(pte) kunmap_local((pte)) > #else > #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address)) > #define pte_unmap(pte) ((void)(pte)) /* NOP */ (I think this could be a dumb question if this patch has been running there for years downstream, but still..) I assume one major difference of using kmap_local() is page fault will not be disabled, while kmap_atomic() will. Meanwhile, pte_offset_map() is also used by pte_offset_map_lock(), which means before this patch CONFIG_HIGHPTE systems will disable pgfault before taking pgtable lock for it, while it will stop doing so after the change. Then what happens if a page fault happens on the same pgtable lock range that is already taken by the thread context? What stops the deadlock from happening? Thanks,
On Fri, May 26, 2023 at 06:22:58PM -0400, Peter Xu wrote: > On Sun, May 21, 2023 at 09:52:31PM -0700, Hugh Dickins wrote: > > pte_offset_map() was still using kmap_atomic(): update it to the > > preferred kmap_local_page() before making further changes there, in case > > we need this as a bisection point; but I doubt it can cause any trouble. > > > > Signed-off-by: Hugh Dickins <hughd@google.com> > > --- > > include/linux/pgtable.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > > index 8ec27fe69dc8..94235ff2706e 100644 > > --- a/include/linux/pgtable.h > > +++ b/include/linux/pgtable.h > > @@ -96,9 +96,9 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address) > > > > #if defined(CONFIG_HIGHPTE) > > #define pte_offset_map(dir, address) \ > > - ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \ > > + ((pte_t *)kmap_local_page(pmd_page(*(dir))) + \ > > pte_index((address))) > > -#define pte_unmap(pte) kunmap_atomic((pte)) > > +#define pte_unmap(pte) kunmap_local((pte)) > > #else > > #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address)) > > #define pte_unmap(pte) ((void)(pte)) /* NOP */ > > (I think this could be a dumb question if this patch has been running there > for years downstream, but still..) > > I assume one major difference of using kmap_local() is page fault will not > be disabled, while kmap_atomic() will. > > Meanwhile, pte_offset_map() is also used by pte_offset_map_lock(), which > means before this patch CONFIG_HIGHPTE systems will disable pgfault before > taking pgtable lock for it, while it will stop doing so after the change. > > Then what happens if a page fault happens on the same pgtable lock range > that is already taken by the thread context? What stops the deadlock from > happening? Ah, stupid me. I think such a page fault just cannot happen when holding the pgtable lock.. I believe the same applies to !HIGHPTE.. Sorry about the noise.
diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 8ec27fe69dc8..94235ff2706e 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -96,9 +96,9 @@ static inline pte_t *pte_offset_kernel(pmd_t *pmd, unsigned long address) #if defined(CONFIG_HIGHPTE) #define pte_offset_map(dir, address) \ - ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \ + ((pte_t *)kmap_local_page(pmd_page(*(dir))) + \ pte_index((address))) -#define pte_unmap(pte) kunmap_atomic((pte)) +#define pte_unmap(pte) kunmap_local((pte)) #else #define pte_offset_map(dir, address) pte_offset_kernel((dir), (address)) #define pte_unmap(pte) ((void)(pte)) /* NOP */