Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp356881pxb; Wed, 14 Apr 2021 17:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPpKI7vaMDyATLjjsqkDmXttugOZveMdprqzJajcaUvNs8UooHmacpMZQPWrad9o6wtGV8 X-Received: by 2002:a17:906:39cf:: with SMTP id i15mr736842eje.534.1618447355900; Wed, 14 Apr 2021 17:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618447355; cv=none; d=google.com; s=arc-20160816; b=y2YnBY1FZ0Mz9JVOd/7WhcQ5lBndW3PfBkGiHkHqaSH8rHw9hj+6oUBm4OhRsy15fH hBP2Yma6t4ricsk5nxpYJRQ7eCWhIHZZ9A+Csvt4ZZHWA5ksPME+4qOjuY7NnWWXCk+o NzdHBlrs00Zvuw8kTqB8wT3j4kWjAoNeiL2J8f7WSyx83RWQ9sN575VHFtu1tqhavHpS 6gsyeX2mPfCufqVX4eFxhyVtF5X7RMiF6Dbg4yv+8v49HU8NrKWnXEgBdF6hrlSiuTzF klUlTIaKs8SYi/kXb8Kl08iE8vX7m3zWGwONiXeCU0jyz/hKc9rjuOkZN0X8C7fKLAqK A5Cw== 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=jYrJlRv7hMOslZniAZd/Q50Y9bWCr5RlPObcMlcuTkQ=; b=x6YVbuMvxFZrJsCGZsPjnZFJDzsQyRYKtcg8kqSgMUDzBwjXz1W9khJjX0M/NVCXbu a7ioObrOXUolg99qnBM0vrBspVV6P+ks1v1MMZAcVfYGkb8eJee9itzcqDdsvDWQ2vv9 6HjyMrBbVKCRYHQiUF0JHdVlhtlyWtOvx0pDcK/CJvlM3yHcSOkmlaHmRwdUIPlarqSC Jx7qyYkQKs976q4RSCSmEu/4ieahvDW2WYaNW+fwwOKQXML8FXOwRJbg8VFikPNEsXWF +UJbRSD/XV3A412dqCAbMe9SAGF73qusu0RWXInIbIyJj5RkX38R7Ot93ozQO+Ln7vlX L3HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hzHoiVkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si735491ejr.633.2021.04.14.17.42.12; Wed, 14 Apr 2021 17:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=hzHoiVkW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234493AbhDNTF2 (ORCPT + 99 others); Wed, 14 Apr 2021 15:05:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232347AbhDNTF1 (ORCPT ); Wed, 14 Apr 2021 15:05:27 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D413C061574 for ; Wed, 14 Apr 2021 12:05:03 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id o9-20020a1c41090000b029012c8dac9d47so3867800wma.1 for ; Wed, 14 Apr 2021 12:05:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jYrJlRv7hMOslZniAZd/Q50Y9bWCr5RlPObcMlcuTkQ=; b=hzHoiVkWIZEHVJk9H2nbZSqd2yL7vB4H89ftPNLX5CWSYzwiF/RYeI69rFC5JdnwLA UHsS7ckUkdL2XPeDeclyaivwKYvS9FvTlvIlhp5J1LT3v/iBhwEzc/ISgcNvQ9OjW16l lPWSF2KT9PTYioS8NKV/OqP6BSd6PmwZxxQLwaFr2v+g0kmybzjX9DC2McZ5dzV/2r4E zdtLhlIiPAOJV9G01jDnkciAXGfgoEpSJT07eBaNecUCr+f8UV2BY9zGFBeStRIA79UO RUp8cQfGP2+bJ3l3uIUenDrHs7o4+D7D3bBUP9MUly2cOMOD+EIZS/GBCBmmr+kEAiup UbKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jYrJlRv7hMOslZniAZd/Q50Y9bWCr5RlPObcMlcuTkQ=; b=OjtbMEny3DRXiY+O4pX8F6sLrHG2QZwf9ip8i8ctzxyVds+9+zmOgszqDGS+7I4Dmb 6uSsa5tvgq3jY8Rh3JQTCUVDreobjGzgSbfJV3WJXUYT2RRf0FISLuHpKzHcKauEgOJJ aWWcmZFYkv5tb/2o742w3hpnan/vH2A4iPrOFXEEI8/jAb7cB6+3FCovTC9G01iuQfpm pCGOvVK3gZlkkgnVFuJyqS8O037nxlU+tb7EZhRMwzf74W/LyW8saZq5ql5dAtCq8OLP RvbBBbVkSrh8tLSfmcEbr+cO5T8FM592dcl7/0KOTBfNz0DB4I2OI4+fhWQ1iS9K6J1E IUrA== X-Gm-Message-State: AOAM531Np13c+51Go0CTEZHWmaeh6KhQgJwiRrXE3fPGni0kPe6OCa48 k/eY4xoIKA7qeLMfILlJtkzzG/C3mXu3fbD3hxS2OA== X-Received: by 2002:a7b:ce8a:: with SMTP id q10mr4414305wmj.101.1618427101999; Wed, 14 Apr 2021 12:05:01 -0700 (PDT) MIME-Version: 1.0 References: <20210413075155.32652-1-sjpark@amazon.de> <3ddd4f8a-8e51-662b-df11-a63a0e75b2bc@kernel.dk> <20210413231436.GF63242@dread.disaster.area> <20210414155130.GU3762101@tassilo.jf.intel.com> In-Reply-To: <20210414155130.GU3762101@tassilo.jf.intel.com> From: Yu Zhao Date: Wed, 14 Apr 2021 13:04:50 -0600 Message-ID: Subject: Re: [PATCH v2 00/16] Multigenerational LRU Framework To: Andi Kleen Cc: Rik van Riel , Dave Chinner , Jens Axboe , SeongJae Park , Linux-MM , Andrew Morton , Benjamin Manes , Dave Hansen , Hillf Danton , Johannes Weiner , Jonathan Corbet , Joonsoo Kim , Matthew Wilcox , Mel Gorman , Miaohe Lin , Michael Larabel , Michal Hocko , Michel Lespinasse , Roman Gushchin , Rong Chen , SeongJae Park , Tim Chen , Vlastimil Babka , Yang Shi , Ying Huang , Zi Yan , linux-kernel , lkp@lists.01.org, Kernel Page Reclaim v2 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 14, 2021 at 9:51 AM Andi Kleen wrote: > > > 2) It will not scan PTE tables under non-leaf PMD entries that do not > > have the accessed bit set, when > > CONFIG_HAVE_ARCH_PARENT_PMD_YOUNG=y. > > This assumes that workloads have reasonable locality. Could there > be a worst case where only one or two pages in each PTE are used, > so this PTE skipping trick doesn't work? Hi Andi, Yes, it does make that assumption. And yes, there could. AFAIK, only x86 supports this. I wrote a crude test to verify this, and it maps exactly one page within each PTE table. And I found page table scanning didn't underperform the rmap: https://lore.kernel.org/linux-mm/YHFuL%2FDdtiml4biw@google.com/#t The reason (sorry for repeating this) is page table scanning is conditional: bool should_skip_mm() { ... /* leave the legwork to the rmap if mapped pages are too sparse */ if (RSS < mm_pgtables_bytes(mm) / PAGE_SIZE) return true; .... } We fall back to the rmap when it's obviously not smart to do so. There is still a lot of room for improvement in this function though, i.e., it should be per VMA and NUMA aware. Note that page table scanning doesn't replace the existing rmap scan. It's complementary, and it happens when there is a good chance that most of the pages on a system under pressure have been referenced. IOW, scanning them one by one with the rmap would cost more than scanning them all at once via page tables. Sounds reasonable? Thanks.