From patchwork Fri Jun 9 01:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugh Dickins X-Patchwork-Id: 13273088 Return-Path: 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 EB762C7EE25 for ; Fri, 9 Jun 2023 01:37:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9188C8E0002; Thu, 8 Jun 2023 21:37:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A18A8E0001; Thu, 8 Jun 2023 21:37:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71BCE8E0002; Thu, 8 Jun 2023 21:37:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5CE4E8E0001 for ; Thu, 8 Jun 2023 21:37:19 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 2EC58AF090 for ; Fri, 9 Jun 2023 01:37:19 +0000 (UTC) X-FDA: 80881496598.25.38791F4 Received: from mail-yw1-f182.google.com (mail-yw1-f182.google.com [209.85.128.182]) by imf02.hostedemail.com (Postfix) with ESMTP id 6A90680004 for ; Fri, 9 Jun 2023 01:37:17 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="g/fK8hP5"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.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=1686274637; 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=zu44LOJFUZSfjUzXfaM7AXaMVzmcNQ9SKaG/n0S1Di4=; b=pNToysqZkdBUUfyvFlHLKWYkJyPvkrGeQCFBoY5R/EO/WbFHd/TQXY78440Sx6YvVELTqh ngQYWWh0xi7B/WFx2xV92EcCtVj87flsUepj5mw2efpqXhCbUSMiFeBPmZ07yrWZL/e0us UMbb3ZC5UbwX3jNQb6+0VrG6oJdb3Ms= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b="g/fK8hP5"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf02.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=1686274637; a=rsa-sha256; cv=none; b=FKmRSy9JBLRxFYPGenNnQoLrXQ/Wbi5VrnePjvZkr5PiDAv29xlMAPlpvUdW2ZFpNzq3qr lch3sakKFVbXtAstLLwJkvAx85ckr+pSQHcQLqS5A4EZPxyS5N2eKmY1EfPnzNPlU3/9cm xC8Hkr6rzFcvwHACsEey/1lR7U/E8m4= Received: by mail-yw1-f182.google.com with SMTP id 00721157ae682-568ba7abc11so11571427b3.3 for ; Thu, 08 Jun 2023 18:37:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686274636; x=1688866636; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=zu44LOJFUZSfjUzXfaM7AXaMVzmcNQ9SKaG/n0S1Di4=; b=g/fK8hP5bFpFVjO76tLNArCNe2GlcEYd1TR7ZwQdCtSODKo9bn2ob62ekzm4ZsThhU yjQK+8xMaXjxfJ1yZWY7NOanC9yVcDVOaMe2iZYwQzT6eJ8h5uTrJC9oVwwCDxswbBHp l/xid7bUgRR1+bdWUBBbvmFDZ/iNYOS5AHsDau932Tn9EMZ4WD6ylqBkwxof8Mw7/egD Ww4k6FcpaXFX8Vqb/E2HUbm90tkOaEYqBxZ6KyMuDMKUc0iBxBMpA3o8pXAN+XBCXRzs f8EIBhd27TS5I+YyqHsJshT+x1siX1ieudcplgI00w6T7xrRyEgdPl7QxJSf2yBgKL3/ hKjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686274636; x=1688866636; 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=zu44LOJFUZSfjUzXfaM7AXaMVzmcNQ9SKaG/n0S1Di4=; b=LjTcuFtb+Hz9ytOjYHZduskHmnF9MoWjquhrDzrY0CwfYIOqxszQiQXoJMLXsquDil HahypTvFObkMw/cypZ6EYxXQL48qhu86ggd2fg2bDo2aTdJDCB/BBuAU+xEHIdKvYGTH in/3dnEABOKMrJNGxKNSQfIoGOCuh2rPpaQtkv9vXwtHkeyeggfcYnliTrl9U7PmeNEi oVQXPNKSUm2Mbc4OXbZ2ScpDXmDaW21UB/UYDfYGh1uirxQ5UcFFqr8wJ3wiTkHf8cRS AHbXBNxjlljPYN/5woR9+sTVV/CJBpwmZ9t4izOl7VidOU6YY6YP2dpCuurVTBXuN6CO Iyfw== X-Gm-Message-State: AC+VfDy1jCJ28nWedpNZHubiyyECYlKxLDpU5HYZowmBRPlpJ1Tc6oii T8g6W/KorVCubLwc/BS3FPZByQ== X-Google-Smtp-Source: ACHHUZ5BEYGpIOz49tbHOiOve9aTVph95zxtniJYmBvQce3mSMb/qY9GD2nlVpV9ClVLYloJKEZjzA== X-Received: by 2002:a81:46d7:0:b0:565:eedc:8dbe with SMTP id t206-20020a8146d7000000b00565eedc8dbemr1425297ywa.27.1686274636468; Thu, 08 Jun 2023 18:37:16 -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 k124-20020a816f82000000b00565b26a9c9csm292968ywc.64.2023.06.08.18.37.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 18:37:15 -0700 (PDT) Date: Thu, 8 Jun 2023 18:37:12 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Andrew Morton cc: Mike Kravetz , Mike Rapoport , "Kirill A. Shutemov" , Matthew Wilcox , David Hildenbrand , Suren Baghdasaryan , Qi Zheng , Yang Shi , Mel Gorman , Peter Xu , Peter Zijlstra , Will Deacon , Yu Zhao , Alistair Popple , Ralph Campbell , Ira Weiny , Steven Price , SeongJae Park , Lorenzo Stoakes , Huang Ying , Naoya Horiguchi , Christophe Leroy , Zack Rusin , Jason Gunthorpe , Axel Rasmussen , Anshuman Khandual , Pasha Tatashin , Miaohe Lin , Minchan Kim , Christoph Hellwig , Song Liu , Thomas Hellstrom , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 23/32] mm/mglru: allow pte_offset_map_nolock() to fail In-Reply-To: Message-ID: <51ece73e-7398-2e4a-2384-56708c87844f@google.com> References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 6A90680004 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: d1ymmtk47srt16qftnaff9esb3wjh6c4 X-HE-Tag: 1686274637-422159 X-HE-Meta: U2FsdGVkX1/CZXJejtpF93+PmJHpAn9UKNCGrqSoi/dyNIPJTMo+qOuml/HRHqFW9ucXq06Aryw0fiZctX9Sh+91EBspSalOVjfndWQYVR3xlg/sj8FBxu+bvBc8vCaCCcuDUIy86xcj5tuGouPPw+G/vmFHJteEX6y4tZTLacaGyzC2H/GuSrvUdTzZi0Pyd/XbrFWZhJi27fvpUClMW1ihi5xgSNOIc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nZmiAScJl+2kYC8U5/JDo/RV1vUtyUrJCmkwahuDvTJv069Dhld72edJrXRQR7jtz8cBTfAQmmXf+A00idSvMSMneGVUDxh3jCrHyFxRgDbOYakmcEZlYw1w+SXlbRQcG7jTCRI2f9og== 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: 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 Acked-by: Yu Zhao --- mm/vmscan.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 6d0cd2840cf0..6a9bb6b30dc8 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3993,15 +3993,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; @@ -4042,10 +4042,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); }