Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32362051rwd; Fri, 7 Jul 2023 12:36:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFNyLHMf381RmwMKztd7aKxNVwKUyudPSYRo5zIBIS0GYJKg7vk9LeoU546MhOK57MGDSG3 X-Received: by 2002:a17:906:7a0f:b0:98d:5333:79c with SMTP id d15-20020a1709067a0f00b0098d5333079cmr4927181ejo.5.1688758600444; Fri, 07 Jul 2023 12:36:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688758600; cv=none; d=google.com; s=arc-20160816; b=jpdNR02rp86ILIhcZUHAaL+RfA46BjZ6ObEhMViNaIJcMp9bfJZceCITr9U7VfKvE4 v8gFTZCgueZhvVcFArZv173rUqUfP9IcBfxBkcyv3lp3EE/FS0+Far8j/iM7CfBh+0dM ku4n6Ulj8R7ZRcTjqNRXf0t+IuIYM6010gw1SrAYCxsdWb1t5VP0r3XWgkzD1qveRljG IhaqnrXnXC+Gs2xRmAp3KzG4FV2vqPKRqynVTzLyssU5LLQeTEe22LoLEoM2ItEcbGhi jA3WI13hUEC6PhEYVQS2VFOHNeFmlYcgan0cQRs1Q1ik4UPlqJhRVWbbHkrhgSk38QLf NpeQ== 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=Jizv26qEyW+isbIEvMSSY4iZewrX+DIUAlqHWWS/s3g=; fh=K3MlHgxON3qWpPsLkqYfbubxhz1cfYsk9YAWWYZYQY8=; b=Sc7scd7gcP/6MhsjcLDMe3sKAwawOfYGufc0Z2Iy8n72FphLy9ZJywDmXPWfnYqM3w aPBQiGhjupU828OgK13VWFCrNd7B5XyDr1PS1iBz/g3JDD80P5qLSzOdclU+pYSAMamO amnvCTMUoJMzNSIMfputc8pWUeNfJUqDWjK5mCgyn+b3/MabiFlwVO/yvTv22QB6AzAs hcyeeWwQcO5vBefMO20K9ymKUw+KKlQciOfHXPi+p8dPwsz42E3kcN+ls3dTQXB14uin XuWR7c6tOGmRRea0dZBrC+sYeswNfTHiLYVywEOfaD9zNupzon9N2sjhH/RMNc8RPPfr jbaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=huiLJISG; 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 gj17-20020a170906e11100b009889baa6a24si2481834ejb.1032.2023.07.07.12.36.16; Fri, 07 Jul 2023 12:36:40 -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=huiLJISG; 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 S229747AbjGGTJs (ORCPT + 99 others); Fri, 7 Jul 2023 15:09:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjGGTJr (ORCPT ); Fri, 7 Jul 2023 15:09:47 -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 F39AE2107 for ; Fri, 7 Jul 2023 12:09:33 -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 792BA61A3E for ; Fri, 7 Jul 2023 19:09:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B13E0C433C7; Fri, 7 Jul 2023 19:09:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1688756972; bh=bsWOwWbAgPkBn7wNRZCfCwO7B5F2fdglS9wNNhs6Ktc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=huiLJISGDK/hYqE/5V6ivNupwqho4dWwXwAxA4slsqQghRydE5umU/1VEXpS+hnZp kKkKcWIoD9DesPxWBno1uPce5ZjpSWgMl7AgxENL0G2HcM6kCy7J8FiKUs1tCwurqB 3xEBo1GUeY/gqR3rA8aaVSAZopgleBUSXs+fGs14= Date: Fri, 7 Jul 2023 12:09:31 -0700 From: Andrew Morton To: Efly Young Cc: , , Johannes Weiner Subject: Re: [PATCH] mm:vmscan: fix inaccurate reclaim during proactive reclaim Message-Id: <20230707120931.f2ec7f5c53c5dd2788afda11@linux-foundation.org> In-Reply-To: <20230707103226.38496-1-yangyifei03@kuaishou.com> References: <20230707103226.38496-1-yangyifei03@kuaishou.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 (cc hannes) On Fri, 7 Jul 2023 18:32:26 +0800 Efly Young wrote: > With commit f53af4285d77 ("mm: vmscan: fix extreme overreclaim > and swap floods"), proactive reclaim still seems inaccurate. > > Our problematic scene also are almost anon pages. Request 1G > by writing memory.reclaim will reclaim 1.7G or other values > more than 1G by swapping. > > This try to fix the inaccurate reclaim problem. It would be helpful to have some additional explanation of why you believe the current code is incorrect? > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -6208,7 +6208,7 @@ static void shrink_lruvec(struct lruvec *lruvec, struct scan_control *sc) > unsigned long nr_to_scan; > enum lru_list lru; > unsigned long nr_reclaimed = 0; > - unsigned long nr_to_reclaim = sc->nr_to_reclaim; > + unsigned long nr_to_reclaim = (sc->nr_to_reclaim - sc->nr_reclaimed); > bool proportional_reclaim; > struct blk_plug plug; >