From mboxrd@z Thu Jan 1 00:00:00 1970 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 1D67BC43334 for ; Wed, 8 Jun 2022 22:46:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C6506B0073; Wed, 8 Jun 2022 18:46:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 075576B0074; Wed, 8 Jun 2022 18:46:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57D26B0075; Wed, 8 Jun 2022 18:46:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D799F6B0073 for ; Wed, 8 Jun 2022 18:46:04 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id AF73F60C23 for ; Wed, 8 Jun 2022 22:46:04 +0000 (UTC) X-FDA: 79556553048.01.74B3DA5 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by imf05.hostedemail.com (Postfix) with ESMTP id 4A8C4100053 for ; Wed, 8 Jun 2022 22:46:04 +0000 (UTC) Received: by mail-ej1-f43.google.com with SMTP id h23so33106212ejj.12 for ; Wed, 08 Jun 2022 15:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RGyEQx4XWPendUVIT5iH3jx+IKfbaeExu0R992MzqQc=; b=SEfIfZdBf+iUPWQ84Xx/UK3Jih3tLOBZ34JtUVzGUBT4CjLrNly6+yNX1/1WpYx87C KEgViwFPHgwDF8NoBf6vNRXlPqDaH+QGJvkPMBJw09vAkse9uLwioPVNGEtkZODqo4n+ QTdv0rcegiaB4K+bNml3+fDmNnk+vvKHKlKEbtHlMF8Hlctn2gP1MkeMjOR+Mx7uetqc T9tKETI/Y/jWheQYaPkYJGY9L+YlFUyuWpCBbTdMNIIqL6SYnTb7nhhfwrH9Kogcnshe nwnoSAfOau4l//65+Yvi46YnfaRbeZz7MoJmtYKj58ZUk5f0LxNAtdaaSOaaeonfifrm nvMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RGyEQx4XWPendUVIT5iH3jx+IKfbaeExu0R992MzqQc=; b=eRc4hBp1SY8b0T5sFM4VOmWr9UTqFBFX4dEM0/XmwQO5IaKmw4nvsd50cn87PZxqBY DVV8rQuqRGqR7BrDxP71RM3KCaiM1/SpDPYZ2yrRfMpsSencCvb8H0MtG5QPZI+hAlbh 74dImw0QChcrgeC8ved5zXI2bYMB0dPHZsOUT9YAx94h02LOdu6fxTJkdCq+K9ABqLU5 EodZcT5jvrLyTJ2HysIRBZcrd0qwV1JwfKip3eklvn0/FlZayznW5u0XTY7kgeX9fGln jON4PKfKo39Kx6ujJPD5HmKnhiD7xb6TnSOzDBqUcu6cvzhgnK6aXUCOSsOhJqsEIPC6 nM+g== X-Gm-Message-State: AOAM531YufrALb6uA5ec09O9uWFoGUDvFBp2KXW7WQDX3lwxcxlzFdwH HcUzA+oUdF2G+eJjhO/3vP7+nm1/+JGJ1f/75Qo= X-Google-Smtp-Source: ABdhPJycCulqR/dNreJvVX5htaggHlxzrVNrJd1i+/13R78yiSZFXhgCbhoCFawHBoYXeJSOMPhKQmin+waHYgUqL/k= X-Received: by 2002:a17:907:a0c8:b0:711:d82a:1caa with SMTP id hw8-20020a170907a0c800b00711d82a1caamr14138368ejc.702.1654728362854; Wed, 08 Jun 2022 15:46:02 -0700 (PDT) MIME-Version: 1.0 References: <20220518014632.922072-1-yuzhao@google.com> <20220518014632.922072-8-yuzhao@google.com> <20220607102135.GA32448@willie-the-truck> <20220607104358.GA32583@willie-the-truck> In-Reply-To: From: Barry Song <21cnbao@gmail.com> Date: Thu, 9 Jun 2022 10:45:51 +1200 Message-ID: Subject: Re: [PATCH v11 07/14] mm: multi-gen LRU: exploit locality in rmap To: Linus Torvalds Cc: Yu Zhao , Will Deacon , Andrew Morton , Linux-MM , Andi Kleen , Aneesh Kumar , Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Johannes Weiner , Jonathan Corbet , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Mike Rapoport , Peter Zijlstra , Tejun Heo , Vlastimil Babka , LAK , Linux Doc Mailing List , LKML , x86 , Kernel Page Reclaim v2 , Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , =?UTF-8?Q?Holger_Hoffst=C3=A4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain , huzhanyuan@oppo.com Content-Type: text/plain; charset="UTF-8" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654728364; 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=RGyEQx4XWPendUVIT5iH3jx+IKfbaeExu0R992MzqQc=; b=r0gQdqxLTdYKr5xSYIOTAk6tQgIuAB0hbQmCeefL77pIeKiwW9n5PzISz3GyoDFlnEGo0J wt+2mS0M7rEmWR8ebjp2iZ5zlpGSxWZH8Y3qewTrIoZzIaCSF2dQuER6H50/2dy09/3K6P DXzDaF1Wv9ykQnf3Q2q6wfD6OLrwol8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654728364; a=rsa-sha256; cv=none; b=m+ZXMTASed6/zcxnTZH7uLxxTPN2kXKB50czX0nO2EdBeuUcyTqrg3Dp7x7CN0Jjx3zP4N Ej1NSy6cRMQLtVga5IlSq9KKmo9dx4yrGQchQ0jjCsYUGUjEctdtYsyMX0+TZX3bcJiWSw V0f8TpSh8bSBDO3Fgm7gc5eqtUXxX6U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SEfIfZdB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=21cnbao@gmail.com Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=SEfIfZdB; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of 21cnbao@gmail.com designates 209.85.218.43 as permitted sender) smtp.mailfrom=21cnbao@gmail.com X-Rspamd-Server: rspam08 X-Rspam-User: X-Stat-Signature: eip8pi11fypfyobt6iz4ye983fd14tr3 X-Rspamd-Queue-Id: 4A8C4100053 X-HE-Tag: 1654728364-747332 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: On Thu, Jun 9, 2022 at 3:52 AM Linus Torvalds wrote: > > On Tue, Jun 7, 2022 at 5:43 PM Barry Song <21cnbao@gmail.com> wrote: > > > > Given we used to have a flush for clear pte young in LRU, right now we are > > moving to nop in almost all cases for the flush unless the address becomes > > young exactly after look_around and before ptep_clear_flush_young_notify. > > It means we are actually dropping flush. So the question is, were we > > overcautious? we actually don't need the flush at all even without mglru? > > We stopped flushing the TLB on A bit clears on x86 back in 2014. > > See commit b13b1d2d8692 ("x86/mm: In the PTE swapout page reclaim case > clear the accessed bit instead of flushing the TLB"). This is true for x86, RISC-V, powerpc and S390. but it is not true for most platforms. There was an attempt to do the same thing in arm64: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1793830.html but arm64 still sent a nosync tlbi and depent on a deferred to dsb : https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1794484.html Plus, generic code will also send a tlb flush: int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { int young; young = ptep_test_and_clear_young(vma, address, ptep); if (young) flush_tlb_page(vma, address); return young; } We used to use ptep_test_and_clear_young() only in rmap.c for page_referenced() in 2.6.0: https://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux-fullhistory.git/tree/mm/rmap.c?h=v2.6.0 int page_referenced(struct page * page) { ... if (ptep_test_and_clear_young(p)) ... } but in 2.6.12, it has been already ptep_clear_flush_young() in page_referenced_one() https://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux-fullhistory.git/tree/mm/rmap.c?h=v2.6.12 I failed to find the history to figure out the motivation for 2.6.12 to use ptep_clear_flush_young() in LRU, but I am still curious how using flush or not will affect LRU on those platforms whose ptep_clear_flush_young() and ptep_test_and_clear_young() are different. > > Linus Thanks Barry