From patchwork Thu Mar 14 14:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5YiY5rW36b6ZKExhb0xpdSk=?= X-Patchwork-Id: 13592479 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 40656C54E60 for ; Thu, 14 Mar 2024 14:15:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6BBB800B0; Thu, 14 Mar 2024 10:15:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1C4A800A9; Thu, 14 Mar 2024 10:15:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8BDED800B0; Thu, 14 Mar 2024 10:15:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 79B67800A9 for ; Thu, 14 Mar 2024 10:15:50 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0E9411213FA for ; Thu, 14 Mar 2024 14:15:50 +0000 (UTC) X-FDA: 81895843260.08.8B6D791 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2124.outbound.protection.outlook.com [40.107.255.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 9AA1740002 for ; Thu, 14 Mar 2024 14:15:45 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=IClft8te; spf=pass (imf17.hostedemail.com: domain of liuhailong@oppo.com designates 40.107.255.124 as permitted sender) smtp.mailfrom=liuhailong@oppo.com; dmarc=pass (policy=quarantine) header.from=oppo.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=1710425746; 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=qdTeTxUTc7bvID5bSUOaCMoO/h8AUVtgfchyzcDc7sc=; b=eh8/jVSIX/m/mvCA25ZQdFv5Sko7vRHXTACfmCfU1mKWC3KJHiWqfrkR2yMwjMOvhlPgDO xyI7zo9lu19ZLReamvfZv12/ASgMZnMFDmblG/11poTIP2874HwNwyKME/CYRAFfSJuF5Q PAOo7usIvaKlNpi8qTGZanaLrfU1WtU= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1710425746; a=rsa-sha256; cv=pass; b=XcpMl6byflKlPMhoH62tWV1t1oLX7puWJdaoldnpHhZ39vPlmGZeAza1P7oSD19iUCHjIO hlzGvp+UCLO4xvKLxKY5vh2h4r7dBZMs5nDxMOpA1BL16BAyb/T5HlBvWYM6eR2ViRcOC4 cVlhdmzBVO3eKwOf6KE/LaoWbmXcwUM= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=IClft8te; spf=pass (imf17.hostedemail.com: domain of liuhailong@oppo.com designates 40.107.255.124 as permitted sender) smtp.mailfrom=liuhailong@oppo.com; dmarc=pass (policy=quarantine) header.from=oppo.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") 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 MIME-Version: 1.0 X-Originating-IP: [172.16.40.118] 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 X-Rspamd-Queue-Id: 9AA1740002 X-Rspam-User: X-Stat-Signature: njyc73kg4fiih51xm9sza8sg34ysdsdc X-Rspamd-Server: rspam03 X-HE-Tag: 1710425745-510902 X-HE-Meta: U2FsdGVkX1+T/R4oEdyUmoPIkDUen3iykGXQEwNN/dxOfUoPws+TDEEPsNmn6I/E5bkDbBvJ2SI2+1H3wjaqD7D3FGpOOyVQBKqbp7sl0aUf/PwdEyCJScQWfp9MIDCj82FT+/g/gfDGUe0nr4Jt4Uk80ofqVqUHE5e0w1vBgmAYSUcloMCmW/t8yJ3sZ+JxDk6OrdxH+uVNk5CcdgfLrqsD7552nv1U83ar//WtPOjG5pfVfm+UxqB4umayfvtsEFo/Ddwku0H/Ea//wmA//X7f+nO4qdOQxXUhaw1GlfJwEKGt3OQc/XkOak95jBpK0IhyJnYee3gCpS+nk0Y72WHaEp1mAKL+UsTixdtUiUds8z4sdH93rV+h5Ng5ec28ezWOJ/M5GoGmG/SahPkjTYyn3JTBMxzHRJa8DAHqbZ/Mq9fKzib6dcGLz+Mb9/LHQgLKsAZm0HoKJ2RmliJS+nM4riYN9O7PO3d5ukfil3ECkLyz1V1+vd31RE6yIqZVdgXz/xcO/CXPaCHpnHCr+nWzIFnxS0dVMu5VUIq7DkV91HtgC5gtXZ+vYxEiE4+nNZezwIqWA1XjHzFrT4KXUY5nmR2BVDdrf0F1RoaxxXPB05of/uy0hh9UIKIOr1J5oGrbIid3/VhlWV53m/N4+j3mb3gSuGz3G11QlTBZyaYXByVsTl2UkHSDSiE+CsQFCiMyl81SvUo32LbtqL3MSAWsbS9b+VPpIE7gYRUB0hO5+mUQbBd4POxlksixjd7AIqTwHznv4Bjv575vPw4i+SKVeIe++rF2lpG9qGtwSPq+LUeYsHTxeMLKr6FniSTUpstW9bMri++4Wn8tszLUNrZ12vBSqpWofK4Z+FYuqIoUfV4KrBAcl8ezJvA2AF0q+25Pd9gFK6ku0HPiJ7gcIjd0cRNGL8+ceBTB8O+5KlPvPid4Xnf8vAI+JDZOXkb5AK8qsgpqLuSPfQn8nNB vgQ== 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: List-Subscribe: List-Unsubscribe: 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;