Message ID | 242721-1e64-845e-226a-bf2b2dc72dd@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 09567C7EE23 for <linux-mm@archiver.kernel.org>; Mon, 22 May 2023 05:19:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84A5B6B0075; Mon, 22 May 2023 01:19:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F9206B0078; Mon, 22 May 2023 01:19:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C158900002; Mon, 22 May 2023 01:19:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5FD006B0075 for <linux-mm@kvack.org>; Mon, 22 May 2023 01:19:50 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3707A1206FE for <linux-mm@kvack.org>; Mon, 22 May 2023 05:19:50 +0000 (UTC) X-FDA: 80816738940.21.F46CE79 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) by imf08.hostedemail.com (Postfix) with ESMTP id 6CF35160014 for <linux-mm@kvack.org>; Mon, 22 May 2023 05:19:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=c16Z4sMp; spf=pass (imf08.hostedemail.com: domain of hughd@google.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684732788; 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=ooTKFpGgFIG6tpdJyTdSPdnhROWHUT8BFdRqrlDYiG0=; b=MC4PQPCELr8rX0FJYU7sO7QUvTc27QgUgPM8Be8kOC6DXiFhPjl8r0kS20hDTlpTLYvnHP uJP9vsE7YJWBYFkxEIy6kdF2gj49ufpjfjUzdp1nuveHVQAadHdLWHQdF08cDA27/DfaJ1 NPMLFiJ1ZQWDy1CK0ysoL+MJV5jjBU8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684732788; a=rsa-sha256; cv=none; b=DgMdGqgAw/ioZOyeoTNtxOSJscr2L/am3rTUqhVYiH3moLttSZ1k0dA+6GZv5oHQwuZMDD 6Lhy+DuJIIURCGUpOjOMtRPX1YG+gwIG2gjkHPNGUtYxX/RhNlPexnJl8SVBtLbYy9MAoO 7hcRcoVR49J5Ovy3YiD6tjE3UqODY54= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=c16Z4sMp; spf=pass (imf08.hostedemail.com: domain of hughd@google.com designates 209.85.219.179 as permitted sender) smtp.mailfrom=hughd@google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-ba1815e12efso4782694276.3 for <linux-mm@kvack.org>; Sun, 21 May 2023 22:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684732787; x=1687324787; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=ooTKFpGgFIG6tpdJyTdSPdnhROWHUT8BFdRqrlDYiG0=; b=c16Z4sMpjKlgLDYv6Gs/y1EYdzJZLSgcmaTkBaIf9Gh+M6R5Fj28OTQhOSCRw7EEv5 CoXdOMLH5hzAb7ctwTVEzalqQl9a+Um/b9wFPM2bKdaAzb1WrTE0ZJDEimE6nNgaQriX ekKs2u5sm5n3wdVCVhRqBQ64w5hCu6jc8AAKpTKma9h0EDNZhsm+d/uAlNMvz+IWh9Vi IdWQzCcYU/nxwQLTQZI99miGWNLqkFHHVO984XkRjgpZ7eBUTR4yIiwEf+nz+MbqBbbu qrDeOVuSWS3vwtPVFhgFnPNPF1tXG11tH/YIDKTxJb7j0INA2XTKzLvkIppZ9XEZec1f V+Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684732787; x=1687324787; 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=ooTKFpGgFIG6tpdJyTdSPdnhROWHUT8BFdRqrlDYiG0=; b=IBtjuk9RY649N9PuOahvX2bsiuw1slStFGsiClsFzwrs9y0GGuodYzCFixZCeLSJNa BdUkhKhm8lpmH/tr9BbZR2IX92CjFRHUUk+w+R1yWfrB+W+CMDRc0PglsbbVL+Ojx8/h zZImen97TqLkBTZu2/79QimP7nP/cxAgYifjGpOP8vqrKT15tsfRIO3DGFjV4CulPcjj l1U0WZdh0ktPZ3N/m29qf8DMMbIeBHrKqycTpqzJZZjirHXY5sd1NhZCn8z+fzPbCCOT N7suJgPfCmGSP+D3MFwByuDtCJ8Vgr29H3zH2p4/+uQxD6TydL8dtPG04AGjRgcf0uUC IeJQ== X-Gm-Message-State: AC+VfDwocDr35x0YNFDDGemkM4qNfpCy1UqybJRSyaJBD6oawiEg8MDz C5AlebNNGc3fWxNInM1XE5bPQQ== X-Google-Smtp-Source: ACHHUZ4/iOac0pg6azmy6Y4+9ZIQvlTnkM+d3E/2233dtMLIq4uN1+AwZtw93iYqYZBi+HEHW+NHVQ== X-Received: by 2002:a0d:d743:0:b0:55a:59cb:4c1a with SMTP id z64-20020a0dd743000000b0055a59cb4c1amr9770012ywd.14.1684732787446; Sun, 21 May 2023 22:19:47 -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-20020a817309000000b00556aa81f615sm1809311ywc.68.2023.05.21.22.19.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 22:19:47 -0700 (PDT) Date: Sun, 21 May 2023 22:19:44 -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 23/31] mm/mglru: allow pte_offset_map_nolock() to fail In-Reply-To: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> Message-ID: <242721-1e64-845e-226a-bf2b2dc72dd@google.com> References: <68a97fbe-5c1e-7ac6-72c-7b9c6290b370@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Stat-Signature: xxmgtxpiicfzbhzzt4gw1tagnanwcbrw X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6CF35160014 X-Rspam-User: X-HE-Tag: 1684732788-93997 X-HE-Meta: U2FsdGVkX19TnBuv9XpdPF4iaYvkdG1dcOoI2XT3D5rQTCmzGH7wg0xsbfi/tKLwsa+kV8k1AW8Sil5f3HvS+8RA/89yjPNgr426yoyJGGb4aLJbS5GbQin40vwqYZ8pubEKun7WcJtcgcinjIB2nFIkhWmWu4mrjFH5ObfWU6am9Exg2c3a4tYKyQW76kX9+1a2jktUdKT2uLl7KjkjmpoPsZOHaI+uf04z9UQKqUI2KuZUnCEU1rH2owh7JK9TwEsPhW/5GnGmWlQVEwXHu0cuYZNqpmnSKSnknU0jnNXyq2bYr4OjoVYgfmY5taFyHjFnunFdndZ3aBLyKKhDiAvC3oIa29mmKi1rK1u7ci3xhT4r1yZduHF2OV6ifWCR+YJ8nIZgOSmQeUUz/fmbmNjRIy9OjfSFzpzSbjREXqWA87mfrsLW9WIBGgOStspiYGxnhJOvPT+mASAtAKc21eca1cj1SPFEdMqiYwZqD3znMUi5N7WpG6v5BKAAf2alfq8mtN/yJEJxODJnWAL2M1CWInqxzz3nlWyzdDjGvmWpzeGlJApIcEDYmboMNKUiRcMIeAh3cJ1H+iadNK2n291TcbwZ70hlepBjiHlVu5X6W+uB+AVslCPjBl8y0QYDU9f9rt8huDN5NRtuKB8mxYopgdS1CHbOEXOc8cv6uSf3pTNdB4aZ03n2zkYI1dGo3coWN0Dl0l6g6tw9lSwldrhkwD4P0AGtEj5fygMesK49Cxi5RGN0F0mzJYtQ//gqiBsNDcfTPdHHiN+dbhTbcCFpWOaJjpIg7jIBpam1yhLpygjkkbdZaq5e+RGbhtOzBFjpuxhQoV1FNpUJdqwuQf1vT9m2vLNhLXpC1eHlXNzWgnphvzqUB2jTVZh2kAW4uobMueCk72BJLnU7SnzlTXA03FvEoG+Jy++cVkho/bG2mJAfovNzLd6Jks6R/KENdgV1BLxmQiXAobJoWWK ITIWqoVn Y3GP6ISRZvV5HRYoxmN2g7u1GzlIHD4v1GhrvE2qv2wWtwsl6NLSqOn2ZdACUvNEljky7L0VErIfbc+FxMo/Cm7k4pF9cboO+4+4PCiXBHfQ9Ef85eG6QDZyvEXqj3Y0bIw6OLGBy8nsreZRy0UxoEcPmWEH+wpH0uRmNv7mzQhGQtMxcaUPUTXmqRfxFs7rtav4hupXyM+qqs0p5ysfjv6FtRIK46UDwXb2lPjp+J50+SmE6fthIv7JEtGBfJ5X9VDasC/u7d19QsWAX9IHhVdX/rJ0pu2q7PhuFls8xhFADSMgV5c9La0UHSbAMgrpQQuY31V8Ej0laKw3IaaKFEXw5CAfkEcd5VfONYYyG+6lXe+i0OBIpGkS/bAP6b2jVmBrNrP9rMcAExNZ9QQVxmU6Rp2bhH2qBRF8xQj1zHMBpLJ+01m666otGng== 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: allow pte_offset_map[_lock]() to fail
|
expand
|
On Sun, May 21, 2023 at 11:19 PM Hugh Dickins <hughd@google.com> wrote: > > MGLRU's walk_pte_range() use the safer pte_offset_map_nolock(), rather > than pte_lockptr(), to get the ptl for its trylock. Just return false > and move on to next extent if it fails, like when the trylock fails. > Remove the VM_WARN_ON_ONCE(pmd_leaf) since that will happen, rarely. > > Signed-off-by: Hugh Dickins <hughd@google.com> Acked-by: Yu Zhao <yuzhao@google.com>
diff --git a/mm/vmscan.c b/mm/vmscan.c index d257916f39e5..1c344589c145 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3992,15 +3992,15 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, struct pglist_data *pgdat = lruvec_pgdat(walk->lruvec); int old_gen, new_gen = lru_gen_from_seq(walk->max_seq); - VM_WARN_ON_ONCE(pmd_leaf(*pmd)); - - ptl = pte_lockptr(args->mm, pmd); - if (!spin_trylock(ptl)) + pte = pte_offset_map_nolock(args->mm, pmd, start & PMD_MASK, &ptl); + if (!pte) return false; + if (!spin_trylock(ptl)) { + pte_unmap(pte); + return false; + } arch_enter_lazy_mmu_mode(); - - pte = pte_offset_map(pmd, start & PMD_MASK); restart: for (i = pte_index(start), addr = start; addr != end; i++, addr += PAGE_SIZE) { unsigned long pfn; @@ -4041,10 +4041,8 @@ static bool walk_pte_range(pmd_t *pmd, unsigned long start, unsigned long end, if (i < PTRS_PER_PTE && get_next_vma(PMD_MASK, PAGE_SIZE, args, &start, &end)) goto restart; - pte_unmap(pte); - arch_leave_lazy_mmu_mode(); - spin_unlock(ptl); + pte_unmap_unlock(pte, ptl); return suitable_to_scan(total, young); }
MGLRU's walk_pte_range() use the safer pte_offset_map_nolock(), rather than pte_lockptr(), to get the ptl for its trylock. Just return false and move on to next extent if it fails, like when the trylock fails. Remove the VM_WARN_ON_ONCE(pmd_leaf) since that will happen, rarely. Signed-off-by: Hugh Dickins <hughd@google.com> --- mm/vmscan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)