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: 13177010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D17CC6FD1F for ; Thu, 16 Mar 2023 06:00:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0EFE6B0071; Thu, 16 Mar 2023 02:00:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ABE7C6B0072; Thu, 16 Mar 2023 02:00:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ADAD6B0075; Thu, 16 Mar 2023 02:00:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8B9F76B0071 for ; Thu, 16 Mar 2023 02:00:37 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 32703A1329 for ; Thu, 16 Mar 2023 06:00:37 +0000 (UTC) X-FDA: 80573712114.21.B51D6FA Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by imf05.hostedemail.com (Postfix) with ESMTP id B9566100010 for ; Thu, 16 Mar 2023 06:00:33 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of yang.yang29@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=yang.yang29@zte.com.cn; dmarc=pass (policy=none) header.from=zte.com.cn ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678946434; a=rsa-sha256; cv=none; b=ZWdkGBeAseO1i1xBiHa4NwkBOB38IHvB1rX5AI30oeBl0BoIrFVi64qHdMUIr3QKEb/I1N vFfcNCX7FDsklAj3vOw2EsTv5mMDHkoLevITq7LyHkT0U/S/AfzLDesS9rBL21bNbWHejy SjCouX49U5vvzeyUyzifYaVkBGu6b1s= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=none; spf=pass (imf05.hostedemail.com: domain of yang.yang29@zte.com.cn designates 63.216.63.35 as permitted sender) smtp.mailfrom=yang.yang29@zte.com.cn; dmarc=pass (policy=none) header.from=zte.com.cn ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678946434; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=Rl8gOnkhdmPBRlY1jUYTNCduvFB/D/dXOZrFGMLfu1c=; b=nJGS/zInKrB7Fvdo/wzlWWFsPuaMmvCuuCz4qeG2tth4axnpVlf8vGYR82ofdPxjlGFTgx LbjJ9Oe0PWZ3ORQSshiROC4YEdeSOaju+WtFWoO+XEe3CPAJ3owKjyBNgfHnfRLmw+W2RU 3UtaLGm2VGTrc4+psa4FSzMCG7ihqYA= 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-Rspam-User: X-Rspamd-Queue-Id: B9566100010 X-Rspamd-Server: rspam01 X-Stat-Signature: 9adzrtmytje45te8on77t6gqo8dq5hdy X-HE-Tag: 1678946433-160736 X-HE-Meta: U2FsdGVkX18MemMastcFhwBzVEf55MWATPlfe+4twbZK5U3baOpwVvqSrEw9Siz/awIKiLVBWVchG/SzyLP2+7Cw3NNuHWS6mKxu2j0Eyjh1snS9MaQRqhoh6sWcKAtdtWUqGkqmtzkSVDnhttskN5uiKw3OwPIZFU6QhPFbucu47/GIY4OR6mLI+k9GF5X/6BaUGe8SgbPz66QrGx7QRAJA6TeOOV+juJTzDO9R0NWTS+N24+hdfbxEb+knK/viOq5Q1I4Sx+Us3yUo1FdzlRQrcS9HzOvy+Nis/fvRV7Q4CKCxmyDSUKMoIq62gRfAY/jjHICzuQBLLPk5/rFa/OTLQhBT0mMaYFMIBWspmumsEg7++AOWoc/4elZOU/27jnARHr7wSZPwLg33jerAa5xqK8ZMSJCzDHJ0LYvcOeiruRwcMSlPq/vTX2ORgYr4AWlauW6OZu8smHiJRVHCpAfD2/KdYOQdlUIsDSm2PqdinDnveci8rGDo1ZDpeSsPaBIfEL9AXTW6U8zEzmeEwN0+j+GWjHnE0QlSKiJJnz2f/wF7EvIBBckbzWNgLz8L9sWbrS8urHyqmJHqpX0E7EDcCGJxzg3HTrv1GltoypquxKuXx37ipf9K9bnN2BZkj69vNc2MY+9mkpfvAUugcjAMGS9H/kqmpHiNTZJ68/wJfFlB7Ws5B2TcECHGmJ/6tStl3v0L3NHvIiApRzJacuXG9dHlDi+q7kroWG5HhdxzCvzAUwgKfbNw+vnSGO56NXCNo/up/4GSQj8WdFI0OAUI+B38h319r2cowiLbwClvDdGOvL4kyMoCGnIET5QHl5s6IyQFxZsdqENyVFa4IavConqLWyBlPtFxtDXEaIspRclxPUxHw9IPlTXibpjkauWlagM19HdNfXi4Z5qJ2TB72e+d5+PvUt9awD3LBdnjsMUkPZdlRfhqCNtdbMXjZtvvG/eMXGYRz1hQa9g QGqnT2YU wrUZ+EO5735bQyITIfHWJf8TrNdDYliq3ynif9tpnxl6W+4MhFDr/+uF0QgY6ZmXoAhrCpQlVlMIrNWUgUZnzLlbcDRii05DuRr25n3MPPeIFFh16Vx/6RrYggpBREXEta97jWfdi7MA19MniFdjgKbW8Cjrp/o3koFA4yOABFsH/wuKMkN125uRnl+9op5gvVHLw00v2CmZlhC9MNRnjSa+4dXzjLZKOP9gr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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