Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp97548iof; Wed, 8 Jun 2022 16:15:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp1dbetsadEdVOvXDw61D0YW7jdRjiO8hSeQoGSAuPHHNBMU9tcKSqFNKaWtk0JjH+pTgw X-Received: by 2002:a05:6402:90c:b0:415:d340:4ae2 with SMTP id g12-20020a056402090c00b00415d3404ae2mr41969504edz.331.1654730130873; Wed, 08 Jun 2022 16:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654730130; cv=none; d=google.com; s=arc-20160816; b=mddgU2A+FXx+BrlbYqS1EQcuCnVDVy8n1LHdxv9gdpTDbqj6MHrf9zVJsrWTB7YxQt tCl16SOc3cWDmfcHZZTCOtiwpT/CfV23KpQu0F4oRu9d9RNjrVqG2you7yOqzdo8P8ai bN4BWyxapJHIo99ATieb5/8DtDbLYn8Tw8rKYDkCly5JsR7asWXrsjwJnloL2mA1qfye 2zadbFy4oQ+a+ASwwuVZDVvvXTnHT8X5IHKZhI1YmTZsH8nx3EuZ6vvNCSMMIP1QE4bg rDLuStcYHjBaTMOl6T9NckxSYQ/AJ7YaWstvBo+WMh5eaFjo8WWSVzqbppDYZsx/jEft oB2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=RGyEQx4XWPendUVIT5iH3jx+IKfbaeExu0R992MzqQc=; b=L+73LYNWsipsmezGNezLlZYca8LubNNqpB5Sek5Hg0w0BWQEpPKZo2ja59cjOgVN18 waR7fgWykdo0B8g1TTkWCn66E2eY5qRxxsqLNZOlznnXFntSOhHWsasS0JipbtUUHvZL 13VTPAfaHHY7Im+u/iMyP49ayL/Vl8ktm0E4SZVECN34neHJVWX1DqBJZsxdbriTavfK PEnm5DAxCCk6oda+pF4cYzb9Lxrez6KtaNCVAv38Egzq/SUq/bRKNBNH6YNqkNL0ERrm BwQQgTuE3A5GvlzxMW4aCTungENxHMVp6kBJm261wDJcK1DCWaSZ775zTm+lzCe7DPII l7PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SEfIfZdB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qa35-20020a17090786a300b006ff14cfebbbsi27248095ejc.618.2022.06.08.16.15.04; Wed, 08 Jun 2022 16:15:30 -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=@gmail.com header.s=20210112 header.b=SEfIfZdB; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236420AbiFHWq1 (ORCPT + 99 others); Wed, 8 Jun 2022 18:46:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236200AbiFHWqY (ORCPT ); Wed, 8 Jun 2022 18:46:24 -0400 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14C03253329; Wed, 8 Jun 2022 15:46:04 -0700 (PDT) Received: by mail-ej1-x62a.google.com with SMTP id gl15so30303533ejb.4; 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=xlDy2lXLa2buFpBQ4Tb2mXbTjWOOnbIK4vgXnJRpDsXyEWG0QybdGG+Zl5nOPFk6nL 6XAfb7HBZfW4aVOPYcFQX0IpvMo2lIiNgJ6+mwODJXbQAhhn8n9o72ttC12bx+ODr0Jw 6F5z544NUrFf89YXH0jPVm8nFQUUIp+zZTvdbYg+EJZFs6v8DA08lzNwhAD0d3AWZSHF Z1tj65cQ576mTq6q459iKDcNzzJxPRcBNvJm0XmPLHxVzfB6dWl9QaixGMNOwRqGfzzF 2gJtsRBFUBF2mLl65qn8iiibbM8b6e+3NdgpVLP7GivxTM5scTxpSgvcw3fJLwn1tzJ5 Uj2Q== X-Gm-Message-State: AOAM532qceiaGS+LxnjvRNv6vBniBsxUFqx5BEt4imAM3oXhHstN9sdw cOC+GLjIgROd5lwpFAIzo2zydTRzkNmnwdRC4oM= 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" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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: X-Mailing-List: linux-kernel@vger.kernel.org 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