From patchwork Thu Oct 19 13:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Jiang X-Patchwork-Id: 155561 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp375020vqb; Thu, 19 Oct 2023 06:15:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEivz6Lopqm6A3FFHrOw2JbF2DFZc/E5oFbjC1wArTu0Ms/hLSxp/miTcS9VHo6J4ctHOpW X-Received: by 2002:a05:6870:7810:b0:1e9:b811:da13 with SMTP id hb16-20020a056870781000b001e9b811da13mr2877023oab.49.1697721319294; Thu, 19 Oct 2023 06:15:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697721319; cv=pass; d=google.com; s=arc-20160816; b=Mh/F8oEPuG0yW1FkvIMGMayO1jL2pgHcAQgXDxSQ5tjGoQecHCgI6uIivYxgQiEB9c 1UixTLgfEp9zlXXJN+Vr8DJHyfPt4wzNH2S3y9gLqUnZZt/PEjG0++iVj3B15IlOHota coUY9/fvuxyDfqoHFJGGNKxyV6iR0PfPPvQdK8UhkYryoxO8/uF8B5fR8xR8FEGYwfaJ +yFg536l9CujlP5t259vC7RwJRyqZEEJOqTk41Ah1olT8rnBVJcr3oZ9RWbbagBgJhEl T2V/Ajb+NGMgiQE/IPZx4rRUmA6TTBd9ld/9qDyNhYrVJumC6Lw0H+sxsmOAVxNJiyJo g+Ng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZVCbfCgY6uphg+FnjetqR8dr7AX+sQTlt8WYhEGY+o4=; fh=c2eYxmN/YNr2ouhP31X3BrePKjLzNfOQt6lh5667ppQ=; b=eqPhtLGVRMKQCWaKTmKU+XjtSb42AEherm7GbOeHE+suldTEn+Du+EDHzie9wGvRQY WUnyuiZQLebm0SgD/SwfuhjJ9AepWgwELv/t9aaMX/A5JvKKXOtMnrq4P8vL+b5hbIBB SGyklUnHb6/DVhiVzTbKl3nHKFQHimnU0h2PV/cDNgfLVH4VrPtJDvx5sriw17OUF/WG ActJydPF9UKAmEa4mEYHDiAT7A334vDXILWQuqcJyV1in7FmxRQ6LaQzesa5Miqv57jm N3GMjJHqOuwBoLXFnTP7TB0v1CM4GoKgwyd5KMm03OkTRMKfUXJTYWxwbWmoAEJL/wH5 jTyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=oIqedpkD; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id d10-20020a63f24a000000b005b3bcd9d7f8si4325996pgk.808.2023.10.19.06.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 06:15:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=oIqedpkD; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 7E003822D10A; Thu, 19 Oct 2023 06:15:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345839AbjJSNPL (ORCPT + 25 others); Thu, 19 Oct 2023 09:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345494AbjJSNPH (ORCPT ); Thu, 19 Oct 2023 09:15:07 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2102.outbound.protection.outlook.com [40.107.255.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D541498 for ; Thu, 19 Oct 2023 06:15:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E9QY1dxPHAn4Zx7A/ycRUF+TreMuWVmq14wK8cjQCxHwzZuob/1AahWf7IhDrD9YF0zvx1HSDKlGOPEH3fH7daKi5A+lncfcMNK9klvuCSnd8MvFEX7EnoAPDyiUxnoYRzIZo0tJhrelv7BSFEN5QpdAmzUyYLwrHzbVlSroF3DSt4rRYJ+LVVPElLurLIOcZBfNnAEE56hFo5yeJm/xp5N5bPuTY50Z08UCU8ROtA/rS297k9/D4RbfO1Bxi6U7soI8i9tuLjPYqbXL7FRRsDjfh6yJoJ3GLkTyi4pO5Zjo0M6+1hDOB7Kgb/A3LW3AwUhyLPaV5vRn6n6ZHSLjlg== 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=ZVCbfCgY6uphg+FnjetqR8dr7AX+sQTlt8WYhEGY+o4=; b=e3k6DNOjmaqI5xOkGIJddfVakZWwNT9CSwjad02flAKxdnbqiisN3/mmhXYn9I/z2Mpx5uXRw/lg/bUQASERb2nzG/mtZ+qzujz3QLz0EITgKOhmt67ISy7oDOUYqm9arw2nl2HUj2CbdYCCbC11c+I0XmcChB1AydzcT0lWTDhJhMC7EGzJN1S2reSnS4ZHgMDs82LlFf0j4t/boHxEWFPQL3TLpBnPZ6urFrvMs+GkSq6ZtVTtr7mXZa8yksKe0EINcKidgG34Xv3SYpWb6aHJiZxiyFNbVmhvYKN/USrx+TcAFF4CUAjorwmv10kyoMDUU6A3coeYVPAGBoTIqg== 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=ZVCbfCgY6uphg+FnjetqR8dr7AX+sQTlt8WYhEGY+o4=; b=oIqedpkDNK4kMlYxG3W+0qHZ3WxLlqIAymP4ElhFeUOZth6ZpMK3QtsQIo+xGU7jbvaYNbNTPuZUa4ZiLupSUqSqz07DV7mdsmJNN2sJ5OWG9jemYuNXIFNCYDafaVP038IoBD8GfEjFTyXpLDX0r+xAXCGN2P0ajauCB09+aZHWyJZpsve/FhrBb07TdVkuT+UKKkeIXgQiXKucGhaiPik/thd8kNKwAaC+G/GK9Dxh8ePYCsd/ODVb3SymjACgCeEXj006Le3GPi0zf2Mgg5H0JE6ehsf6INQVYrnpoxYUpu10Mm7Fgjayz3sVxT1PwvPaCs8NhUSjY1H3Ofcukg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by PSAPR06MB4470.apcprd06.prod.outlook.com (2603:1096:301:86::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 13:15:00 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::32d4:1209:6b36:86e5]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::32d4:1209:6b36:86e5%7]) with mapi id 15.20.6907.025; Thu, 19 Oct 2023 13:15:00 +0000 From: Zhiguo Jiang To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Zhiguo Jiang Subject: [PATCH v2 1/2] mm:vmscan: the dirty folio in folio_list skip unmap Date: Thu, 19 Oct 2023 21:14:45 +0800 Message-ID: <20231019131446.317-2-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 In-Reply-To: <20231019131446.317-1-justinjiang@vivo.com> References: <20231019131446.317-1-justinjiang@vivo.com> X-ClientProxiedBy: SG2PR06CA0252.apcprd06.prod.outlook.com (2603:1096:4:ac::36) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|PSAPR06MB4470:EE_ X-MS-Office365-Filtering-Correlation-Id: e188ed6c-90b9-43aa-0779-08dbd0a565a1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5DHS/WHs1IjQVsApHeLVYgiRFe1PDoN1JMEQ1Tm+SSh/b3tyWKrxj1aDtTI9fNZdf8/TgZNTRiNrvcw+PGh5eP+Y5f//GAkx4+hKK7tkQ0HOEKC0y6VDHgnHtDe2431anqcHSQ5lOXM9nGgUdnGJ+mxN5iqIqTGKxA5aiCruaQ0QtrzUXDJCcDTgn4mSnFpk8nvw2W6quRC48ZS6gnjW/LDDe2xX4x1DteYk9yLYOlodsgn/Bb7VzO5Sfmp6ViQqxWCUVUPpOY/1KNabBim90vAAES8hqI10gVZ+O+fko0QiQEolyLsJtjZB4Z70NYN+/O/Ziar4cvFGcoknffKBfUNSog+Oln5D9wJW4XsitJqL43CKh2tOr21xna+g5njiVByF2rwMs1EO09n3ziF6WS94VxRoZWbfmcjEvq7xHZnn/GnoHRNQ5z0YKPOaTWKKzRzMVcJhvwM1mW4+7qAhISF2czffYgnObThVkTSPy1GwNsNeDdYddPr6faOCdY5xqrBQ12bg+m4ool15+8pplGTKZZKy2KDDpOgLlzAZacBktpDDamlyx6XsDjVTXLHio4m1qA049M5pRaEkPd1njsq1p374wC5PqL4r05qJI0C895i6d0j58KS0axmphrg8SutSlFjaKIsCyXzwQbZuvQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:JH0PR06MB6849.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39850400004)(136003)(366004)(396003)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(6666004)(2906002)(52116002)(6506007)(6486002)(478600001)(41300700001)(4326008)(8676002)(8936002)(5660300002)(66476007)(66556008)(66946007)(316002)(83380400001)(36756003)(26005)(38350700005)(1076003)(6512007)(107886003)(38100700002)(2616005)(86362001)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5vB90dhy0ZXy0r62r028RWkd9HDcJdyhwICByWP3t+ryyUVcFix42Y9Uwo1eKhrZvdFJPYhPBepynrXuxetYI+hlgCrKok4vtgYKVGDhCo+4pKNjmRJy4eP0Ek5ir3BLpuyDRQODLBHkfLCg5CoRw0EXp7uv/YXsQNsEBG6xgoSIVlh71Ly4gOukGjM56CTZB+tHJFwsWiOzeIGR4eM8tZogP0yEGiriL90TyjHaJuIMuU1rxpKjYGxuFZb2U+wQYh9MWBKJIi2P4ebJkIK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yzK4g27iw/d4COEfVrdWMejqUK5XNc5hNhBetALAD7iCfxi6CfTSUBbl9TuYFCQ2vdboqGtnI58PKetWCXvj0H4+U8h2MexZHf/UdC3/cT4tu+YlhVZ2uiR6FtozVmoEwKNYlkuRSIOdQFJVREjg/KjY/grn18RsBsAQEM5uNfDXZq2c1pGYVzjNUB0cpCLnY1UbmNNvaPJfteKoOgjbNgpvzyTUElOZdYRTC6QwgYfFG+ir X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: e188ed6c-90b9-43aa-0779-08dbd0a565a1 X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 13:14:59.9075 (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: DSjMmEFfByqao/3v+0PEbPxtbWyxqjuSsF5XG7xvf3mYinAp2/q4z/H5Pbp1sbcjWnf5QTxd7BYuByQbS4d6Og== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4470 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 19 Oct 2023 06:15:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780189829988896842 X-GMAIL-MSGID: 1780189829988896842 In the shrink_folio_list() the sources of the file dirty folio include two ways below: 1. The dirty folio is from the incoming parameter folio_list, which is the inactive file lru. 2. The dirty folio is from the PTE dirty bit transferred by the try_to_unmap(). For the first source of the dirty folio, if the dirty folio does not support pageout, the dirty folio can skip unmap in advance to reduce recyling time. Signed-off-by: Zhiguo Jiang --- Changelog: v1->v2: 1. Keep the original judgment flow. 2. Add the interface of folio_check_pageout(). 3. The dirty folio which does not support pageout in inactive file lru skip unmap in advance. mm/vmscan.c | 103 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index a68d01fcc307..e067269275a5 100755 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -925,6 +925,44 @@ static void folio_check_dirty_writeback(struct folio *folio, mapping->a_ops->is_dirty_writeback(folio, dirty, writeback); } +/* Check if a dirty folio can support pageout in the recyling process*/ +static bool folio_check_pageout(struct folio *folio, + struct pglist_data *pgdat) +{ + int ret = true; + + /* + * Anonymous folios are not handled by flushers and must be written + * from reclaim context. Do not stall reclaim based on them. + * MADV_FREE anonymous folios are put into inactive file list too. + * They could be mistakenly treated as file lru. So further anon + * test is needed. + */ + if (!folio_is_file_lru(folio) || + (folio_test_anon(folio) && !folio_test_swapbacked(folio))) + goto out; + + if (folio_test_dirty(folio) && + (!current_is_kswapd() || + !folio_test_reclaim(folio) || + !test_bit(PGDAT_DIRTY, &pgdat->flags))) { + /* + * Immediately reclaim when written back. + * Similar in principle to folio_deactivate() + * except we already have the folio isolated + * and know it's dirty + */ + node_stat_mod_folio(folio, NR_VMSCAN_IMMEDIATE, + folio_nr_pages(folio)); + folio_set_reclaim(folio); + + ret = false; + } + +out: + return ret; +} + static struct folio *alloc_demote_folio(struct folio *src, unsigned long private) { @@ -1078,6 +1116,12 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, if (dirty && !writeback) stat->nr_unqueued_dirty += nr_pages; + /* If the dirty folio dose not support pageout, + * the dirty folio can skip this recycling. + */ + if (!folio_check_pageout(folio, pgdat)) + goto activate_locked; + /* * Treat this folio as congested if folios are cycling * through the LRU so quickly that the folios marked @@ -1261,43 +1305,6 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, enum ttu_flags flags = TTU_BATCH_FLUSH; bool was_swapbacked = folio_test_swapbacked(folio); - if (folio_test_dirty(folio)) { - /* - * Only kswapd can writeback filesystem folios - * to avoid risk of stack overflow. But avoid - * injecting inefficient single-folio I/O into - * flusher writeback as much as possible: only - * write folios when we've encountered many - * dirty folios, and when we've already scanned - * the rest of the LRU for clean folios and see - * the same dirty folios again (with the reclaim - * flag set). - */ - if (folio_is_file_lru(folio) && - (!current_is_kswapd() || - !folio_test_reclaim(folio) || - !test_bit(PGDAT_DIRTY, &pgdat->flags))) { - /* - * Immediately reclaim when written back. - * Similar in principle to folio_deactivate() - * except we already have the folio isolated - * and know it's dirty - */ - node_stat_mod_folio(folio, NR_VMSCAN_IMMEDIATE, - nr_pages); - folio_set_reclaim(folio); - - goto activate_locked; - } - - if (references == FOLIOREF_RECLAIM_CLEAN) - goto keep_locked; - if (!may_enter_fs(folio, sc->gfp_mask)) - goto keep_locked; - if (!sc->may_writepage) - goto keep_locked; - } - if (folio_test_pmd_mappable(folio)) flags |= TTU_SPLIT_HUGE_PMD; @@ -1323,6 +1330,28 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, mapping = folio_mapping(folio); if (folio_test_dirty(folio)) { + /* + * Only kswapd can writeback filesystem folios + * to avoid risk of stack overflow. But avoid + * injecting inefficient single-folio I/O into + * flusher writeback as much as possible: only + * write folios when we've encountered many + * dirty folios, and when we've already scanned + * the rest of the LRU for clean folios and see + * the same dirty folios again (with the reclaim + * flag set). + */ + if (folio_is_file_lru(folio) && + !folio_check_pageout(folio, pgdat)) + goto activate_locked; + + if (references == FOLIOREF_RECLAIM_CLEAN) + goto keep_locked; + if (!may_enter_fs(folio, sc->gfp_mask)) + goto keep_locked; + if (!sc->may_writepage) + goto keep_locked; + /* * Folio is dirty. Flush the TLB if a writable entry * potentially exists to avoid CPU writes after I/O From patchwork Thu Oct 19 13:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiguo Jiang X-Patchwork-Id: 155562 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp375667vqb; Thu, 19 Oct 2023 06:16:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGexmFtMbJQDx5wPKUlt9FZeP5ZZzxXf28AEnE3g3etowXrJK1xk+3ckTqhAq185/T+hQv X-Received: by 2002:a05:6602:3f94:b0:792:6cb2:e92c with SMTP id fb20-20020a0566023f9400b007926cb2e92cmr2506958iob.3.1697721373328; Thu, 19 Oct 2023 06:16:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697721373; cv=pass; d=google.com; s=arc-20160816; b=j0PrWDF/D4oszC39Eo/8fpyayazXC8GRI8L9xIMFG/H3Ehnawd3fXU+MIylt7ZJ983 M/x3YTe+gbefl1mTvP7e/I6BoIYTXUtrB41JxqZLMSAtMxzcVuYH5UPJQIz2FsBEHhz8 tVX6Ms9VuGsARhXUD7A2xXVRnRUiA3K3pT63Hxc6yZ1+lgk3pjqO0AixxDMBNn7ILBi1 xhR5lXkNVH5/DM71hhnzW+gdzbcvxm7Qmp4pftsfRJf7bIv7ZInC+Sa2S05MwQSNiiuQ wcKtl/0b8jNjKo8b1sZR2VGdNEYkYeSqLXbNRYMORAFkJV1z/QiG7ohroDcENZMSlfRl 8Ojg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G+W6fmJ72ArZzY33LmCyBv0xsV450yR0iejgRMpA4iw=; fh=c2eYxmN/YNr2ouhP31X3BrePKjLzNfOQt6lh5667ppQ=; b=ZaopU4EiGIbi2l3F37kGtOlAl05cRwPVR6OI8f9m79vjovX6fx6/OM9xxAe+WXClrl lV7+nGGjUl63nm5JDKnNU0WpN0/E2pgHgTnonel9twiUoL01egaaVebucpsNkdcDHcDL CqWq2WbDMgbcGZWrjA+z/+7JWsBJdu6zAE0sbgVCTOQmAqQ1qUrMniNnWahtRwtX/dk0 et2U2wDEBTOv2MxDJr33mU2aXw1uUVOrHsopPN4UQm8jkAbV0e/USIEHcZfYclESWJS+ 5oNaSPSiNICjr+ZxmvZyFbNpiP0sonXnm3v2lX3KVXAhpx3rc5YnEzbQOfX1EFITZ7sb +fBg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=E4OhPqtB; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f22-20020a637556000000b0057ab7f46381si2756031pgn.76.2023.10.19.06.16.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 06:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=E4OhPqtB; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 9751483A9FBD; Thu, 19 Oct 2023 06:15:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345860AbjJSNPO (ORCPT + 25 others); Thu, 19 Oct 2023 09:15:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233202AbjJSNPJ (ORCPT ); Thu, 19 Oct 2023 09:15:09 -0400 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2102.outbound.protection.outlook.com [40.107.255.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604C19F for ; Thu, 19 Oct 2023 06:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HVgxGL0IfKP5BsYpz2xx1YpLeAnl8FYLpbrfNP0ul8fUVvSArm/xcxGWsJpIIii4IKJa1Z2abtEFmtLz+o0A00z0cG8NViZJ8a0ruMD7cHZ8rTKAsN5MNCLIZ/z5wQZW4qThprcLx4eghi8TWeGChYwW/oKN3cBxewoOI9Js+lMKHFHknsSxRWYTNPgMUdr3q7VC2COjROEfrCF1315Ce6CKwL/tPNkNXY0aVsKI14ziAhKop2MiuinJaz+d72N08FfETO7H0kreImGCyiiuJsxUO4cYa+gIp1kJCLHqHF7pKTxkRZFS9tJQMh09ut6s3m+CnkwDehIiaE2SOF5C7w== 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=G+W6fmJ72ArZzY33LmCyBv0xsV450yR0iejgRMpA4iw=; b=WzlWUazOM12osh5dZOY1RC/azrBGdAVdhRuIQpmW5opup2SmM71J+JE8sv2F3aMC2oLwkhlA1ZFhgnAaJVxFzkCoNIYI7obxGwbMTePralZ7I7SpyHswxjNuoVv1b5cAFtZQCsCyrR/UOkF7qzeA29u4/HlMDBU83cxfiTyqlb+S5RTVw3QBeaHlJhoPM/f0gW+eF16jyJtGJEBpC/31o+itSYwwkx4PNDUid3XTf/eaNvRbHEpULb0wVpDZQ1ovcv8bpcw35WnFK64AyY3VOBeMeYoB1sIKKF7VwdaJtaifZzUL1Ztns+nyfKgG2G+y8CAMgNHDMm2m37WBTp4ZoA== 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=G+W6fmJ72ArZzY33LmCyBv0xsV450yR0iejgRMpA4iw=; b=E4OhPqtByr1T51mLLXH1xZ2x4OsE9PvykU4CF8skgj9maG53gv+7ef8uTutyME6CtW6cmhJqr9iLts5hv5rjEF79NoKMMRhDPsW8Sl3H7CDEtQt1cvoC9MNm8OC1TKdFjC/pYpM35N9XXlCm56dhhLaiKOFLaHjSwRPNuJXSszJKSk/e5H+qQMW3e42Vd6E9jVPMtRCzON3O0YMT2ixWLFLQh9S47aWctrH2j2vARYcdAknViRH+iKdQH8h8KMoGfR2TS/Bicw7tFQJBqPqpQuCZCOmsyxCuDtsKIfOrdzJ9i2d2fkbqbpAZxjIC0/zG9NgFOhk2GW1nlbDNEz++hg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) by PSAPR06MB4470.apcprd06.prod.outlook.com (2603:1096:301:86::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26; Thu, 19 Oct 2023 13:15:00 +0000 Received: from JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::32d4:1209:6b36:86e5]) by JH0PR06MB6849.apcprd06.prod.outlook.com ([fe80::32d4:1209:6b36:86e5%7]) with mapi id 15.20.6907.025; Thu, 19 Oct 2023 13:15:00 +0000 From: Zhiguo Jiang To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Zhiguo Jiang Subject: [PATCH v2 2/2] mm:vmscan: the ref clean dirty folio skip unmap Date: Thu, 19 Oct 2023 21:14:46 +0800 Message-ID: <20231019131446.317-3-justinjiang@vivo.com> X-Mailer: git-send-email 2.41.0.windows.3 In-Reply-To: <20231019131446.317-1-justinjiang@vivo.com> References: <20231019131446.317-1-justinjiang@vivo.com> X-ClientProxiedBy: SG2PR06CA0252.apcprd06.prod.outlook.com (2603:1096:4:ac::36) To JH0PR06MB6849.apcprd06.prod.outlook.com (2603:1096:990:47::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: JH0PR06MB6849:EE_|PSAPR06MB4470:EE_ X-MS-Office365-Filtering-Correlation-Id: b9920517-d3fc-42d2-a33d-08dbd0a5661a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nQhOuWlQ0oT2Q+AJCAaqD8oJwWDSLRd3fyAgqfst0sOxPMFYT/Kt7xColcxu5dlcm0LWd0Jk4M5qxnCxMgEB0DhQiC4RKIXQsIEbXPCcfztnCJPnoBOms4QevXO8c2C0nEwDWJCMGdSwmpQ+k1NGk69HmYjBQroJ48R5/Nz0CZmqsrXL3NT2tKDlncaYA232VWDDAn04yPou9HMs+ygM3ohFxRJFJ+QbuRW4I40JiV1YrolXdLGTAOQAej1RoymHfjWvQKnXPKXS1CeKJg2vXXzCVXI3VJTj6gX52RCmCS43ZWx3YlrZs5+RINKoVPQyRN/sj5xSh4DR1HeWsOwC9bhgensyOQIWVS4ZJycUigsel1HFModobdiz94+zQy0poMHI3uhxxxIdmIUdLWX7KbEZa+LKHahmScwDo4aDnHHM8uE2/SG4HfcYWccY8K70idBWcZ7runSiCvsLsdPs6gLDzXB/EG6MuttqQvtjzaOMNqK2Efqc3Fpr85NLfgtFXTJv50LvGchLDmME23ZzWEO3yU5fEUSO5K8j1g7pjOAdshCDlb11CrpaV4htI/dmB2hgNquAMor5n4hSc0/fb8DWJAzEm8BS1Gc10c9OhTiojyaz2p8vH+UT+OEM4jWhQFwOUlRrtIBKX9cbKChnuw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:JH0PR06MB6849.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39850400004)(136003)(366004)(396003)(346002)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(6666004)(2906002)(52116002)(6506007)(6486002)(478600001)(4744005)(41300700001)(4326008)(8676002)(8936002)(5660300002)(66476007)(66556008)(66946007)(316002)(83380400001)(36756003)(26005)(38350700005)(1076003)(6512007)(107886003)(38100700002)(2616005)(86362001)(14143004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y4uu7QOBAHDbWdWb5j5e3zRNghc670D7e1kMlur1BKKc1U4Fj0Ehi0vcRbVFrWPysdGoVLul9zXQQ85kA5jFPiVMxKBJEPDj4cuVhO6cs9nguHhfeJ2Pa9rfXiN9QOPvRnB82HEtYOdL/KW3/E6BezQLFlrIRXeiPLbtZihqC74pYQOAfUwF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XMvPS4KPn+I0uBGDPyjGUzJkURHQj0cesKea/KnkgMhzqvCUeCCcjyPZrw9F0RP5OL6ms7I4MTjlTAr6M8qU6YCrxUUFoTvdMFduJFSuNDZo9z1/DLHIVBp8u7OyrTJJtN8ITiOv8T2DWsi98NN++XvsKG8+qbOPrr8XzRB42x8IZFMSgl8WBNzi8xNDsO8bdaXqgr6RciqP8Ci5TBiIAERdcOCY99tf9pgj46N8POj2ZFT8H2ljWHHpTig1/sxAltp3lFCKDyyoAQrsWE1eU1nSgKfh2uClDfqy17DH5NYOBC+SZW0RwekYLKUndvFnN3TYz0Y0HwXQUvybrrCfPaWeXk6ueccEu X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9920517-d3fc-42d2-a33d-08dbd0a5661a X-MS-Exchange-CrossTenant-AuthSource: JH0PR06MB6849.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2023 13:15:00.5695 (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: beufrBEs7jxiCr+SCX/viJVePdCXPh5heSnT22NZQ+jQzxwrvJLsGgqAIJtdbk0hJ0S1sK+8zcutFnd0Fv3OGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4470 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 19 Oct 2023 06:15:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780189886704765238 X-GMAIL-MSGID: 1780189886704765238 If the dirty folio in folio_list which is inactive file lru is FOLIOREF_RECLAIM_CLEAN, the dirty folio can skip unmap in advance to reduce recyling time. Signed-off-by: Zhiguo Jiang --- Changelog: v1->v2: 1. The dirty folio in folio_list wich FOLIOREF_RECLAIM_CLEAN skip unmap in advance. mm/vmscan.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index e067269275a5..e587dafeef94 100755 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1225,7 +1225,10 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, stat->nr_ref_keep += nr_pages; goto keep_locked; case FOLIOREF_RECLAIM: + break; case FOLIOREF_RECLAIM_CLEAN: + if (dirty) + goto activate_locked; ; /* try to reclaim the folio below */ }