From patchwork Sat Dec 23 04:56:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Zhao X-Patchwork-Id: 13503926 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 1BD01C3DA6E for ; Sat, 23 Dec 2023 04:56:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8066B6B007D; Fri, 22 Dec 2023 23:56:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B7076B0081; Fri, 22 Dec 2023 23:56:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67EC36B0082; Fri, 22 Dec 2023 23:56:55 -0500 (EST) 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 52B426B007D for ; Fri, 22 Dec 2023 23:56:55 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0DA38140176 for ; Sat, 23 Dec 2023 04:56:54 +0000 (UTC) X-FDA: 81596873148.27.44559A4 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf30.hostedemail.com (Postfix) with ESMTP id 691158000B for ; Sat, 23 Dec 2023 04:56:51 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SOaQqbqF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3kmiGZQYKCK8njoWPdVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yuzhao.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3kmiGZQYKCK8njoWPdVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yuzhao.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703307411; 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: references:dkim-signature; bh=4v/LYlLycZFodA3ctHFCW6YVtoXi+WcqMYLGsHPgX1s=; b=fR4lEnyea3p8S3IxHUHppmjIb1ttLzlm5dOJjnNr4xWhs0tZ7HbfLdpiPTIwSPcMhhpc5R wTGvLMD8K4SHYuJaGs8tK9Rj5OGOAYHA0jNLwOmCMQt0QIT3WCq0311qad2UXyllaylroh gVvWGX9KIPcBi/r4l1KJOLiTD2IhPBQ= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=SOaQqbqF; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf30.hostedemail.com: domain of 3kmiGZQYKCK8njoWPdVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yuzhao.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3kmiGZQYKCK8njoWPdVddVaT.RdbaXcjm-bbZkPRZ.dgV@flex--yuzhao.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703307411; a=rsa-sha256; cv=none; b=UcoJ4TjqkaSYRpfMMl2m7xescC6y1moqZUiKGoruWt6elfjdClR/HKEsb2Eqp8JI/9mLAb wVadyTonRmWoc6FxiPLIVr7tspz1/ue9CdJSguRwJvaHtgCs80z6EgZaO2rkMK4E3Ce9EN 7dqGOvTAXYPkOsAElm8QF/9SoQvngns= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5e898eb4432so36250367b3.0 for ; Fri, 22 Dec 2023 20:56:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1703307410; x=1703912210; darn=kvack.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=4v/LYlLycZFodA3ctHFCW6YVtoXi+WcqMYLGsHPgX1s=; b=SOaQqbqFv2RQo7W6BQwlHzDM+hEIBj98lInDaYd+4pT7oZ5E+Wn2gLGxg7QDkbK8kN lGmhTg6rbulyUULNptaBxFD6Asa25iVkym3nHBf2ifl0osUMckhUdB5h4Qbqt4k1HARV 13z1npiSWj3FO5fbT9LxvZEV2EEIEVSBIsn3tSL4GPnSfqZ4jOBLgqhDLp6qrJsshviw oSPhQtMM33SirMJtNn0w+FbfaKXFS6aiqfdXvYLNDJt/ijiuh9fYD2GGKU72qQkLw3/s E61Y1WK++r9XPEyrGZn3zHBGzN1ZhrbbhPQ5u4fUPLEGRV1MPDrkXIaeMnYa2iEHN0G+ rheg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703307410; x=1703912210; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=4v/LYlLycZFodA3ctHFCW6YVtoXi+WcqMYLGsHPgX1s=; b=WAHJq063WMIJGJrDrrj8tp7je6BNlsv9IqgxE0K6bNbfqWGDVjXkykOpwxXJuHt14k xd1G9D1jidglKcWXiM8nBmCldEuXTbHpFuvn06cMgXDzgUJTB7k7Vb3MlJBEwBJf4J3N 1RINvZZaaFqPNrbikvh+jWqk1B1VrCyuVn47nsR+fvO0mUgIhmxh0wzF9CtAUV39uMQB UXcAYSsjttye2Hstk+zs3XY0q00OTMK9QY1YO+TGKQjmdTkdErYCF1slajzcvmZvX/vC JZu5Fbb2dzQnEaDA0gMFvr5Ln6fdlR1w+jKiNIWtXjLcASTU/DVMeb1a7mgrFWz/l00N LfTA== X-Gm-Message-State: AOJu0YzqgkRUf1dc+prAhh/RyjE22P3tvlw2KAFjyBZqkb81iIiaiXjm RfjsgQjD5PFpIxK2fI/mYYWr+SQMP9cWAVYG+A== X-Google-Smtp-Source: AGHT+IFFhHVArPPblD2DVYdTOdpn3Q5otdg4xxc2KJoUGdqMYAFIdZ+AH5uKiJdNpnmvJkxUPXRcr431E2g= X-Received: from yuzhao2.bld.corp.google.com ([100.64.188.49]) (user=yuzhao job=sendgmr) by 2002:a05:690c:3604:b0:5e3:c8e7:3bc3 with SMTP id ft4-20020a05690c360400b005e3c8e73bc3mr1104118ywb.1.1703307410447; Fri, 22 Dec 2023 20:56:50 -0800 (PST) Date: Fri, 22 Dec 2023 21:56:47 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.472.g3155946c3a-goog Message-ID: <20231223045647.1566043-1-yuzhao@google.com> Subject: [PATCH mm-unstable v1] mm/mglru: skip special VMAs in lru_gen_look_around() From: Yu Zhao To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yu Zhao , syzbot+03fd9b3f71641f0ebf2d@syzkaller.appspotmail.com X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 691158000B X-Stat-Signature: ktcitwte8qeq11hp6pb6wq1sfbrkb935 X-Rspam-User: X-HE-Tag: 1703307411-596651 X-HE-Meta: U2FsdGVkX1+88NOD+g890fXcDPAPZFVpFauinW6ycm0fGTaXn3sGoEQNcTKa0t/mbvCCMX1a+AuBOGCPT/WlxmKIdmTIMZa7mFba5wzjR/u4xDPINtaArVZzt//pQY9mz/lNm+EX5HMbTrHMA+NUApONNpGl3iMrCLer6CLB30p+Jn+BD8fVWhBDZYihPyNhjzS4AMY+7TuItGb9cmczX7GWczNYkpDfblPU31wOkryS3FGNWa1wY4XgGzgl0tzEbYHtbpxnZdRrbOwpZXBreQXcEeSNs83FakE+ctFCez5e7UlQGe4ICJJYFm6WuJ666pS0Vx2m+N1G58+xOeKKpuxsls1YJLBBBpCw6RhRzrU4METq5HlAVQcSoR/7ObjTmVK1eBlHvDL/gEi+nDLoT57QDYfXC+URehgP+xUrIqfEL4PBVU1O6fWuApb7GU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XyJcoyk2dCEq4VSWobyQmuMu+1DFa/28/l0Zn0+wThFYYHNSTPhDtU9hheJLK2kCnNBRuN41q1TaDAxVJTxuryxZC97kPlbxnxQhDMJRMcoSWKfw4CC27nVG0uajAsmFS+618bCdPKheq15P7TJn4ZLxiekj1U3EKtzJCLRjjWBH7T5sjznYT8GFLgqTWHaSFtr0KIllGt8XTXChl6go/lz0NXUqESWNoodDkeD06rqCAPVge2Pv4euYOrdPCTJKFEfjIFBafp8qY7NQJ0vKCYvUPYq0XSAhFwx6DYQaxtCFsN4AYgChoMbzdBmsO+uWDe432K/PPReTppFDnXY= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Special VMAs like VM_PFNMAP can contain anon pages from COW. There isn't much profit in doing lookaround on them. Besides, they can trigger the pte_special() warning in get_pte_pfn(). Skip them in lru_gen_look_around(). Fixes: 018ee47f1489 ("mm: multi-gen LRU: exploit locality in rmap") Signed-off-by: Yu Zhao Reported-by: syzbot+03fd9b3f71641f0ebf2d@syzkaller.appspotmail.com Closes: https://lore.kernel.org/000000000000f9ff00060d14c256@google.com/ --- mm/vmscan.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index b4ca3563bcf4..3cf7066d627f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3959,6 +3959,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) int young = 0; pte_t *pte = pvmw->pte; unsigned long addr = pvmw->address; + struct vm_area_struct *vma = pvmw->vma; struct folio *folio = pfn_folio(pvmw->pfn); bool can_swap = !folio_is_file_lru(folio); struct mem_cgroup *memcg = folio_memcg(folio); @@ -3973,11 +3974,15 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) if (spin_is_contended(pvmw->ptl)) return; + /* exclude special VMAs containing anon pages from COW */ + if (vma->vm_flags & VM_SPECIAL) + return; + /* avoid taking the LRU lock under the PTL when possible */ walk = current->reclaim_state ? current->reclaim_state->mm_walk : NULL; - start = max(addr & PMD_MASK, pvmw->vma->vm_start); - end = min(addr | ~PMD_MASK, pvmw->vma->vm_end - 1) + 1; + start = max(addr & PMD_MASK, vma->vm_start); + end = min(addr | ~PMD_MASK, vma->vm_end - 1) + 1; if (end - start > MIN_LRU_BATCH * PAGE_SIZE) { if (addr - start < MIN_LRU_BATCH * PAGE_SIZE / 2) @@ -4002,7 +4007,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) unsigned long pfn; pte_t ptent = ptep_get(pte + i); - pfn = get_pte_pfn(ptent, pvmw->vma, addr); + pfn = get_pte_pfn(ptent, vma, addr); if (pfn == -1) continue; @@ -4013,7 +4018,7 @@ void lru_gen_look_around(struct page_vma_mapped_walk *pvmw) if (!folio) continue; - if (!ptep_test_and_clear_young(pvmw->vma, addr, pte + i)) + if (!ptep_test_and_clear_young(vma, addr, pte + i)) VM_WARN_ON_ONCE(true); young++;