From patchwork Wed Dec 1 14:30:27 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: 12650059 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 6B19FC433EF for ; Wed, 1 Dec 2021 14:44:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 298476B009D; Wed, 1 Dec 2021 09:31:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 24A4A6B009E; Wed, 1 Dec 2021 09:31:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 073D76B009F; Wed, 1 Dec 2021 09:31:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id E98F26B009D for ; Wed, 1 Dec 2021 09:31:52 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B4D7B181200FB for ; Wed, 1 Dec 2021 14:31:42 +0000 (UTC) X-FDA: 78869464044.15.1FDE0A5 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by imf13.hostedemail.com (Postfix) with ESMTP id 9060010515ED for ; Wed, 1 Dec 2021 14:31:29 +0000 (UTC) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1B1ECcS5002533; Wed, 1 Dec 2021 14:31:20 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=yzzqmVgBpmVR5Ja0Yru0s1jlXWFEQ+PdWmICofUE+AI=; b=lIZc/Dt8NuA+BxF252JrUKw7q294mPInh+Ybk2w+yP9K0Mxiz5yWfTd25iaL625pNBRf 0y6w0uIQngHwbkNhHPoTojjd62OgpIukI5C1At0gBeE4EMWu4NQfIhpOXFEOh8cyuaLW OthBUFgO57eFXBintDcewyljcJU9MMJuhSqczNG4kIJvjHDKy6xi9oI70a+T4M7vCcpH yHJku574s9DFIbYCp7W+cn2edF/EW7pGKg8K+G9v3/frUwTodqVp59tf+E8GA3i+fhYs tEYNZURClJtBEEMg5iJYhaIYloy4UvS3WGiG1Dsz+UrhUPS4SrY/iXAb7/OeiKNOskTy 6g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3cmvmx2270-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:31:19 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 1B1EBlwZ109866; Wed, 1 Dec 2021 14:31:17 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by aserp3020.oracle.com with ESMTP id 3cnhveqdaw-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Dec 2021 14:31:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f00Rmd5ZI3u79rw/tcUUtUJmkRrhcMtyNH7gjoe6DCSwNglzw6Yabj0J0ATDnaOLkNQrYvcjUowOsyNTmzBZMmuZFBFlqOXKuj75exHdubW21+1uE2TiZFIqgNqzms1OwREs5gshvK9iXLh8b2Xbs2D/83mEzD0/TnqV3c8oeXNOlq7kWwbT1JgmPMydY49/2p61apkmVT3BgRD4eO9JAqwok2CU088QFX0FuOeA+q3okZpLMklrZgQKFZOBpaPmS3QfYN8ikjM7+9gG5JGFjAGnJ2370bqyRXUTvrOiEAofQYkA/m1krNVQ0P9sF17xoazLDnxkef/kp63p9rdPzw== 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=yzzqmVgBpmVR5Ja0Yru0s1jlXWFEQ+PdWmICofUE+AI=; b=D43eIrdX2lQBdMdmBODdQYx+RT5ZCfa6gLZ0BGSy845e5U4taz82xpFc+Dyl4XBnSupTyISEn2raskdtw+3vnCFFs3/YP10RdDCQ8vIGwERoL/4fVN6slOv+68/3BIEZEZC7Us4cDYkmHFLAoubOfw0ItDIk4NjlfBhVKmsGxEU43l/+NesC9qJ7L6mt6LM2+7YQYpmZ4wiz6c3uNqY7lkOvQNMoWUnPCCjFun/OsymV+eqTduEl+UCWSjYVa9/xXFdqHjFjwQBbv/UheVIm2lDokLP0FTK3drKfYqn6PE7XeLWjq+OXzCzSX9aGv9xPh/hXFEUrGX7r3GtucX9j+w== 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=yzzqmVgBpmVR5Ja0Yru0s1jlXWFEQ+PdWmICofUE+AI=; b=UO/elLUl5AbayFGgwlS57nrVWrZoKxS5dv5eZirHLbRyMuajCbMNeF5UgbBdSx/IWaxzbrAbOslq9sDQJAFrpnRhzxNSQc6ZNyfsDQAlesfnWT8beOFcXQuwRghZ++GEZ6SQb+EHGkhMKYI9TRKUKnT3HhFIp64BL473sWi5PKY= Received: from SN6PR10MB3022.namprd10.prod.outlook.com (2603:10b6:805:d8::25) by SN6PR10MB2464.namprd10.prod.outlook.com (2603:10b6:805:4d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.22; Wed, 1 Dec 2021 14:31:13 +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:31:13 +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 63/66] i915: Use the VMA iterator Thread-Topic: [PATCH v4 63/66] i915: Use the VMA iterator Thread-Index: AQHX5r/8pyGHA0a30UCeHYNaMLfKUw== Date: Wed, 1 Dec 2021 14:30:27 +0000 Message-ID: <20211201142918.921493-64-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: 701570e3-55ee-4cec-d147-08d9b4d73a13 x-ms-traffictypediagnostic: SN6PR10MB2464: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4714; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PrdA1IFxyn96ur0OPdRGT8FJeXl46hGD4IuDUeIqTc+hiXjcbWKmOFVwrLbehV4Vyr5ZRznuQl3E+Avi2KzJ8pa4dx/qoC6wMWBMcOkqgufM3tengRCu4tUvnvcewKcgs5fCifP7Qx+S+aj2OAanGY/tyrQs63UBDtc0fzg9pbhlpMiCrTCV8Bt5qcGvH4bixRe1VDIuXO9JvMzSZCIOM3v6NUGRUOLZrs5lC60t+7QYCc7R2m4ApQHUBPwBE1NKtChNN/zFASj63QQ842CLGdbzUHW9nTiEgSNMBbkB3+EDkYbBuMF5t0bI8dB99zFTxImjdPpnbZPLztaIOZDQmLm5yDmhWw2JL8p8t9jX9qy5IzMBbyboJRsNPY1N7wu8v6fqr1AV17HVt8TECH39ecMQYe7YBu8fB46BVvhlii5oQxDNkK7scI0hWRGrr+ZmEnagY881/R+jEuOlDZNmnX6Wdq3A5cGOFsvWgAHTb8Fnj1N4W47JtqU+WCBkNuxJ2wSQDAawz08qw2FIdDAoGNgDXV9uY50J8Nq3b/RSgT7TCJjKTadBn23RkRaR8CXJjchNYiNpM//XJzWo6XsV2vw4oLq5VWwi+DglsmRPS0gQ+hHyeGYCiND8fdd80XSlf/XSsQx5BObUT3M+4mDghed/j4hnFkjHRXNwd8Yy8DqQkZ/GxRQ+7Mq3lkgIVbolMxpj0dHuhicy5eWK7falog== 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)(91956017)(6512007)(2906002)(1076003)(5660300002)(76116006)(83380400001)(186003)(6666004)(4326008)(26005)(38070700005)(36756003)(8676002)(7416002)(54906003)(107886003)(2616005)(316002)(86362001)(122000001)(44832011)(508600001)(8936002)(64756008)(66446008)(110136005)(38100700002)(66946007)(71200400001)(66556008)(6486002)(66476007)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?q?33Ut4nwYLouREEcNOXh6tNc?= =?iso-8859-1?q?O2VtcaKqA6s9zWIo9EumvK5YNtxjI5pXSxmbkJMIQB/B3Kzo6BEF6MMHZso3?= =?iso-8859-1?q?69gZBNpp+D6uwWsccYRa8Neh16qrVbqLCCz2deN4e4MMdulZ3SIfD6qCb+3c?= =?iso-8859-1?q?NaJKePHN654eI4MRhGa2if7PN08/Y/WISRR30+EMQqgAnuXXY5ZcPTsmXnSa?= =?iso-8859-1?q?B6HbsET/XVkmT6Qsz2UX3QBMvbHXT6SJIcwVLqyhxubMTqPb5QYSICUQN4OM?= =?iso-8859-1?q?Hh4vEl8h1W8mySc+tLXf6kXZfV5PJlLM2875oK2MikvrMurBoJ2NvaxGG8Ea?= =?iso-8859-1?q?7Vs6Y1SpuiOO8cJDSOTy7rM30QIewuitgMoOV0TyDEK363V2IfIqPs/6Kz8a?= =?iso-8859-1?q?IQwWRiQKhVlQyFd4TVY1wWtMqv/xQj2Q5GHD+LOv5md/kMqILgJRRi0oxalU?= =?iso-8859-1?q?sjzmrIuenCaWBuoXpRMlFZdHB8FsIZtXIVz33iQbfl19hvwFM6MYVuJ4QOjm?= =?iso-8859-1?q?btb5c4EE8dSgQJQhczAIzKu4tc5xRF17/p19CkTTo9ZuZwdU7A2VQmxEgBFQ?= =?iso-8859-1?q?XTPaMXaUMmy1c7hEiiQqzIvJq39Ifo6mKi1xOem2j+hsy8zmH6VxLFhpMcjl?= =?iso-8859-1?q?bjH9EtxoORJpSWpIDCNOLdOPO6yOKmXwuFf3hCN4xo1ql4lB7QvieXssVwA5?= =?iso-8859-1?q?jQ4gPVAneZc3OGiuFmSW/YOz1b230Cvr2az/8jmqFIbKC6dPEOjtDZiJcOdR?= =?iso-8859-1?q?YIipKWxRz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fNm+T7NT4soPDmvRcLr4stUYF5j7b7Xz5N3b5jQ?= =?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: 701570e3-55ee-4cec-d147-08d9b4d73a13 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Dec 2021 14:30:27.3864 (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: R+1rTepN9v7TxhHonys1mn8shs92jXyamT9SdEPgUPdQm9eGNyGaTpjCQysYiUnviYJN9PcyeeTPip7fipP/Dw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2464 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10184 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 adultscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2112010081 X-Proofpoint-ORIG-GUID: ks3z__2RwQQzphdUZkZSCbHDyqlsvWwJ X-Proofpoint-GUID: ks3z__2RwQQzphdUZkZSCbHDyqlsvWwJ X-Rspamd-Queue-Id: 9060010515ED X-Stat-Signature: to6ne4w6ud34y6jr8w6cnauqzsagwmwg Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=oracle.com header.s=corp-2021-07-09 header.b="lIZc/Dt8"; dkim=pass header.d=oracle.onmicrosoft.com header.s=selector2-oracle-onmicrosoft-com header.b="UO/elLUl"; dmarc=pass (policy=none) header.from=oracle.com; spf=none (imf13.hostedemail.com: domain of liam.howlett@oracle.com has no SPF policy when checking 205.220.165.32) smtp.mailfrom=liam.howlett@oracle.com X-Rspamd-Server: rspam02 X-HE-Tag: 1638369089-786707 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: "Matthew Wilcox (Oracle)" Replace the O(n.log(n)) loop with an O(n) loop. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Liam R. Howlett Acked-by: Vlastimil Babka --- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c index 3173c9f9a040..39960973c130 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c @@ -425,12 +425,11 @@ static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = { static int probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len) { - const unsigned long end = addr + len; + VMA_ITERATOR(vmi, mm, addr); struct vm_area_struct *vma; - int ret = -EFAULT; mmap_read_lock(mm); - for (vma = find_vma(mm, addr); vma; vma = vma->vm_next) { + for_each_vma_range(vmi, vma, addr + len) { /* Check for holes, note that we also update the addr below */ if (vma->vm_start > addr) break; @@ -438,16 +437,13 @@ probe_range(struct mm_struct *mm, unsigned long addr, unsigned long len) if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) break; - if (vma->vm_end >= end) { - ret = 0; - break; - } - addr = vma->vm_end; } mmap_read_unlock(mm); - return ret; + if (vma) + return -EFAULT; + return 0; } /*