From patchwork Thu Jul 6 06:20:40 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: 13303237 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 E67C7EB64D9 for ; Thu, 6 Jul 2023 07:04:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3FCEB8D0002; Thu, 6 Jul 2023 03:04:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3AD318D0001; Thu, 6 Jul 2023 03:04:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 29C1A8D0002; Thu, 6 Jul 2023 03:04:51 -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 1B3548D0001 for ; Thu, 6 Jul 2023 03:04:51 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D7E81404D2 for ; Thu, 6 Jul 2023 07:04:50 +0000 (UTC) X-FDA: 80980299540.22.055D374 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf10.hostedemail.com (Postfix) with ESMTP id 2E815C0013 for ; Thu, 6 Jul 2023 07:04:47 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bu1f8eLU; spf=pass (imf10.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688627088; 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=ORUTZlKjN0qMpiS0OXppYHa5tIArtT9ztqKk+Xsat/U=; b=6tX/xL7YDTC1Djhy5XWjR6Mi991SbffMFcATxxNVFzsDGDjDc0NGX6PuQfgLE35V4b6q7P VGa19CXi4t8QNJcW0WftjTDO9FPHxYlVkgwebBXeXVn+vzKG/0uQHToSPajDBOnaykO+it HvXdYNo8iMed/8fjnkjNRfo60EBWwcE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688627088; a=rsa-sha256; cv=none; b=puLpdZqAn3Oplq5nUhiSjM1mkKVeM+iKRsqOgAo5S4sPkbotm0FrYEjCVpaLhMHBqIBIat otoTwszuwjbZ66p5IO86l/mU9b8TXu3ccxAUN/wFCdqd0w81SHuQBr4LmPIeDK8wwa5B8k opQaXmzQvaZgGCAIOCLTF/9Qe2s7mCA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=bu1f8eLU; spf=pass (imf10.hostedemail.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3666qAvO031213; Thu, 6 Jul 2023 07:04:46 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=ORUTZlKjN0qMpiS0OXppYHa5tIArtT9ztqKk+Xsat/U=; b=bu1f8eLUcT9Sj+DJcMYEKZ5N+CQPEGC2Q+NmlQLA4C2hmC6FJBQDfjXAiTZ9evpF6A+E gznSxmy1oyLiRXq0PQuqyqiw5LJ97vtSkpe8f8zbCfsVkpgGPbkG9ogyqBM9apgHQg5t oQBAZ0l10FeKJqH6bXim2iCbl6O2U+uJDptGjkMlwvOaB/G0QC+oIoJsx0oA+W96VEM2 gpqWNnBHa/DW+U9IcanFBinMO8bl6No+E33gJA3f3nr8JLCEjekLOkgmDE1KboornwlY aR9xxk9Bx9/z14xHfsC5+13O3dtoMbouYykwMLTqHtKdTsajDd2nPp/3biqj7gwyuTOj Vg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rnrqhrasf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 07:04:46 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3666qKu3031585; Thu, 6 Jul 2023 07:04:46 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rnrqhranh-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 07:04:46 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 365KWKOw001784; Thu, 6 Jul 2023 06:21:02 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([9.208.129.120]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3rjbs57x1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Jul 2023 06:21:02 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3666L1BO57671942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Jul 2023 06:21:01 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1071458059; Thu, 6 Jul 2023 06:21:01 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 253CA58058; Thu, 6 Jul 2023 06:20:59 +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:20:58 +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 1/5] mm/mglru: Create a new helper iterate_mm_list_walk Date: Thu, 6 Jul 2023 11:50:40 +0530 Message-ID: <20230706062044.816068-2-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-GUID: OHH1ksSooPEyh82LjoWixJMCvgAsgvtC X-Proofpoint-ORIG-GUID: iKNf1M-S1aQDJT203zFYnru0eXnT2_nd 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_04,2023-07-06_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 phishscore=0 impostorscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2307060062 X-Rspamd-Queue-Id: 2E815C0013 X-Rspam-User: X-Stat-Signature: js35dghcpxd6tz9ris7fktcps1td9z8g X-Rspamd-Server: rspam03 X-HE-Tag: 1688627087-990594 X-HE-Meta: U2FsdGVkX18iOkJJj5FCSfP8yJ9c/AZiHmitr0TtkX2kbfOrS7R7cO+Q31DrHuyW9lc2KyyUnyy5IArFHzsOlgRHhc0UT887rRFWEAq/zIR2gZ35JGh2uedOUWuccgj7ZxChZRcacbUVPKPVz9+prJPmp6SVeREZuYq65JbZ4ZrRHD4HRR7Z9dB0LblcignQKVHX2S0q8GdZqdaKsXHSH9OPSi2m0pjt+5aDsN1VDxOJesTxuPd9FC2d4fuwIQ1DWuhEUELHy7qR55MxANncriSeFYNJd4fdIljKgb/oNhXikY58yYOVip9uixIYNqmZP/TGF7lR8dn+v8pOLRlQEKmFJ/P0aLLolRqWjmumyuRDa6gJIQhIkoH7hXV7Y6g/rpoaekOkWmVejUfB5GrCaCijF5LkHEq4/ujZ2MZMKGWYkqgRuqeSA0Hn5kAVLVZLknuzCT+0jdWYm2ic1drqKEG2WBRNx3jLNP7ZuADI/7OU7BeQDHcKEAKKs09oqQtyBQZXxMWaGHx/a76za+BWhiDsWVoieJRojHKmETISBQGjCqS53oKYDSJN+suqCrLjDvUgm77O8q50YtDl5ml0qUosZVz/RdcltrNOpBkWJxMUq93Si1amu+4fa8hHXRfYhzmwIk+FNeqJ3WSnThFxSN0wTVFa+AcO5kWd3Pp+R+/ELuE4HCRxbz9hNVcixVBs2QOz3hnu/zhTl01K9l6SrbA8QaYbcgmLvRn+bQtfwG/u7IVt/CmNo8hpl6DZCDgAhlddb9QKZRQ/4OYFGlhGkc6PIMAcfJ7J/bY7l1cPnZVoI/zKpswv6ZRlkzpY0ydC8Ub93DOgg11SD0U6UjDQUthCSoAv8BwjMgc2rfqQ0Nph6J30+e5bld84oGcJO5EEbm3Za3GLr+eTJolN4kC8WLlS0O17UQcQpIm9voJBnXB2Auuv/9ngKhMuCw2Iy44JPrOsAxCSly7Z/DVGVH3 2ZKQ8rQc rrL0t533fhcY1dcfSw2TtLoUeqs6IUNBZT61CNXWBLjSpfXg8aCWo74zznsi/Q1lG5ddn6sVmGhJMrmV1MW54bE+VQJw5GsKPTJbEPRIZ8pq9JLQbIUgJ+MMGfx24MEdyEpPU6A9VPAMSMIkUMmMY0C80hgI8E8bMf/d20SKHO6xfHUXaKe59i0gg0g0tZA1FeEpwD8hAqEa4ExE3eXUMOCcEn8UF/2ZO3UGGGM+ZhdN8g6TM4N/RHPX6Nlz3/a+0pPKeTlCvNarow/3aM+mbeEyldg== 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: In a later patch we will not build this on ppc64 architecture. No functional change in this patch. Signed-off-by: Aneesh Kumar K.V --- mm/vmscan.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index eb23bb1afc64..3b183f704d5d 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -4491,12 +4491,37 @@ static void inc_max_seq(struct lruvec *lruvec, bool can_swap, bool force_scan) spin_unlock_irq(&lruvec->lru_lock); } +static bool iterate_mm_list_walk(struct lruvec *lruvec, unsigned long max_seq, + bool can_swap, bool force_scan) +{ + bool success; + struct mm_struct *mm = NULL; + struct lru_gen_mm_walk *walk; + + walk = set_mm_walk(NULL, true); + if (!walk) { + success = iterate_mm_list_nowalk(lruvec, max_seq); + return success; + } + + walk->lruvec = lruvec; + walk->max_seq = max_seq; + walk->can_swap = can_swap; + walk->force_scan = force_scan; + + do { + success = iterate_mm_list(lruvec, walk, &mm); + if (mm) + walk_mm(lruvec, mm, walk); + } while (mm); + + return success; +} + static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, struct scan_control *sc, bool can_swap, bool force_scan) { bool success; - struct lru_gen_mm_walk *walk; - struct mm_struct *mm = NULL; struct lru_gen_folio *lrugen = &lruvec->lrugen; VM_WARN_ON_ONCE(max_seq > READ_ONCE(lrugen->max_seq)); @@ -4506,34 +4531,17 @@ static bool try_to_inc_max_seq(struct lruvec *lruvec, unsigned long max_seq, success = false; goto done; } - /* * If the hardware doesn't automatically set the accessed bit, fallback * to lru_gen_look_around(), which only clears the accessed bit in a * handful of PTEs. Spreading the work out over a period of time usually * is less efficient, but it avoids bursty page faults. */ - if (!should_walk_mmu()) { - success = iterate_mm_list_nowalk(lruvec, max_seq); - goto done; - } - - walk = set_mm_walk(NULL, true); - if (!walk) { + if (!should_walk_mmu()) success = iterate_mm_list_nowalk(lruvec, max_seq); - goto done; - } - - walk->lruvec = lruvec; - walk->max_seq = max_seq; - walk->can_swap = can_swap; - walk->force_scan = force_scan; + else + success = iterate_mm_list_walk(lruvec, max_seq, can_swap, force_scan); - do { - success = iterate_mm_list(lruvec, walk, &mm); - if (mm) - walk_mm(lruvec, mm, walk); - } while (mm); done: if (success) inc_max_seq(lruvec, can_swap, force_scan);