Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp128790lqb; Thu, 14 Mar 2024 07:15:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEIFbGIsRywsFDGBFiqsG/H/t1yfvo5Z+OOrsodNzpbzujBC1qlimQbPYrUAeIurl0h19JkXIuVVViSycDE4vHsCS/YZs93HACfYvyzA== X-Google-Smtp-Source: AGHT+IFow5xyPLXkCSRBt/omFBuzVFr/CIcRnV9dgc17PfsTK4f5lcfXPHGm8AhfDOhCpc1iqPp/ X-Received: by 2002:a05:620a:558d:b0:788:63c1:49f6 with SMTP id vq13-20020a05620a558d00b0078863c149f6mr836512qkn.45.1710425752703; Thu, 14 Mar 2024 07:15:52 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wg9-20020a05620a568900b00788620ed003si1568146qkn.232.2024.03.14.07.15.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 07:15:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@oppo.com header.s=selector1 header.b=IClft8te; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-103371-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=oppo.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 614801C20923 for ; Thu, 14 Mar 2024 14:15:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 530096FE0A; Thu, 14 Mar 2024 14:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="IClft8te" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2135.outbound.protection.outlook.com [40.107.255.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E61F6EB73 for ; Thu, 14 Mar 2024 14:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.135 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710425746; cv=fail; b=NcgHzDk+P1tr99Ye6BGMDOJp2PQVOt+duGmWqceuk/4anzU12ayimdMYJxTNwQ4DpfvikD8ln1pHGq+wCciRUQMEg7U2ngBJ0fIqjYjLHmeYeUm2tsSuWPhOgxSiQwJiS7UiDX/wdTl6Ry8ysDvRaN84m4ei1ttwRBoxAzSF3rA= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710425746; c=relaxed/simple; bh=V+JUXSGQNyoQ/O1A5k9aUYpXfhy4xtp/OIzIgoDEslQ=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=MvC220Tvr8xRtWFGbMYJxMEAKVOQbr+m6GYAFjEDQ9ov05pvQoaDb3p3aT+BQBk86OmLhuzkoDnOMHSG2bFuvAjZXDDT9cdjWlx/ZODuDKjLpcLfiRZHLI6gLBmBpHjjOvflBxuttXocsmV3E9FC/Ztrtiq3grlFyh4F2qfmwrc= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com; spf=pass smtp.mailfrom=oppo.com; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b=IClft8te; arc=fail smtp.client-ip=40.107.255.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oppo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H3Qdv+bF9KEACAdcI8sd4A4Q+K1Iglw9iF9ADUoMySjdM2tu1Ecxiebf8nHlZ6RjGxage3XM8FK6NXSL/Vr5mixsJ5+WAcqnuz/ftoGVHZ8OBx1ya80vwcwVH1KM6MYYJZEDSSJCAwdFqsg4+8uNwx6dUIDoNgM5pDSvpB+wjm4Ijn3y4u8C0g+I41sXxMGa42eBE91CLSNNg4Jnq3k/dj8lbE+3cPG9YWhoMscgmTnL1jF8CDLxvUDuaQUvJF+ztMR44aOPdYhKq/fidsNl3MFl6FGTRZ83DBF+3NJE7As09MV6Tbv6+A7Vt7XzSIeOHULvPTTXRuZKGmlaJwLIwA== 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=qdTeTxUTc7bvID5bSUOaCMoO/h8AUVtgfchyzcDc7sc=; b=cLDUsc1yp3BzGEOVmpL4EdB2OsKoVyuCOzStvvPsraJ7tBkSd9TS/m9mpOPOGB089aBfbw1FBjH4wAIOMlcC3GX3f8IrsHd7gwlpsRSEvilidUydrc0jhhD9zCk+RUbh2IKgppEGOw2ihymO41VYZv48f6zlVs8LzLNPCt0dzBeDLD6IiefKz1EWhPSv8992F6066EAzrRLOdleN+Sq6uJeCYH1ijttEsI3+IFs0eTDTkJEM6TDm8c1E3pstneUGgSf8jATBo+5FqETRTDfxtGD5srf1dU2gYm7y85G6wn5a3tjPkOqc4B/QN8+sVsq7o1PZEohyHCBtUSvNwnpBdg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=oppo.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=oppo.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qdTeTxUTc7bvID5bSUOaCMoO/h8AUVtgfchyzcDc7sc=; b=IClft8te39aCGO78B5CahmVNSMTqFsT833j3lj/njhN6PDWgzvq3mUy68wpzyhK6bYkKqrgolpH9Q1JFmHHeM6o/L60/X658WdyBkG0dCx74yzETv1fCgfNxs+L9ApT2Ud65BwVs8X1yQ9c3XuYQcl/AUV9cbRb7llXpEF/sN64= Received: from KL1PR01CA0157.apcprd01.prod.exchangelabs.com (2603:1096:820:149::18) by TY0PR02MB7105.apcprd02.prod.outlook.com (2603:1096:405:8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.33; Thu, 14 Mar 2024 14:15:39 +0000 Received: from HK2PEPF00006FB3.apcprd02.prod.outlook.com (2603:1096:820:149:cafe::8d) by KL1PR01CA0157.outlook.office365.com (2603:1096:820:149::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.19 via Frontend Transport; Thu, 14 Mar 2024 14:15:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 58.252.5.68) smtp.mailfrom=oppo.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=oppo.com; Received-SPF: Pass (protection.outlook.com: domain of oppo.com designates 58.252.5.68 as permitted sender) receiver=protection.outlook.com; client-ip=58.252.5.68; helo=mail.oppo.com; pr=C Received: from mail.oppo.com (58.252.5.68) by HK2PEPF00006FB3.mail.protection.outlook.com (10.167.8.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7386.12 via Frontend Transport; Thu, 14 Mar 2024 14:15:38 +0000 Received: from PH80250894.adc.com (172.16.40.118) by mailappw30.adc.com (172.16.56.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 14 Mar 2024 22:15:37 +0800 From: To: CC: , , , , , , , , Hailong.Liu Subject: [PATCH] Revert "mm: skip CMA pages when they are not available" Date: Thu, 14 Mar 2024 22:15:16 +0800 Message-ID: <20240314141516.31747-1-liuhailong@oppo.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: mailappw30.adc.com (172.16.56.197) To mailappw30.adc.com (172.16.56.197) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HK2PEPF00006FB3:EE_|TY0PR02MB7105:EE_ X-MS-Office365-Filtering-Correlation-Id: be71050a-24d4-4d57-518f-08dc44313954 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4C7FiLAszmXzhkhYpc8zYvunlAwhVdP5ymcSY1WgCE/Q6srT7ktKv/o8M6Z6FsroYtavhNFj9eLjHCkfY6HiEcZFUah9FFdNbJ8Mb9OyVNo+A0OnLzWE+okXy0qF8UrlUI0KwZNFYWBaGpjXx0eu0TgERM0epayjZp5GxA1M5BPtieXUIGRUDiHhrZWnpEfwqW29EwgN5ZJzBnyzi2E63Ojhuu1KaQ1psFKujBrTFnlZ57BXpWD7rVKLoz37c6BTlHCW/jPnP5gfxpT6JQNGbOOwF8yjhZJMtr944Y6swe7AbzedtRSgwedcbOG/Glqm78C02R/quPi/D90eiOfUlLaM5wXEvl+j+ON3s5KEsCujcRixw9vmk6eWK4+HSC6QmurzZ0dWWt4RornkS637Zf7TcsszmrOf+hHZJ9xowlfHpzPxgjf8z5xLf8Io2M0/r7ktF3n2Qw83WWwWe7/EcEyaeJ4sJ1F07aJKUz5UxLvqEorKBbHAvA5kJOX7kRlGx1WtBSyQtKI2+7/V2eRUqhEU0yxOD658dQH0oBKq/Kew4wCLk7c34+8Q//Fg6lYIdDj2nfXLxPJ016Ai73fL6mSZvO2zRejVNuEHSp5axeLU1oPEy0jUNGgyIiNPwOm5Sh7TijSqs1K3U+eAkXvJKPYYicvPRZySj6V/8W60fdMkcGpwVQD9HYkz9g2KLi6mRcJmCS7osvQ2z3N0T73woUIjsBWS+dlkirjkYBVIlyBATgHGBiXsxYrdjTbfWizn X-Forefront-Antispam-Report: CIP:58.252.5.68;CTRY:CN;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.oppo.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(82310400014)(376005)(1800799015);DIR:OUT;SFP:1102; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2024 14:15:38.3962 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be71050a-24d4-4d57-518f-08dc44313954 X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f1905eb1-c353-41c5-9516-62b4a54b5ee6;Ip=[58.252.5.68];Helo=[mail.oppo.com] X-MS-Exchange-CrossTenant-AuthSource: HK2PEPF00006FB3.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR02MB7105 From: "Hailong.Liu" This reverts commit 5da226dbfce3a2f44978c2c7cf88166e69a6788b. patch may cause system not responding. if cma pages is large in lru_list and system is in lowmemory, many tasks would enter direct reclaim and waste cpu time to isolate and return. Test this patch on android-5.15 device and tasks call stack as below. Task name: UsbFfs-worker [affinity: 0xff] pid: 3374 cpu: 7 prio: 120 start: ffffff8897a35c80 state: 0x0[R] exit_state: 0x0 stack base: 0xffffffc01eaa0000 Last_enqueued_ts: 0.000000000 Last_sleep_ts: 0.000000000 Stack: [] __switch_to+0x180 [] __schedule+0x4dc [] preempt_schedule+0x5c [] _raw_spin_unlock_irq+0x54 [] shrink_inactive_list+0x1d0 [] shrink_lruvec+0x1bc [] shrink_node_memcgs+0x184 [] shrink_node+0x2d0 [] shrink_zones+0x14c [] do_try_to_free_pages+0xe8 [] try_to_free_pages+0x2e0 [] __alloc_pages_direct_reclaim+0x84 [] __alloc_pages_slowpath+0x4d0 [] __alloc_pages_nodemask[jt]+0x124 [] __vmalloc_area_node+0x188 [] __vmalloc_node+0x148 [] vmalloc+0x4c [] ffs_epfile_io+0x258 [] kretprobe_trampoline[jt]+0x0 [] kretprobe_trampoline[jt]+0x0 [] __io_submit_one+0x1c0 [] io_submit_one+0x88 [] __do_sys_io_submit+0x178 [] __arm64_sys_io_submit+0x20 [] el0_svc_common.llvm.9961749221945255377+0xd0 [] do_el0_svc+0x28 [] el0_svc+0x14 [] el0_sync_handler+0x88 [] el0_sync+0x1b8 Task name: kthreadd [affinity: 0xff] pid: 2 cpu: 7 prio: 120 start: ffffff87808c0000 state: 0x0[R] exit_state: 0x0 stack base: 0xffffffc008078000 Last_enqueued_ts: 0.000000000 Last_sleep_ts: 0.000000000 Stack: [] __switch_to+0x180 [] __schedule+0x4dc [] preempt_schedule+0x5c [] _raw_spin_unlock_irq+0x54 [] shrink_inactive_list+0x2cc [] shrink_lruvec+0x1bc [] shrink_node_memcgs+0x184 [] shrink_node+0x2d0 [] shrink_zones+0x14c [] do_try_to_free_pages+0xe8 [] try_to_free_pages+0x2e0 [] __alloc_pages_direct_reclaim+0x84 [] __alloc_pages_slowpath+0x4d0 [] __alloc_pages_nodemask[jt]+0x124 [] __vmalloc_area_node+0x188 [] __vmalloc_node_range+0x88 [] scs_alloc+0x1b8 [] scs_prepare+0x20 [] dup_task_struct+0xd4 [] copy_process+0x144 [] kernel_clone+0xb4 [] kernel_thread+0x5c [] kthreadd+0x184 without this patch, the tasks will reclaim cma pages and wakeup oom-killer or not spin on cpus. Signed-off-by: Hailong.Liu --- mm/vmscan.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 2fe4a11d63f4..197ddf62019f 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2261,25 +2261,6 @@ static __always_inline void update_lru_sizes(struct lruvec *lruvec, } -#ifdef CONFIG_CMA -/* - * It is waste of effort to scan and reclaim CMA pages if it is not available - * for current allocation context. Kswapd can not be enrolled as it can not - * distinguish this scenario by using sc->gfp_mask = GFP_KERNEL - */ -static bool skip_cma(struct folio *folio, struct scan_control *sc) -{ - return !current_is_kswapd() && - gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE && - get_pageblock_migratetype(&folio->page) == MIGRATE_CMA; -} -#else -static bool skip_cma(struct folio *folio, struct scan_control *sc) -{ - return false; -} -#endif - /* * Isolating page from the lruvec to fill in @dst list by nr_to_scan times. * @@ -2326,8 +2307,7 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, nr_pages = folio_nr_pages(folio); total_scan += nr_pages; - if (folio_zonenum(folio) > sc->reclaim_idx || - skip_cma(folio, sc)) { + if (folio_zonenum(folio) > sc->reclaim_idx) { nr_skipped[folio_zonenum(folio)] += nr_pages; move_to = &folios_skipped; goto move; -- 2.34.1