From patchwork Thu Mar 16 06:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 70584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp308364wrt; Wed, 15 Mar 2023 23:05:41 -0700 (PDT) X-Google-Smtp-Source: AK7set8JIjebZ/Aa69ZVBYg/li7am9/xEELXQCf48FnF8TuRLg/osVua+wAA2uQBmRsYMb+r8Og/ X-Received: by 2002:a17:90b:4c85:b0:237:b64c:6bb3 with SMTP id my5-20020a17090b4c8500b00237b64c6bb3mr2824577pjb.11.1678946741579; Wed, 15 Mar 2023 23:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678946741; cv=none; d=google.com; s=arc-20160816; b=TSg7+kHO24bFm5cPkpxQHBbB8OobVb8ZYP4dJul+iCNZx/OKdlOTVFMlVEEpltau2G 5kmgrcEJS7KILQnwqPTXhr+5h/hoYsYuWaxGy4cuZixIGxDvNvI94w2Krnt/GT9E850H zhPURq8iZXLZksszvklSSJSGdxlCX96pJApe0/PhIAmgAl7MuyCgsEx0uYvKC8DOpPV3 ccVZDP6sx/MR9+At+Hl1k78kkAYLG8U9DJGTEgteGnhllRmPz76/6DtEA4smACI0IuD9 R9OQdVRmZKkhnkLoGl6NdHKxamKEr6kpAYJdhxRBchVZaxQcPlL3uwtk55BycMcv0ApV Nt/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=Rl8gOnkhdmPBRlY1jUYTNCduvFB/D/dXOZrFGMLfu1c=; b=VIZZrwJl7ngM8JzrCvRwSRdqziuwe/q/eeqESxuOXdhkQd5OvyRuGSK6LB3w5Qxc1F +r92fnlrsJnG14Q/u+3DZy0rmf2qZurhMLGw/hcUKu58xfgcAonBpNIOqF9Hf/3bzOkH klB/w3yUirWEcc0S4RjvXxXIuDtZEUeAvnDjnxxxifL/6sZdEpI9GPPo6iVnN6OQtZ0q z+KBvpzIhFWUX29vpkWrV0pSYK5Pn6OkLDesOiQGQy3dlfwAuIXNc95o3IMFyHNRcaiy oB8ATHkN1glXmvj/mZBAlYIxWIDsMsHksCXctPg/0VXQfr7K6qsYl36qgt+o4gA0Z9ON 9Ieg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x21-20020a634a15000000b00503151d6493si7025638pga.198.2023.03.15.23.05.26; Wed, 15 Mar 2023 23:05:41 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229532AbjCPGAd (ORCPT + 99 others); Thu, 16 Mar 2023 02:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229471AbjCPGAb (ORCPT ); Thu, 16 Mar 2023 02:00:31 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22DA220A3E for ; Wed, 15 Mar 2023 23:00:28 -0700 (PDT) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4Pcc7H0FTNz4xVnD; Thu, 16 Mar 2023 14:00:27 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl2.zte.com.cn with SMTP id 32G60Jtr045334; Thu, 16 Mar 2023 14:00:19 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp03[null]) by mapi (Zmail) with MAPI id mid14; Thu, 16 Mar 2023 14:00:21 +0800 (CST) Date: Thu, 16 Mar 2023 14:00:21 +0800 (CST) X-Zmail-TransId: 2b056412b075ffffffff827-b63a2 X-Mailer: Zmail v1.0 Message-ID: <202303161400212924424@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_mm=3A_workingset=3A_update_descrip?= =?utf-8?q?tion_of_the_source_file?= X-MAIL: mse-fl2.zte.com.cn 32G60Jtr045334 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6412B07B.000/4Pcc7H0FTNz4xVnD X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760503258154564069?= X-GMAIL-MSGID: =?utf-8?q?1760503258154564069?= From: Yang Yang The calculation of workingset size is the core logic of handling refault, it had been updated several times[1][2] after workingset.c was created[3]. But the description hadn't been updated accordingly, this mismatch may confuse the readers. So we update the description to make it consistent to the code. [1] commit 34e58cac6d8f ("mm: workingset: let cache workingset challenge anon") [2] commit aae466b0052e ("mm/swap: implement workingset detection for anonymous LRU") [3] commit a528910e12ec ("mm: thrash detection-based file cache sizing") Signed-off-by: Yang Yang --- mm/workingset.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index 00c6f4d9d9be..1a03c75811a3 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -111,9 +111,20 @@ * * NR_inactive + (R - E) <= NR_inactive + NR_active * - * which can be further simplified to + * If we have swap we should consider about NR_inactive_anon and + * NR_active_anon, so for page cache and anonymous respectively: * - * (R - E) <= NR_active + * NR_inactive_file + (R - E) <= NR_inactive_file + NR_active_file + * + NR_inactive_anon + NR_active_anon + * + * NR_inactive_anon + (R - E) <= NR_inactive_anon + NR_active_anon + * + NR_inactive_file + NR_active_file + * + * Which can be further simplified to: + * + * (R - E) <= NR_active_file + NR_inactive_anon + NR_active_anon + * + * (R - E) <= NR_active_anon + NR_inactive_file + NR_active_file * * Put into words, the refault distance (out-of-cache) can be seen as * a deficit in inactive list space (in-cache). If the inactive list @@ -130,14 +141,14 @@ * are no longer in active use. * * So when a refault distance of (R - E) is observed and there are at - * least (R - E) active pages, the refaulting page is activated - * optimistically in the hope that (R - E) active pages are actually + * least (R - E) pages in the userspace workingset, the refaulting page + * is activated optimistically in the hope that (R - E) pages are actually * used less frequently than the refaulting page - or even not used at * all anymore. * * That means if inactive cache is refaulting with a suitable refault * distance, we assume the cache workingset is transitioning and put - * pressure on the current active list. + * pressure on the current workingset. * * If this is wrong and demotion kicks in, the pages which are truly * used more frequently will be reactivated while the less frequently