From patchwork Wed Apr 19 05:40:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "zhaoyang.huang" X-Patchwork-Id: 13216379 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 257DEC77B73 for ; Wed, 19 Apr 2023 05:42:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69A408E0002; Wed, 19 Apr 2023 01:42:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 64A9E8E0001; Wed, 19 Apr 2023 01:42:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5391E8E0002; Wed, 19 Apr 2023 01:42:21 -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 448758E0001 for ; Wed, 19 Apr 2023 01:42:21 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F2D4814016A for ; Wed, 19 Apr 2023 05:42:20 +0000 (UTC) X-FDA: 80697045240.09.3AD6595 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by imf12.hostedemail.com (Postfix) with ESMTP id 5F8B740012 for ; Wed, 19 Apr 2023 05:42:17 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681882939; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding:in-reply-to: references; bh=3A5YzfJ4b/LcfKEwz4Fg8Q32Ha/hdTNa3JTjajnUYVc=; b=x178kxNTO/E5D6Xm8vq3n/dT+UpuWlX+Cujaiw7ngEHnkzqVv7r10KIcjfUpEs9OEFnJyq Ycq1opoadzefOTYfmC27FJKwlHUu0pJkQ3iflLDjD+yBklmjjNq8ccrQ92J8P5KrUg/IkB mLYlXALDBJ8yjDsmgoFHgeMICafkzJc= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf12.hostedemail.com: domain of zhaoyang.huang@unisoc.com designates 222.66.158.135 as permitted sender) smtp.mailfrom=zhaoyang.huang@unisoc.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681882939; a=rsa-sha256; cv=none; b=qwPjqnBlE4wnxukSfzGZgOULvWCQqQrNN4204B4npONcLyOhWuhHGKvZOS9qwueeGp8jj3 npi06KMQ6OFbNsRpKBhzMX87lM9TrGUwSzst6qeb9xcAZY4gpMToxrBTdN9qWgUIcqQrzG UldNl9sBIDTZmIOJ8z4SD0TWSoWHBfY= Received: from SHSend.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by SHSQR01.spreadtrum.com with ESMTP id 33J5ed12070031; Wed, 19 Apr 2023 13:40:39 +0800 (+08) (envelope-from zhaoyang.huang@unisoc.com) Received: from bj03382pcu.spreadtrum.com (10.0.74.65) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 19 Apr 2023 13:40:39 +0800 From: "zhaoyang.huang" To: Andrew Morton , , , Zhaoyang Huang , Subject: [PATCH] mm: skip CMA pages when they are not available Date: Wed, 19 Apr 2023 13:40:24 +0800 Message-ID: <1681882824-17532-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.74.65] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 33J5ed12070031 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5F8B740012 X-Stat-Signature: 344i65t46p5u56afnfh1ndxc657rsomq X-Rspam-User: X-HE-Tag: 1681882937-49218 X-HE-Meta: U2FsdGVkX18t8nH0GyQjmI+YDx7bZ3QwlG0PS5OfvuSNRadCaXD5euZ3ktpQ1wfomobQ49KGwf61Htt1irmWHqK/ZWJWd5eOcBvlVCAEMDvlY/AZFDnE6Vm2URFXYpa/dreea2iWGPZQJkeQFlmnSqsSFWqk3oOLSBs9XtaPncxs1cAUfLle9BA1NGtAZlToOo3ilyowP/F7iPBYDnX3IqmcQxjBvJ4JrFQGAgPB/jBxv2vHCv8HX3qG5XzystNnw5I6hf99RVWx8UtqYbON3U3G+v85UqRYJSMcaNLC8u8RHD8Lz3/kDefrEcCjpR3F8TX7l7c9KJHbA9fxq93pHm+cw7wOGtekLXRwGzYaZ0Pp4VssuLiGCrWtPoVSwqywhFbGuUfvoRgCJtZY6Kru5Zu5bAFVbw20nk050MHxjw4FLX3wTXMqbeaEuRm8+5Brhh1dhc4lT/XqYzZHSTVvABY412yfXLVIAQEwfijtKwoUOew7u/zF8NkWOeCWT92/VjNz5snwJtztNf+uiQWATR2+EWFYCYy0QyjL6yOqW7BSGyuzh88xfI+S+pZRjs+vHYFXU31MQ9msUcdm0GTtqkskz+HQz8SKpl4bN/5gU70bwq6cRdW4xucfFoMIKOHCJZS0n7+ebMShk1YRUw7IS/25tk8QFuignmJhqbXqvdBvGvUA1yGNC+9a/j86KPRwyphg0RoUg8PBQ17ou4ZvHRy2lc0dEOqWCIMp5G8h1oOtf5t5w89Jz1GTCN9dj1Gu/yJH0O5vcfUOHfQof6vcP8iGzS4ND0kz8FpdxvtkvRu4tybrGHqg4l6jYfjGabYj8yyzbWciEfyEibY39CfMdoABWI8mrUuw/WpDOED8QdXOi8innzHCZqfLVUfMNBBFdMgUpKyeWiPniSAHdqdmyLt/gkShrrqZ0hCxnVwdLf7YZQdIsuH5OmoXOXQ8vSY999D0a4NxQPlD2WeW5Wz MoBllLdW 9pDxbVxy1QW8mi0jmcqXj4apwsDS6cJVSvie5BDhutmai7EbJ8yjdqpenMAVTi0O4eV/ghwnxVejVvrlJe0nJuTcXf+bLp/ij3+BCMOUGnJBWyHRA0ygED+m0p/evDq+wQXEIkMR63ifwiwSwVlCkOU0KmF/7omubDvtz8OTpArp51vkSXq1AYMIAGxDKDXUEO9F5VTb+24rLhy4srjTvxuwrg5ApEmPlggPDTuIEDkhSTwNIUaSrzPqTqjnKPcMbAjzPo1vg1vTOBFbNt/pOMGE+SQ== 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: Zhaoyang Huang It is wasting of effort to reclaim CMA pages if they are not availabe for current context during direct reclaim. Skip them when under corresponding circumstance. Signed-off-by: Zhaoyang Huang --- mm/vmscan.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index bd6637f..04424d9 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2225,10 +2225,16 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; unsigned long skipped = 0; unsigned long scan, total_scan, nr_pages; + bool cma_cap = true; + struct page *page; LIST_HEAD(folios_skipped); total_scan = 0; scan = 0; + if ((IS_ENABLED(CONFIG_CMA)) && !current_is_kswapd() + && (gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE)) + cma_cap = false; + while (scan < nr_to_scan && !list_empty(src)) { struct list_head *move_to = src; struct folio *folio; @@ -2239,7 +2245,10 @@ 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) { + page = &folio->page; + + if (folio_zonenum(folio) > sc->reclaim_idx || + (get_pageblock_migratetype(page) == MIGRATE_CMA && !cma_cap)) { nr_skipped[folio_zonenum(folio)] += nr_pages; move_to = &folios_skipped; goto move;