Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp704697pxp; Fri, 11 Mar 2022 12:51:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvnKDpUTHcHoc11hNtXCdSVTo+3F5apITWkx/+yzumgr+8txvta2GrgsCOXXfRVSVS+xM5 X-Received: by 2002:a63:2316:0:b0:381:ac6:94a5 with SMTP id j22-20020a632316000000b003810ac694a5mr4164753pgj.501.1647031896028; Fri, 11 Mar 2022 12:51:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647031896; cv=none; d=google.com; s=arc-20160816; b=LC9FZwhT+XQQCBOQGKQzIZSPtCiWYQgnN00bBfQvTbsk+bJCKbUb5IUewrqFHv826E ROu1HAI53PuQDtBQnzwGa9IiHyov9llCc1oqWkmINc2ZS2Aq1JmLCdgqIKRXFLP4G9NB PNqUj9Lco6h2oJ2CBpQvKILI8DVaKOOm4QmIK6Sp/cNW/1KUkGt2MKRk1V7woyKvIz0W 1L6NIhn+7p4iIGvn+NfliWp4bpPnVFYWWzPCmbPBeECYet91pezPX/X8t3qNJ2jYDNm7 UHp93kMfkseBQRXcme00Bwr+MH6md8em4/FmlbWM249eFKlkfvklsZzg5Pp0I6sDmirc WYiQ== 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=KKinXJt7hCI4YpcWmOz6K5DlvGxO13aibVS8plGZoac=; b=FOgWGiUigDg+8cNnDlXhQB0m5jK6TW/pUh8yUd2gBMEkvoUQZJyIOgbcx9kFWn7L/+ w+O4Z96WRsyyo3PEzvHGIecCLvn7fwTGM5xybABGzIWYHnOILmnKgHuNWozE+tjqzPt2 VJWk7f7o6x7s42S6tqYYRGEsg0ZZIbydIC/xR+THI5AWJLS/SzUOsHw0EYl1kSRIQQyR lIXlh2r75BD+8kGuHiZIIMN+cgnZNjwlOgH3d2M0bhPAbiUCyOQE1nkIFJnj/7V5XtdQ 5IJt+TWMHcRz4W4WLaN74I0XsXdNurtqfIwTv/eoCOsc2T1COX+o8QzTvxgxbJ6F/XBB FIOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HqX+58Le; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 128-20020a630886000000b003652e4b3ef2si9038290pgi.265.2022.03.11.12.51.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 12:51:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=HqX+58Le; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B8F511E747D; Fri, 11 Mar 2022 12:44:01 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244971AbiCKAKj (ORCPT + 99 others); Thu, 10 Mar 2022 19:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230224AbiCKAKh (ORCPT ); Thu, 10 Mar 2022 19:10:37 -0500 Received: from mail-ua1-x929.google.com (mail-ua1-x929.google.com [IPv6:2607:f8b0:4864:20::929]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37C73E33B8 for ; Thu, 10 Mar 2022 16:09:35 -0800 (PST) Received: by mail-ua1-x929.google.com with SMTP id b37so3025400uad.12 for ; Thu, 10 Mar 2022 16:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KKinXJt7hCI4YpcWmOz6K5DlvGxO13aibVS8plGZoac=; b=HqX+58LeRiyJ+PCpXDzYP5OEeCLu5dtyp+co5T4+ZSilbM/f/SuTyjR/SP5bq59Qje NYcX25WKgHXZ7PNbCD+j6iamM/KYFiq87pv9laSQydiTUaVkWdWBOL8O7VL5I/iQtT9r FDGvPa/3t0WOBLSafpitmkfSrZB3/mW3aphHPPlHNz05DljBZ3DuozCDGJSsvgRkA/W3 AzU1i1dkD4LVMUUI/BLlEVswagAzDBwpK+fmYbh1jYiRkTc7uCVBegSKSNnUzZploBMO wgdVfKk4l0YBvSpGa3nXIddYza4tfmO3p7JqdnzggMQgnms0/2cZUvYp3RRkMrj241nk C7kA== 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=KKinXJt7hCI4YpcWmOz6K5DlvGxO13aibVS8plGZoac=; b=4uWrrbvGCS7EvwZ3yIctI0pL7Iw+moplldtYhsEf1XUOZwq5L8SgNHB3nA7x55hz9S LavEWMJ6QzQz3CJyjptDh2E/QPUaVtTXH7an0S4KHtpW17CFhBuXedB15Cc+FWBd+k5j 7McLUjAALRSDIGUVnveubCPI7Rtiqs5uba1pceBXDWGP1XSDCS5ESkOPIl1ls+lE5W2y 0D2Rf1OjJCQ2iD9k7bkAJnyg/kvk/yrObARDf5dag36IsZyg3c6zM6TXfMhUdvPrXxn+ N07hFpWPVUBqzMSa8Vot9gzlfG9jm1YS9OqirA7os/puixrXIUpvwGVVq2U8Ow8nlQb5 t/Wg== X-Gm-Message-State: AOAM531G8w8RSu3jXSErX2NdJELOxpIKP3aCS9Jm//fs3BHcTvoCaS7u fh8rY46fEBeOuFSt02CdzIv2KuitCJmkBqj6ag6fGA== X-Received: by 2002:ab0:4d52:0:b0:34c:41ce:275b with SMTP id k18-20020ab04d52000000b0034c41ce275bmr3638164uag.19.1646957374015; Thu, 10 Mar 2022 16:09:34 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Yu Zhao Date: Thu, 10 Mar 2022 17:09:22 -0700 Message-ID: Subject: Re: Regression of madvise(MADV_COLD) on shmem? To: Michal Hocko Cc: Minchan Kim , Ivan Teterevkov , Andrew Morton , Linux-MM , linux-kernel , linux-api@vger.kernel.org, Johannes Weiner , Tim Murray , Joel Fernandes , Suren Baghdasaryan , dancol@google.com, Shakeel Butt , sonnyrao@google.com, oleksandr@redhat.com, Hillf Danton , Benoit Lize , Dave Hansen , "Kirill A . Shutemov" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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, Mar 10, 2022 at 2:01 AM Michal Hocko wrote: > > On Mon 07-03-22 13:10:08, Michal Hocko wrote: > > On Sat 05-03-22 02:17:37, Yu Zhao wrote: > > [...] > > > diff --git a/mm/swap.c b/mm/swap.c > > > index bcf3ac288b56..7fd99f037ca7 100644 > > > --- a/mm/swap.c > > > +++ b/mm/swap.c > > > @@ -563,7 +559,7 @@ static void lru_deactivate_file_fn(struct page > > > *page, struct lruvec *lruvec) > > > > > > static void lru_deactivate_fn(struct page *page, struct lruvec *lruvec) > > > { > > > - if (PageActive(page) && !PageUnevictable(page)) { > > > + if (!PageUnevictable(page)) { > > > int nr_pages = thp_nr_pages(page); > > > > > > del_page_from_lru_list(page, lruvec); > > > @@ -677,7 +673,7 @@ void deactivate_file_page(struct page *page) > > > */ > > > void deactivate_page(struct page *page) > > > { > > > - if (PageLRU(page) && PageActive(page) && !PageUnevictable(page)) { > > > + if (PageLRU(page) && !PageUnevictable(page)) { > > > struct pagevec *pvec; > > > > > > local_lock(&lru_pvecs.lock); > > > > > > I'll leave it to Minchan to decide whether this is worth fixing, > > > together with this one: > > > > There doesn't seem to be any dependency on the PageActive anymore. I do > > remember we have relied on the PageActive to move from the active list > > to the inactive. This is not the case anymore but I am wondering whether > > above is really sufficient. If you are deactivating an inactive page > > then I would expect you want to move that page in the LRU as well. In > > other words don't you want > > if (page_active) > > add_page_to_lru_list > > else > > add_page_to_lru_list_tail Yes, this is better. > Do you plan to send an official patch? One thing I still haven't thought through is why the A-bit couldn't protect the blob in the test. In theory it should be enough even though deactivate_page() is a NOP. 1. all pages are initially inactive and have the A-bit set 2. madvise(COLD) clears the A-bit for zero-filled pages (but fails to change their LRU positions) 3. the memcg hits the limit 4. pages in the blob are moved to the active LRU because those pages still have the A-bit (zero-filled pages remain inactive) 5. inactive_is_low() tests true and the blob gets deactivated??? The last step doesn't make sense, since the inactive list is still very large. Thanks.