From patchwork Thu Jul 6 06:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 13303226 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 78FCAEB64DD for ; Thu, 6 Jul 2023 06:21:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 174BC8D0002; Thu, 6 Jul 2023 02:21:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1268F8D0001; Thu, 6 Jul 2023 02:21:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F138B8D0002; Thu, 6 Jul 2023 02:21:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E212F8D0001 for ; Thu, 6 Jul 2023 02:21:12 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BF42614021A for ; Thu, 6 Jul 2023 06:21:12 +0000 (UTC) X-FDA: 80980189584.15.666E2BD Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf16.hostedemail.com (Postfix) with ESMTP id 5E51C180007 for ; Thu, 6 Jul 2023 06:21:10 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Kh8zGare; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf16.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688624470; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/5Njrz3reCCviyX3u70/+8GUNgIGGwoM6m0K6lhTJsI=; b=kCYrA3IB1GuLEhtR1hOaKa6CzSKA4qsHV7R+oDWtU+cCeYMl0YvoDUMOMDFJdY+pcqOk7P DRLPtVxPZJN3iTCB9l4OhcuRV6HaSgvSqmSN2CUWcLmTsTMEL75cgJFyMrJRR5p91Wm9er BmJkdIV5fbBF//CfvMn4W6yIiDvWk1g= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=Kh8zGare; dmarc=pass (policy=none) header.from=ibm.com; spf=pass (imf16.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688624470; a=rsa-sha256; cv=none; b=WaTCLwnaGoVpBBxMOizRoFqPZIWL3QwfIxEaeirJaoDlpeghqFPJv5+PevCeUBmaP4eF6V tJqVI/+Zxyx4Kw6Wven+xsqO9q369qGDBtMj4CjJn/Pt5nM0zXeuyUnZ9lxv7pbTzoLkau e4VjmXmjsp+XxVemYEh8kDoCeLExUlk= Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3666H4kU026326; Thu, 6 Jul 2023 06:21:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/5Njrz3reCCviyX3u70/+8GUNgIGGwoM6m0K6lhTJsI=; b=Kh8zGare4EVaUwaDGNAygO6JSGvAk917ESBrKmqMsmFB7/ZN2xBXNXi79MueOSyTOxvz 0YJ8j3MdEmMh2dXrY+RizAlUvghRGhn7iXl/jjts99icZDREitF00mZukPUW8vizhsQs x1hadnBoqQEqfJdlnY33UAy/+0YZxBAbVj4ZKTVhpd8Efp23IQiky9kAn00+mP+wQd7J s6BLRRGjcKFTownahjJtTekGE7fcpUzIp5tRqT9hrVArZYOFuZbxJZ1ozmYVKjR2DU1y XO/srrF7SIB0dqypynjCaPCL3zUigVsFuiFZtTQy0BS1SZK7jwYGv1or2BVnIyq2+fZ8 Ug== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rnr7602mq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 06:21:08 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3666I2R1030053; Thu, 6 Jul 2023 06:21:08 GMT Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rnr7602mj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 06:21:08 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3665uM8H016351; Thu, 6 Jul 2023 06:21:07 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([9.208.129.114]) by ppma02dal.us.ibm.com (PPS) with ESMTPS id 3rjbs6m7dg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 06:21:07 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3666L5Ir36766126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Jul 2023 06:21:06 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A360B58057; Thu, 6 Jul 2023 06:21:05 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0F855805D; Thu, 6 Jul 2023 06:21:03 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.109.212.144]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 6 Jul 2023 06:21:03 +0000 (GMT) From: "Aneesh Kumar K.V" To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: Yu Zhao , "Aneesh Kumar K.V" Subject: [PATCH v2 3/5] mm/mglru: Move code around to make future patch easy Date: Thu, 6 Jul 2023 11:50:42 +0530 Message-ID: <20230706062044.816068-4-aneesh.kumar@linux.ibm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230706062044.816068-1-aneesh.kumar@linux.ibm.com> References: <20230706062044.816068-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: uqn0r-hKGKVY8LhcOw1NG3LiAQy6HHKN X-Proofpoint-GUID: BAU39SsRs1uhqzXvGSqqV2O1rdtSPy_L X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-07-06_02,2023-07-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 suspectscore=0 mlxscore=0 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=996 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307060052 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5E51C180007 X-Stat-Signature: sbocmwnkruh1gqxff4opttti5qiyrsrk X-HE-Tag: 1688624470-387619 X-HE-Meta: U2FsdGVkX1+9h2QoI65hInOzaX6LKGxrOcnL5II0wzuTSuzu7kywLBRkoLfhqXc+mAkP37ODpWcz+uR9ciJo70BlOcYvH0dkym5/SjqGlD/Po6MU4VXVVwFxxPsIJjsMTLL0eEu3tIIozW6FKGEbPYqHsamh/q6AtgB8Wep5LqEb4EpNHJU1x8duPOdmspGwfykvE/aV3o3gxyo0hzafbwaZieEgF4Ysh6AqYyG7XtuAJXvzkmS2dy1+P8xjph0F57qxvrvcYdU8mJjicolSRL2z+WHHxstnAObwglMygbAPsUr/1WHKEKu/wwnKseQh93wIufLHmDtLHedq4hyzvCbz7c4cpyBaMrw8YUyIvJd5sYmvR+sTA7/tiIpaBAb7FMWqlkWxd+84Xq4mfXE1tUBnrE2jxmfuNGrl1QrIuBsN9vgNSUjiASlYhwS3Vheyt/wkAl/64heQ1ZunKJr2g2dT73yPu+MAzGANkgZWUU8Z5QK/qZuth4LbOjmT7JKRTLvzCyWeE8kuLyHQTnDziTpP/RRHyC6oAD3rUDxBhewX3XS31bhYW9tPfYQGGK3lwsZuNcaoqRgikHsMcgNqJ5XeW+RCKW9GEQqNULUlq7C1nSPik6WT04L96byDUzhAphR29mAtspe+uXJ5DusYHS7JTlUfTSlFJYBUQGhwsgFzrxl+u5kCCwZm98hHmzvpnLNQ1qr/FkEkSkoN7MfSd2dGir5a8eInOBvj7nNf3xfk8IQpUZAHsi0PWKqxIcoDfIJigjpA6v4iKUzZ1TxEjmflSti17JWyz27Xxpy/10Nk4wJO3/RU+igYktrVnQvaHGbq/txCqjrowkuC0xh5R0BltpAA6S+pIRoFfDOvFeF8Jislxn3CTR55Mc1nLs4th9CaknOOhResidl6luN2YA5LPbT7EJVJ81BJW/mLJ2Qx2Xh1I70yrNeHe+BTrFX73fYsLFnXOqZjYaN9jLw kbBiijI6 DJ64ecNff/RXM0UYtQHBDIK9lacO4dxqSqtmWqIOWnaafmH09DLnkRbMyW6PV24wjp08Ub3LB0zSJfI+ZO+r/Wn3SHBdVkQa8GI2t5i6Pn8NxQUiDmhEoB6JkiYAja6hQrBncSK6hunBExWiHY2wIEVsXtQ== 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: No functional change in this patch. Signed-off-by: Aneesh Kumar K.V --- mm/vmscan.c | 64 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index c5fbc3babcd8..a846a62df0ba 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -3556,6 +3556,38 @@ static void reset_batch_size(struct lruvec *lruvec, struct lru_gen_mm_walk *walk } } +static struct lru_gen_mm_walk *set_mm_walk(struct pglist_data *pgdat, bool force_alloc) +{ + struct lru_gen_mm_walk *walk = current->reclaim_state->mm_walk; + + if (pgdat && current_is_kswapd()) { + VM_WARN_ON_ONCE(walk); + + walk = &pgdat->mm_walk; + } else if (!walk && force_alloc) { + VM_WARN_ON_ONCE(current_is_kswapd()); + + walk = kzalloc(sizeof(*walk), __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN); + } + + current->reclaim_state->mm_walk = walk; + + return walk; +} + +static void clear_mm_walk(void) +{ + struct lru_gen_mm_walk *walk = current->reclaim_state->mm_walk; + + VM_WARN_ON_ONCE(walk && memchr_inv(walk->nr_pages, 0, sizeof(walk->nr_pages))); + VM_WARN_ON_ONCE(walk && memchr_inv(walk->mm_stats, 0, sizeof(walk->mm_stats))); + + current->reclaim_state->mm_walk = NULL; + + if (!current_is_kswapd()) + kfree(walk); +} + /****************************************************************************** * Bloom filters ******************************************************************************/ @@ -4324,38 +4356,6 @@ static void walk_mm(struct lruvec *lruvec, struct mm_struct *mm, struct lru_gen_ } while (err == -EAGAIN); } -static struct lru_gen_mm_walk *set_mm_walk(struct pglist_data *pgdat, bool force_alloc) -{ - struct lru_gen_mm_walk *walk = current->reclaim_state->mm_walk; - - if (pgdat && current_is_kswapd()) { - VM_WARN_ON_ONCE(walk); - - walk = &pgdat->mm_walk; - } else if (!walk && force_alloc) { - VM_WARN_ON_ONCE(current_is_kswapd()); - - walk = kzalloc(sizeof(*walk), __GFP_HIGH | __GFP_NOMEMALLOC | __GFP_NOWARN); - } - - current->reclaim_state->mm_walk = walk; - - return walk; -} - -static void clear_mm_walk(void) -{ - struct lru_gen_mm_walk *walk = current->reclaim_state->mm_walk; - - VM_WARN_ON_ONCE(walk && memchr_inv(walk->nr_pages, 0, sizeof(walk->nr_pages))); - VM_WARN_ON_ONCE(walk && memchr_inv(walk->mm_stats, 0, sizeof(walk->mm_stats))); - - current->reclaim_state->mm_walk = NULL; - - if (!current_is_kswapd()) - kfree(walk); -} - static bool inc_min_seq(struct lruvec *lruvec, int type, bool can_swap) { int zone;