Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28023956rwd; Tue, 4 Jul 2023 11:28:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlEogEVt8HR3xCbgAk1/l03Pb3CBF7HfzLpyYb8/nxWyQWANMwyYUOfMU4+DuNhwjgQbt7T9 X-Received: by 2002:a05:6a20:38b:b0:12e:7a8a:3793 with SMTP id 11-20020a056a20038b00b0012e7a8a3793mr5362401pzt.44.1688495317384; Tue, 04 Jul 2023 11:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688495317; cv=none; d=google.com; s=arc-20160816; b=i44CsGu08+iIh1eebJ5dJoxKNuRQS+UFi2z88TjAdY5glo/84ujzDZuA7kZZdoCItq UI4phtPMlvhCi22fZ0hIXo0haoeqm7tJLob0q4Xvw6T8lMYBfVPvJ9YwVJ5MD0KnGvtd OO9lMuyGgbefajDl/TxRaN09nAObMls+c5Zy5p5oUxdb9+douFxVvBpxbeBDu43ZmmY+ vyFKY4YN5KtN6qNSMXxOyIVpzQsvHRpaf1C2nE/+TpIm4SzBd2ZuO1lOHpSaUxjKZ10e QRXHn0++P2K5VjqwWwlrTctMDkVfkrJt4aWifuIVhh1V81G/KYp5vEIuUegvWioc9wc5 epbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=uRla7TvS6Xyca7BJIrqXLtu50EXCq8Mbvqiwa5vRgRY=; fh=M8l9bG5Qn/XYdeRSC8I2ykZubMYosmv32nW3/9K+mFc=; b=xVMJoMFNAC5AI0+uSEpftGlm6Gh5GYjxACwvBkZjtH8cqTfJ5WQC8LBdGjvV+ahoxA bVN/nUkePvT6cuJPz1Xo4n0GKNTApNmsItfkcT+tZfRKBL7elyo442rsH9fBcF246oQu Q1oE1IaS93bk2mN13oZNh4kPhHgpG0Zsp+w8gYIIsMiBwU1/Ki36Frir4C/e3bg1mN1Z lonF1xqKe5+5QVie1+kOwTytwPeZDFRkfOH8Rr0do1l+JaLstCGbeUWV9D4ywMTCaxYC vaRxNLQdegGG9szFqzDqfGR3Ma06AL5fmJeUvja9m9eTjx/0sCU2Lxc37aOw435J538r PEqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=LiSYfNW4; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l7-20020a170903244700b001b864e1a02asi8051115pls.393.2023.07.04.11.28.24; Tue, 04 Jul 2023 11:28:37 -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=@linux-foundation.org header.s=korg header.b=LiSYfNW4; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231454AbjGDSHD (ORCPT + 99 others); Tue, 4 Jul 2023 14:07:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230318AbjGDSHC (ORCPT ); Tue, 4 Jul 2023 14:07:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB2910C9; Tue, 4 Jul 2023 11:07:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3577861329; Tue, 4 Jul 2023 18:07:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2238BC433C7; Tue, 4 Jul 2023 18:07:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1688494020; bh=ax5aSQO7Q8i6scQMJDEtYLdG7HxPbixeLmpQBL1NGoo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LiSYfNW4TUnYtrQLCm6LWhvyq7sD/au+ZwfSvS7XN04La/WLKynldo0dtKtmTTBwL WunDie3WP/NVO2OTkEben6uoo40mXyy3iL4tIc0/SXP+KDsfcah/LL3k2H6Nid4f1F iT9+PXkbHIQqe5sPUk5oPnCMOivXMUqefaaSpfF8= Date: Tue, 4 Jul 2023 11:06:59 -0700 From: Andrew Morton To: Andrew Yang Cc: Alexander Viro , Christian Brauner , Matthias Brugger , AngeloGioacchino Del Regno , , , , , , , linux-mm@kvack.org Subject: Re: [PATCH] fs: drop_caches: draining pages before dropping caches Message-Id: <20230704110659.3e1de8001f9208e7278352e8@linux-foundation.org> In-Reply-To: <20230630092203.16080-1-andrew.yang@mediatek.com> References: <20230630092203.16080-1-andrew.yang@mediatek.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, 30 Jun 2023 17:22:02 +0800 Andrew Yang wrote: > We expect a file page access after dropping caches should be a major > fault, but sometimes it's still a minor fault. That's because a file > page can't be dropped if it's in a per-cpu pagevec. Draining all pages > from per-cpu pagevec to lru list before trying to drop caches. > > --- a/fs/drop_caches.c > +++ b/fs/drop_caches.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include "internal.h" > > /* A global variable is a bit ugly, but it keeps the code simple */ > @@ -59,6 +60,7 @@ int drop_caches_sysctl_handler(struct ctl_table *table, int write, > static int stfu; > > if (sysctl_drop_caches & 1) { > + lru_add_drain_all(); > iterate_supers(drop_pagecache_sb, NULL); > count_vm_event(DROP_PAGECACHE); > } um, yes. I'm suprised that this oversight has survived 20+ years.