From patchwork Wed Dec 1 14:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liam R. Howlett" X-Patchwork-Id: 12650035 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 A0ABFC433EF for ; Wed, 1 Dec 2021 14:38:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 706D46B0089; Wed, 1 Dec 2021 09:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9AE6B008A; Wed, 1 Dec 2021 09:31:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 387E36B0093; Wed, 1 Dec 2021 09:31:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 1132C6B0087 for ; Wed, 1 Dec 2021 09:31:06 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CD772180E4ED5 for ; Wed, 1 Dec 2021 14:30:55 +0000 (UTC) X-FDA: 78869462070.03.4606588 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by imf14.hostedemail.com (Postfix) with ESMTP id D611060022EE for ; Wed, 1 Dec 2021 14:30:54 +0000 (UTC) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B1EOuJE023540; Wed, 1 Dec 2021 14:30:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2021-07-09; bh=K89b2LHyw6CeBiU320wLi4xG2h//5GN1TI12HiEsdWE=; b=bbpmWWad81NxDO6MhIlXvVO4PM4E1pmfEdHf27KTRdrlLHf0hABnJx2dxfqy8oAF4upV gnMeVK9Uih8lLGWb2FgTlq/w6sfRMLFq41UmcY66hY4OO+Trsu+Q4DU3eyvePOx2OQWh 1X2PWj5BOJQPtdWhZJsu9wr4zGGjyDAFtSmTtDo880/+TuvcdiAEOiTtedIxDJ2bU6xn npTTTo46McvdJa46vxw/fwjEPymZi3mipbpqxBl3ztHLTObpEbHI5VoLgPimZemfqoD3 jWawmgIk5GTiRZIenXbTGoXe4oGa+qf3Dwx0yBylv7ALw6KTDV2+VD2oEdC+J717Sg2W fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3cp9gkgghk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:42 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B1EUNPQ108922; Wed, 1 Dec 2021 14:30:41 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2104.outbound.protection.outlook.com [104.47.70.104]) by userp3020.oracle.com with ESMTP id 3cke4rv5ew-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:30:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f5Elk7KIzSJvpEAnMdHvZKHlF3AzJ+6TxMo8iCUeJrqe0sqcVyFB43bnclA63qSPTruA6W1/vjjxDE/JTULmsARUbnBqrnMxGEruFt72UzE1tyEUJ4aIXyqQuDLhJd2hQsKzSgT+tQhBy4Z9YfGGBCoV6g75uL+JykHwjF9L+FfZ+ZX5rU5PvLnf4//ewQU83j42ox1rgmgtb1jVKmuE4GIPIlO5AqjDGB9gApkklhxhWsL+T0a5BOzPlPvMWZ7TPCykJwDVAoxDFE/2oe+YhvwjnUabjr5jC2Pmr+HpjTPWcBWq+yUbpiZuqn/4NkUyA6wv73Tqx0c0COTeQmnYng== 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=K89b2LHyw6CeBiU320wLi4xG2h//5GN1TI12HiEsdWE=; b=FOirPDMid3Hcp7WQajgcA9PgMpTleHwxRFACMcxi7i2dbsQ8fzOdqDFVV/+tuaHh+/cnlEHaK88bUlItDR0ZAz6L4e46/8E+zX+CqAKRnDle8Pc6YTW7VX+Xaj9VAla941JmGV6j63x+xYWKYq0TkN4laxPTy9Y5LMbfuXHsRkfKpXR99ylnUxrvezAQvv8Rs14JEdCjeKN8f+KCAuU8C9e8/Bbwk5ApTD5jUa1jkMFo3SjffzG94jOgINxDrfYXu4V+7dD5FTX8Qlxl+sJIp5QB55CTBXqJfILPHGiJ4jzQDopUfnmOZY2bSocHX4EQB7bDgE2YxPgvjo/kuSLDOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K89b2LHyw6CeBiU320wLi4xG2h//5GN1TI12HiEsdWE=; b=yzWrIryaACLm2QcR/yspaOGiTAl2yBDIOi3vpK73MYCL9ociqhqdKQrsILAUgSvPKZzxDPsPOSbS4dvgksYZr4lAW920CTh6eQQm9Upv2jaRODIIPxbI/5yKxStJpibLjflL6p9o2zpyhuVkrwuOreEST9LBvN5243h3NXPRLlQ= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by SA2PR10MB4508.namprd10.prod.outlook.com (2603:10b6:806:11d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Wed, 1 Dec 2021 14:30:36 +0000 Received: from SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c4d0:8291:84d:ac66]) by SN6PR10MB3022.namprd10.prod.outlook.com ([fe80::c4d0:8291:84d:ac66%7]) with mapi id 15.20.4734.027; Wed, 1 Dec 2021 14:30:36 +0000 From: Liam Howlett To: "maple-tree@lists.infradead.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Andrew Morton CC: Song Liu , Davidlohr Bueso , "Paul E . McKenney" , Matthew Wilcox , Laurent Dufour , David Rientjes , Axel Rasmussen , Suren Baghdasaryan , Vlastimil Babka , Rik van Riel , Peter Zijlstra , Michel Lespinasse , Jerome Glisse , Minchan Kim , Joel Fernandes , Rom Lemarchand , Liam Howlett Subject: [PATCH v4 34/66] cxl: Remove vma linked list walk Thread-Topic: [PATCH v4 34/66] cxl: Remove vma linked list walk Thread-Index: AQHX5r/vilgZfzMys0q49fGy7gPCNw== Date: Wed, 1 Dec 2021 14:30:06 +0000 Message-ID: <20211201142918.921493-35-Liam.Howlett@oracle.com> References: <20211201142918.921493-1-Liam.Howlett@oracle.com> In-Reply-To: <20211201142918.921493-1-Liam.Howlett@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.30.2 x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7e278bb1-edc0-4380-532e-08d9b4d72430 x-ms-traffictypediagnostic: SA2PR10MB4508: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2803; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8bDDUn8VWOs4s+YjeYTCszmBohwztZ7EcIoN7BTA9EK4ts3L46tflcHIqbRGrLWaHKykVV7fe19Gc7Qk/0HxZdW/Rx5b/f1Ex1IAvjqLPjafFM0y3gJhM+uiNftDDEXfncrKiGrUPJnAIOdfJUtJWyTG1CgsdRf2secA+4dAs1mjJKnnMY/zDDfpLsxinjQrZ+/XI1v2fn6fA2JZ06DRymEYPbnWPxKRIrlckaUZQ6PjnCznCqTzbXXa22TuSK1bAnnxQUo7bFzgj6l4DtE4uswMwSDaFJTAulo2AeR6y939VZ2WfrxRdB3AEghbSvkR9lPQeBBijKWjMGWompd7diwdg4ev/RY9eDuUvEm+Gf/erOpERCNV4EGcTKNgM3jv8cuKCy6NpXVM6pz31cDyudrwOoH9Xja0ds1NrKQZJVwrhS93uNAv0dY6/1TLg0HcKz0bDRwp3xGP7Kj9Qf/rxoy1gtepmfi29xwLoiStqbie0E5C+MddoIY2iDVwnXVyign4eIF8FTlzmFNTRlFMx4Em63jz4MdHI7JrZcwZIXXAO3Gc+HW0tzSKbD7oLEBzSDh5enFYJPaOlhPZP6BkHp9An5P+dRyINUW25c9YZrAYLUiG2D0VluTNsFajmJPuqS40t/rUpWzBbARosotyXMHcjY6BI2x45kgvdJXm0n/zjByMJE1+OOUygLrWfSu1zqqOSWI4U0RFru+kzetXRQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SN6PR10MB3022.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(186003)(26005)(7416002)(1076003)(2906002)(8936002)(54906003)(83380400001)(2616005)(38100700002)(71200400001)(66946007)(86362001)(66446008)(8676002)(6506007)(38070700005)(6512007)(6666004)(122000001)(508600001)(110136005)(6486002)(64756008)(66556008)(76116006)(91956017)(107886003)(316002)(5660300002)(44832011)(36756003)(4326008)(66476007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?NBEkjDY0CgKhMt9Rdi1WKE7?= =?iso-8859-1?q?g2KVgbGqLoNkIBs76kgK4gHj/METbiwLrP1CLO5d4bS9sw1J3DgxhBo00ICJ?= =?iso-8859-1?q?9KGq8/yiQhI66sHE47mtL3pBcTEMjqAW95fTYAIH27MwVVNBRfRNWjOIVsCz?= =?iso-8859-1?q?R6PsgrEKY3wko6Keohmb1N4DUyUtzDlEW1nxKDbIBSjMGOcYEH5pgaZM7jsA?= =?iso-8859-1?q?QK93mSi5kDyRV7MAoS0GPptsNmLat1m9bAmu6SNe1bVuWmqpNhS52CKu7K6x?= =?iso-8859-1?q?FLr9qW6mYONqiQZ9LbKi9YZ9zRyNK3ZairIzsVp1G7pjahPtjW0tV40+tbJB?= =?iso-8859-1?q?dLjF1Gru8ojrBOK1kTMQ3lWy+fmDnzLUKxzzg8NlU3Hy6xM3EM2CjkvySpR+?= =?iso-8859-1?q?7pRAG4F9SmuHCtymNsiKhA1VzfABfk426kSdIcFWbHv2W2IIRQLXVzQLrJaf?= =?iso-8859-1?q?rseIh05sHv7YEkwQQL6sK1lTPFLzbNli43scXssxyzageBvYfyUF5uMEhSTr?= =?iso-8859-1?q?g4QR8yhGIOt3jk0FYsl/sK6DklHGe4d/YAbKIb57g2Vn4wltUzBv1xxpPFse?= =?iso-8859-1?q?5VAsuSM8r3j1lU/0ObkkZSY5y3mvqkNCVHUyoGk+2XqIeFU+35ASm5Xl2PnX?= =?iso-8859-1?q?VZXrmKA2FyYVWyX+odF6BzA5pTEoLMMpMep5qBxQq4i9oOW1vEuQC7jXIsDh?= =?iso-8859-1?q?ENjUPgs5F9cju1ZEY36FUchpppfKNIygYiV0tHhpCLAyb07J2acQX3NL6PrQ?= =?iso-8859-1?q?wLWI7uPgq+bojKRKP4b7HBx9ZZ2hr0AqHqvvEFbj+7m4nsnr7EGzjAri5Er+?= =?iso-8859-1?q?wK4IDeQBxAOHdAPkJSQBF17piBEoQylNiDaH9OYAAelt76ed/Yh50fm+oEme?= =?iso-8859-1?q?sQqxLIDxm9yag8URTIWGurkGLfsajWxB0BJgVd2ON4IRXmqQ30KTJAHSRHls?= =?iso-8859-1?q?lD0zB7umZ+Pms62RKHyuaczKW0qCY/oxwXshj/epoSF7xsj+YpVRkkwLgy5u?= =?iso-8859-1?q?s/Ww1Rb1Nck6WXM5s8OfLlOhd0Vw+y48/YMZTxLmPiETJYsdFSYvb9gcsbp6?= =?iso-8859-1?q?QjTOFqVNrrpMeGAICOaqJlvAkqj3D/Y58vOY3riouxFxK/sack92AyCq9ZSh?= =?iso-8859-1?q?dGbsZflhycULHwZqVadaF7dpSvnpedTVAin1ZMj1k4e0eUYbYt3uc+bsf+Cg?= =?iso-8859-1?q?0kiDMjpAwjfHBgU2At4XR3x6GE3ebe1UzSHt37E724mQOT52PaU0tYG/ANcO?= =?iso-8859-1?q?QMCPg/1/9R6egik95m8f7ikUysWXJ13vAGGzSsU9HSd3Xal1+FgRbuU2ILUS?= =?iso-8859-1?q?ujN1zlCiAwdPkKhIdv20NlEThD5mv5fXSsHolzDaXGbuNcKsyRZN77ziqvpB?= =?iso-8859-1?q?EeD1y96KENxHgoIBAeey2kssftMs6WSEReP7JEFKqEHe+nXYnaaSZp96kMAU?= =?iso-8859-1?q?y+qq+Gpjd9N4GMGt1DeJ+g/b9zR229Ngc9+QAiFBW6u7azbDyxnbmrWYZm9U?= =?iso-8859-1?q?kvwPcD99rGveVNYCLSl+u2Soaku0wN6T3Mtt0VxLWnCgG0C+FPMXgpzzngvC?= =?iso-8859-1?q?3JWcv+2L1/ZqIeKi16Fu9GsO+mmYSZ8odFppsf0unq4lxrX8xzVN3uljctVj?= =?iso-8859-1?q?WsBbk4hL/7cYFqu5AlqjVzxsDqLwA+fX59mv3BPa+dAcv1lXtD/4t6e00yfs?= =?iso-8859-1?q?=3D?= MIME-Version: 1.0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SN6PR10MB3022.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e278bb1-edc0-4380-532e-08d9b4d72430 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 14:30:06.6802 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iJeKuk7SHtXxg/tcheq9fNr8mkF744DbgjWSsPwHkb0fEZDQRCO5wCSxi9PmMU6LeF6jOPht+pJE5b2LZfVsww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4508 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10184 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 phishscore=0 suspectscore=0 spamscore=0 adultscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112010082 X-Proofpoint-ORIG-GUID: 4NAV04AasI5ITaKqB4KD-KpRuCs06Org X-Proofpoint-GUID: 4NAV04AasI5ITaKqB4KD-KpRuCs06Org X-Stat-Signature: 11rgkdmc8kwre1awwtq5jbkn18ciuwjo Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b=bbpmWWad; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b=yzWrIrya; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf14.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.177.32) smtp.mailfrom=liam.howlett@oracle.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: D611060022EE X-HE-Tag: 1638369054-517771 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: "Liam R. Howlett" Use the VMA iterator instead. This requires a little restructuring of the surrounding code to hoist the mm to the caller. That turns cxl_prefault_one() into a trivial function, so call cxl_fault_segment() directly. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- drivers/misc/cxl/fault.c | 43 +++++++++++++--------------------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c index 60c829113299..504522a126b5 100644 --- a/drivers/misc/cxl/fault.c +++ b/drivers/misc/cxl/fault.c @@ -280,22 +280,6 @@ void cxl_handle_fault(struct work_struct *fault_work) mmput(mm); } -static void cxl_prefault_one(struct cxl_context *ctx, u64 ea) -{ - struct mm_struct *mm; - - mm = get_mem_context(ctx); - if (mm == NULL) { - pr_devel("cxl_prefault_one unable to get mm %i\n", - pid_nr(ctx->pid)); - return; - } - - cxl_fault_segment(ctx, mm, ea); - - mmput(mm); -} - static u64 next_segment(u64 ea, u64 vsid) { if (vsid & SLB_VSID_B_1T) @@ -306,23 +290,16 @@ static u64 next_segment(u64 ea, u64 vsid) return ea + 1; } -static void cxl_prefault_vma(struct cxl_context *ctx) +static void cxl_prefault_vma(struct cxl_context *ctx, struct mm_struct *mm) { u64 ea, last_esid = 0; struct copro_slb slb; + VMA_ITERATOR(vmi, mm, 0); struct vm_area_struct *vma; int rc; - struct mm_struct *mm; - - mm = get_mem_context(ctx); - if (mm == NULL) { - pr_devel("cxl_prefault_vm unable to get mm %i\n", - pid_nr(ctx->pid)); - return; - } mmap_read_lock(mm); - for (vma = mm->mmap; vma; vma = vma->vm_next) { + for_each_vma(vmi, vma) { for (ea = vma->vm_start; ea < vma->vm_end; ea = next_segment(ea, slb.vsid)) { rc = copro_calculate_slb(mm, ea, &slb); @@ -337,15 +314,21 @@ static void cxl_prefault_vma(struct cxl_context *ctx) } } mmap_read_unlock(mm); - - mmput(mm); } void cxl_prefault(struct cxl_context *ctx, u64 wed) { + struct mm_struct *mm = get_mem_context(ctx); + + if (mm == NULL) { + pr_devel("cxl_prefault unable to get mm %i\n", + pid_nr(ctx->pid)); + return; + } + switch (ctx->afu->prefault_mode) { case CXL_PREFAULT_WED: - cxl_prefault_one(ctx, wed); + cxl_fault_segment(ctx, mm, wed); break; case CXL_PREFAULT_ALL: cxl_prefault_vma(ctx); @@ -353,4 +336,6 @@ void cxl_prefault(struct cxl_context *ctx, u64 wed) default: break; } + + mmput(mm); }