From patchwork Wed Oct 18 08:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huan Yang X-Patchwork-Id: 13426605 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 8652DCDB483 for ; Wed, 18 Oct 2023 08:22:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0917B8D0142; Wed, 18 Oct 2023 04:22:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0412D8D0016; Wed, 18 Oct 2023 04:22:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4B028D0142; Wed, 18 Oct 2023 04:22:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id D5CE98D0016 for ; Wed, 18 Oct 2023 04:22:08 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id ADEA21CBEF9 for ; Wed, 18 Oct 2023 08:22:08 +0000 (UTC) X-FDA: 81357889536.10.08A43C4 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2137.outbound.protection.outlook.com [40.107.215.137]) by imf27.hostedemail.com (Postfix) with ESMTP id 9EF204000D for ; Wed, 18 Oct 2023 08:22:04 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=o8H5YFaB; spf=pass (imf27.hostedemail.com: domain of link@vivo.com designates 40.107.215.137 as permitted sender) smtp.mailfrom=link@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697617325; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Kbm+tAPuNX9y0d/P3X761goPM9TRc2wfK/slu7bysBM=; b=r3r/jsN3TMq3IhdJSFt/lTIrSw68YTlyNDNnkiFUO7hYeMP9DIxH2dqOQWiyiox1Olr9sg 8QA4p14Deuo3esq20D4evoef/C0uuHIZOf7gOEZVoQSmM+1MatYM/l3OjTd432eMoxaEod TpHe+Bz2XosZFPkULL9vTbXOFUdxOgk= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697617325; a=rsa-sha256; cv=pass; b=7keWvgKdwqpHSWMhl7PMQRl6N67jzQAGxNEf7D2J5Hbm15UUtgvlg+0mTvqFE9ZgI7UPg/ pXtg6NAA85XLxBAN4K7HVqCibK0nKaPoqsjhqokXCvWe1E0662qcKwonFShZAeZHIFZPZF mhyehOBa0Sz6vYtfcUmvuE2NSzjMpbs= ARC-Authentication-Results: i=2; imf27.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=o8H5YFaB; spf=pass (imf27.hostedemail.com: domain of link@vivo.com designates 40.107.215.137 as permitted sender) smtp.mailfrom=link@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mtlpaESAYWOAsBn+CjofFvVm/KVwYyK76qGdZSiqTpQjU9ze7DjMgl3JTO575BbfS6x1KmZO+IdU3oUB7Jdvkrv3h8N5nHdFdFAhjJmOi6GJ9jhSZKrHVrRqx1VVSMGYvKctK1pwvVRlEvtiLGglfavEBEjLRJvrhRoXoY8fQdSEUlApByReZ3gaqJAO9tFDWy7Sfsnc9zTtdyLOyr5U70H1sgD8m+xpshwqlFZs9Big3CT9coHeDUM8CGVItCB3cOoYdrdP0mnoq2cd8XEEHscymDcpHL5n1YILWDKi5lkyt7jllf5EfB/jbmCcsnkmhwpegDEvpG5Ij+/ASG64fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Kbm+tAPuNX9y0d/P3X761goPM9TRc2wfK/slu7bysBM=; b=J/UMNK5H0Mbh70O5gF//5OaPT38k93H8nFWe6d0xRFvhqn/ycRGmoouAme6juQi9fl7naH0VoH+I45PhOGJudgucwYYUUQMYEntprq+M7pIsCDCG59+Ues1//zbUxHw6RsWJaWm4eUgSzdWsKwCay9wBf46LWtKTHkgo8ykNcKy1GgMtXEhzWqJ5RYQxBoO4rsnZZ6Dy9S5G3KaZt0Ajwus4BpoKH004vnHhUAURLspV+0AY6Cf6nfvKmIb3A3Qk2TvaEuZODC1EUM/M+Rdntw+keipf6HtORa8WF8w0Fy49vuCJPzNcxuYf2fpKtXtK3Y2SbTgmguDpZv+p7GurGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kbm+tAPuNX9y0d/P3X761goPM9TRc2wfK/slu7bysBM=; b=o8H5YFaBkD+qUzcFhCqF4w/6BPfoiTgSMCZ9QodVK6v8q4JLamOSVXIL7IRL1E60oGGIDgmVD/zYz7220n55ipg2NymOC10gyPVzqbgT/74OvmfY6K3BXJUz746eNxmet6xnyvVw3naDXKlz0wnWGBA+y8h6eGLrOVs8ZY+3AR4DP8WCvcKIQz5YO7TVrTZu9Yexg50HYXBs/4ytA6qiJyerMu9Kxkw/qFlp34Xjpv2aWL2Cb57WIWoDCLSid/UdvPWJnvR8U1SFhR00E8PH/3Pxu9fQBvceaUwYtVu611AwnZin9NEs8e/1UCbDTc+682Q/P+YLR/+sNLI94ZQpvg== Received: from PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) by PSAPR06MB4391.apcprd06.prod.outlook.com (2603:1096:301:82::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.22; Wed, 18 Oct 2023 08:21:57 +0000 Received: from PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::40ac:5701:4617:f503]) by PUZPR06MB5676.apcprd06.prod.outlook.com ([fe80::40ac:5701:4617:f503%4]) with mapi id 15.20.6907.021; Wed, 18 Oct 2023 08:21:57 +0000 From: Huan Yang To: Yu Zhao , Steven Rostedt , Masami Hiramatsu , Andrew Morton , Huan Yang , Suren Baghdasaryan , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-mm@kvack.org, bpf@vger.kernel.org Cc: opensource.kernel@vivo.com Subject: [PATCH 0/2] some fix of multi-gen lru Date: Wed, 18 Oct 2023 16:20:58 +0800 Message-Id: <20231018082104.3918770-1-link@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR04CA0185.apcprd04.prod.outlook.com (2603:1096:4:14::23) To PUZPR06MB5676.apcprd06.prod.outlook.com (2603:1096:301:f8::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PUZPR06MB5676:EE_|PSAPR06MB4391:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a5946e0-1209-4f03-5fed-08dbcfb34af8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kOJvDUouTh+53/KINue2xCsWpxKzoMHmZYaA8Ggo5vtEPcrb9vTOgpYzYHvFJ/1kvrup5mOjcB69AEtGBZ/8DVBjqgwSiHJqaK+gWAuzzzp0pTscYmAa/iyk6nMnYrtadlOvdcxXVkEMB+6LR94zI8NNgn0ebLlaE5e87T30inrOkqm64hRyfdgX/gR4ni6PiFkL5GyPl8ARGIO2ZEG61rcTkqUoGhLrgOM5cFjm9XRzJ+6byJehc3hxTYRYVXEDqGNp8CUkfrpun/V+Ly1Q3xYzvFwIGq4sAvmGjrkVzAgtQGzoRBxyveLm8CW5VRrSiu+J9DBMvC+9JE8Mw+grcDf6ruRI4TtARTOFS+V6OogEI2pogWfzbi5q4W8sxu3UMRxGEakybBsreGwzfrRQjjQ2ri4fHO51+C+Tdz0UsbgiEusy93pZ07O7otFkZj6+6OhlxiUl0A2Kv2UmPGt75cyfbP/vVNVZLMCPgydWsAigTXUh6NszjNH4cqNOSr5hnnw8ixM7kO46x47g/avl+28qqxmKf8BywSBekk7ssNg6dRtLKMaQU+l3wZpqIy7i5qVJkoDdXZoH/csNkvb9NQa7VLWL9Veqq6kDGCvp1dDUKVt8UEhMFjXI98p26N5gabZwf9phdnxfRDwyG+iYfw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PUZPR06MB5676.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(366004)(396003)(346002)(39850400004)(230922051799003)(64100799003)(451199024)(186009)(1800799009)(7416002)(4326008)(8676002)(8936002)(5660300002)(2906002)(86362001)(36756003)(41300700001)(38100700002)(6506007)(83380400001)(52116002)(6512007)(6486002)(107886003)(316002)(478600001)(1076003)(26005)(921005)(110136005)(38350700005)(66476007)(2616005)(66946007)(66556008);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange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F2XJXcIUKj9gR6aLga+HiVlmdGVSJg18XBVu1zPlR5oIDocUxVbOGoAtBXDz7vDFrgexFvYirTfsln/IYdnbVeRHv4xKZD8Dsxb9ssiJH0LdLjYwQwXF6wGRMIntxXY/a73pLKm6MeMWwB1yroRLEJAOK+gISrHgU7UBYMH4kejuMEaRM/4n0jJEJ30iy+ChLQ4Ws2TWFpsVnJAI0Ptv+KL8D/HA6z8uDOeqd0HynK787QHbIAkbNPhI8GqwW0oj5qx07Yq5aBPd605zPbqh9iv7VWyPsNPaLkA47nwgy6UfyUDMH2PZgfhOQixW4cyuG3gN3obucJJdLIV+CAvRe++tXxaSQkJtKYl3+TNziXTxOTyOOtFdhGS1UNHwvtqteQe83/P38usv+Wv0EXZea5ASTLcptzSXfrjjvpIdb7Qii/Or5TY/W5sQSPcbFaKrVakF5gYiqOjTa9E7pNKBpmlg3TiU34lAualG/icOXIKQIC/eaEyB7XvXBqsF2a8fNVcufNlh/Xq/Xu9wVEnVCOx9 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a5946e0-1209-4f03-5fed-08dbcfb34af8 X-MS-Exchange-CrossTenant-AuthSource: PUZPR06MB5676.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 08:21:56.9551 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fZ5dkRou410tGNW2aZw4ozjrirJFFNjzAAhzvNodF/p9CyENts1+OYWIYWNJn+MBUh51uckWOQZ6pedKB4Yv5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4391 X-Rspamd-Queue-Id: 9EF204000D X-Rspam-User: X-Stat-Signature: h34io5r33mcpujopgydufmauerwpaezz X-R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TDsxTh+Lgdmk8c2Q8UUzR48DuvIthB/zru3g6PJsAKgVN5JCzw6ZEUyfCw+ayY55//AsW0y0Pc17sCKZTNOxHq11C1gLbNSkiZDijIBX5xtlWGvlKis0vPv4OOlow1d9D/hFVKQ4bWMmiJD03tVNWH3uCzy6cO74efBldD3MQSRydHF2EPPUg1yjxYWu/npk8ZsmSAsAxnomtdngjoet9guIuEtSYfMXvYKo310RUw/5zxzRcC60gX98UJpX X-Bogosity: Ham, tests=bogofilter, spamicity=0.000269, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: For multi-gen lru shrink_inactive trace, here are some mistake: First, nr_scanned in evict_folios means all folios which it touched in `get_nr_to_scan`(so not means nr_taken). So, we may get some info from trace like this: ``` kswapd0-89 [000] 64.887613: mm_vmscan_lru_shrink_inactive: nid=0 nr_scanned=64 nr_reclaimed=0 nr_dirty=0 nr_writeback=0 nr_congested=0 nr_immediate=0 nr_activate_anon=0 nr_activate_file=0 nr_ref_keep=0 nr_unmap_fail=0 priority=4 flags=RECLAIM_WB_FILE|RECLAIM_WB_ASYNC ``` Actually, we don't taken too much folios in shrink. This patch use difference between before sc->nr_scanned and after shrink to replace nr_taken and pass this to shrink_inactive tracing. Second, also like above info, we can't get nr_folios going to where, actually in multi-gen lru shrink, many keep by folio_update_gen when look around or other promote this folio. Third, evict_folios don't gather reclaim_stat info after shrink list, so, dirty\writeback\congested stat will miss, and we can't control LRUVEC_CONGESTED or reclaim_throttle. Patch 1 aim to resolve first and second, patch 2 resolve third. Huan Yang (2): tracing: mm: multigen-lru: fix mglru trace mm: multi-gen lru: fix stat count include/linux/vmstat.h | 2 ++ include/trace/events/vmscan.h | 8 ++++- mm/vmscan.c | 61 ++++++++++++++++++++++++++++++++--- 3 files changed, 65 insertions(+), 6 deletions(-)