Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1243011rwi; Thu, 20 Oct 2022 10:11:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xp6jE5sfmkLNrAyiPC33amvGCzr4ZT9wCyeFNbPLEyQK5EEVsz3QMTZWvF6nLo5RhUCNb X-Received: by 2002:a05:6402:4150:b0:44a:ec16:def4 with SMTP id x16-20020a056402415000b0044aec16def4mr13263931eda.21.1666285869266; Thu, 20 Oct 2022 10:11:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666285869; cv=pass; d=google.com; s=arc-20160816; b=f2ejAdlkhoZjs35xS3qMLukw5lMOGtffG0gO4pDmlczDnhrM0klYyWTg2L3wBEs+FS nOHQM8cOMFtK3gHlT0Z37TJioWnU+iooGpxmeA77Ll5E3yrOLHiZRi1DEu5+qKbrq/K+ H48Aizwm0A+fVhjkpubWaGr6Ejnfi5o6zQMEgGVvCiuqqwh2TsE1avoxoBFDceEjoGfW RwER1gc37OntFJLjy4tlg9KkfHA5tm1kUVcelu2G5KX8AnwFPC4FlbqDXoSA2uaFS4Hk BAmwjzNv0d0o+IlrI85mRW4xbcLsi4KfWn6U6LV8rrB6UYxXWVSvweV9C7dnO2jqqtmD ctRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=jedVheM+JrThZ3U5wZlWLXCzJUOc/sbbwwB9b9QfEJQ=; b=okbov5tssb3W48YlTUNZ+hzMZYmZSc+y3MIuWYp0Fok9kGHUpJ+Q5rL3LkzPYfV73U ESHwDt+Dxk4DBeXUoSROg39JX7BiGHZjJc95Qw1gEZ+hjNbOihXBXtEJnu76WdxA1n2y qGIISIskUNagl03GNtOW1JX/MHtabyErSV0rhn2QOsnNi/YLMWOu15FNRc3gRCLW0XNJ yp/Q9A/+JBWbNfGVFm7z+Qvb3iyO6wWF9XbResVQByUCPzRlFtSEGRawLTozK/afxwEN RbMoeSHid8qvAlL2l5rB5P/JgvN9zTZ+t3xbKvJRM+UNksBPnGYpR4xM7TaWgpkJU9eh rGmA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=WOm9kThl; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv20-20020a17090760d400b00791a67e4c00si5677641ejc.835.2022.10.20.10.10.40; Thu, 20 Oct 2022 10:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=WOm9kThl; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbiJTQui (ORCPT + 99 others); Thu, 20 Oct 2022 12:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbiJTQuf (ORCPT ); Thu, 20 Oct 2022 12:50:35 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2076.outbound.protection.outlook.com [40.107.96.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96911106E20 for ; Thu, 20 Oct 2022 09:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vrr4X7mT/F8NcMbnDtwIxA0PO/MeqUHuwdvQwET211sIQ8h3Wq6LRv+WwyirgqIP9TAv/LSeuiGXeZnobz6X85LaoJvli3LIDV11Kw1JRIAr3eZyJ+T3Hl0h1OM51N5Xtrln4D8XzkEETGIJA/baqMbZGdKIn2Tx5lpkLpIuK95yEdgGXrSLeNPXabuHKrCZLrmtzf5z2mDjSZveuKqNdKiyIm8Bx2Vv9XAUrVc6jacdtjPklPeK35OJpUm3ffMM+cS+grLdQuc0fa05LsZHTg1GqMAG1j5RY17Z3MU+qznw6Ah6YY2yVIm2qcTwB8FK1RyLy1kFJqODjXZhWK5XLg== 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=jedVheM+JrThZ3U5wZlWLXCzJUOc/sbbwwB9b9QfEJQ=; b=B7nV9h6FnxBgyZbSd7jBa6jQuoqzP5O+6ThaoTRC7MAupW8HgnOZR5ynFC5H0CbEd3+DmFYDeRKRi6bpJHigP2vwfTH403MkF46j+nTWiGLd7OBTOHclfrSy4Koasrb0nhpyx29Mtxxs/Yl7kTy2MvWsWugFORGDbyCnmbD+ZhcFB7ZcPPNnnnVFbobg5lOa+VsFxJIamPL8q5ToUq9VS4DJeUbep0hg+w/T9W7fXpCkLbMYAtjXN22YtKgdE1e/I8dZ4xNALh7QnyC4b1v7dQcF70/zt1/XJbFIE/iHSSs9/TxOsBcYt2B5xg0NbXjLzZoehTpZdjSdY2hBoQA3eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jedVheM+JrThZ3U5wZlWLXCzJUOc/sbbwwB9b9QfEJQ=; b=WOm9kThlwSFbFeE3gMCy5FnJI/vkgQ+N1GrqOI8Ww2JBUiBklyPubB+i9GPPfF/dYSiV+FOF7JY5X/0Z6kxNuPYl8E6cZGuYBy8n+uuufDCmd6bcnKLfJdwRXJhu/azCjlX5Y2+iMd/pAbRO+/3muUqudTpEzUPl7bfcHnuTv3M= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) by CH2PR12MB4056.namprd12.prod.outlook.com (2603:10b6:610:a5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Thu, 20 Oct 2022 16:50:31 +0000 Received: from BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::f9a4:8620:8238:20e8]) by BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::f9a4:8620:8238:20e8%6]) with mapi id 15.20.5723.034; Thu, 20 Oct 2022 16:50:31 +0000 Message-ID: Date: Thu, 20 Oct 2022 12:50:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] drm/amdkfd: use vma_lookup() instead of find_vma() Content-Language: en-US To: Deming Wang , alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20221020082020.1589-1-wangdeming@inspur.com> From: Felix Kuehling In-Reply-To: <20221020082020.1589-1-wangdeming@inspur.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YT2PR01CA0022.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:38::27) To BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR12MB5115:EE_|CH2PR12MB4056:EE_ X-MS-Office365-Filtering-Correlation-Id: fd171e6a-a4c0-4cdf-cf60-08dab2bb3312 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bAR1Gnx4izQVUs6XI5NLcOv0+EMMYUoikcglU2L6kD32RvBAfj1EhbqPt6/ZLtEYZ5rwAb3dywmI/SYpoB5zpoqDKPId30xnx9aDFtYwXLM+QxkHfBJ9ED5wm19jT9/RV/fyd98W5RO8Yaw6ZR14uJa23IiWw5lJ1s60BwYVH+26w2Tx4RtB3RGTSCawg1lQ/4gsLZMrbmV++XQjuWcSRW2wCzkgZvw00wKXNDLV8Bf1pJpqMHADYzJEWc0e7RseOoeXEgtgjOw1HfJsnmMKM7HJEG9YywH9Bdk+EpHhuevB7FzZWNlYLiE7Z76rYGGgEMSIsJuWxcWfxFoBpb2JonXTOvLaj7stK23x49hbMNenXadgpqAU1SIPD9Qp2cLuwGszAR6qkr/+09AdDFRo1XVVbgySjce7/xDXor4pTRZgxcQbQIoU9gVAzQfnkmSeOZqjD2p2o85QQaf0sL7RHK00RlB9ynAdMTT/QPqO9baDXU5akZ9rsX0DsZa/1X99PdmTyKsoVgV6luXPEIz+JqUHcUsyLzMXBtagTX4ZAraU8pxi6BXzowbHSPM76pxyswnIpwPyVrU0IBzSkmTRt3nOJwpcnVo6Oiq1EHvkJkZENJH5xbfflqm/fRecJlsJqHnh+VJ+uj6m8ZdMT18tyRXWPMz/AwGktNYudBI9M8fTMeRUXbGougw1l6GCIZZgicyFmS67qIBR8skHRaYGX2K4G3Hhk7uRoiSkyayp+pAK9KarUf0d5aqIDbjJEgKRVcY/I4dz3hh8hwjHSN41E6x2Y2GtiQdKXOPR1mJwzRw= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR12MB5115.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(366004)(136003)(39860400002)(451199015)(38100700002)(86362001)(66476007)(5660300002)(6512007)(8676002)(8936002)(41300700001)(66946007)(66556008)(26005)(4326008)(31696002)(316002)(2906002)(4001150100001)(186003)(44832011)(6506007)(2616005)(36756003)(31686004)(6486002)(478600001)(83380400001)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UlVsTHhXZld1S1JEY2Y3OVNEUE5EQmdBY0tGK2Z6ck9xdFBRYjZGWHN4M0NE?= =?utf-8?B?WXVyTU1CRk9XZ21wVkduTWFsVngycUE2dXVqSW5aSkNueXZhNW1qVnplUW0r?= =?utf-8?B?MFVPNmJpMU9CMFplTmUzdndoMDVxM2NQSUxaNVVhR0x4djhHZ3JkUmFpNURh?= =?utf-8?B?QmxBSUdzd2xiSGdBKytVWkh2alZQN2llTGxqOC9MUk5hdFEwckhod0tEK2dh?= =?utf-8?B?ZFROR2hPRWthUksyVXcrSUdoSmFscG5MNGxmWUZ2LzFxUVBhTllUNkEyYXdp?= =?utf-8?B?Ryt6QnBTaVZScFZVUjE3akhaSTByMTBacVl5WXNpclBDczZEM0llNHJ3bC9j?= =?utf-8?B?UnhycVVTUHl6L0YyWGpFQk51TTdVeU8rRkM5OEtZanlCS0JML1laMUdqRWdF?= =?utf-8?B?eXZlVW5j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115.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2022 16:50:31.3094 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: folDD66xi+/2G3reWq78aED7DIyrhI6bK9SjsMmsFeCHi3zTfDDjf9gtkljxUIBGn7JoQBkbE5FrQzu3O0GJzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4056 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 2022-10-20 um 04:20 schrieb Deming Wang: > Using vma_lookup() verifies the start address is contained in the found > vma. This results in easier to read the code. > > Signed-off-by: Deming Wang Thank you. This patch is Reviewed-by: Felix Kuehling I squashed it with your earlier patch in kfd_migrate.c and submitted it to our amd-staging-drm-next branch. Regards,   Felix > --- > drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 17 ++++++++--------- > 1 file changed, 8 insertions(+), 9 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c > index 64fdf63093a0..0100812478b2 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c > @@ -1586,8 +1586,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm, > unsigned long npages; > bool readonly; > > - vma = find_vma(mm, addr); > - if (!vma || addr < vma->vm_start) { > + vma = vma_lookup(mm, addr); > + if (!vma) { > r = -EFAULT; > goto unreserve_out; > } > @@ -2542,8 +2542,8 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr, > struct interval_tree_node *node; > unsigned long start_limit, end_limit; > > - vma = find_vma(p->mm, addr << PAGE_SHIFT); > - if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) { > + vma = vma_lookup(p->mm, addr << PAGE_SHIFT); > + if (!vma) { > pr_debug("VMA does not exist in address [0x%llx]\n", addr); > return -EFAULT; > } > @@ -2871,8 +2871,8 @@ svm_range_restore_pages(struct amdgpu_device *adev, unsigned int pasid, > /* __do_munmap removed VMA, return success as we are handling stale > * retry fault. > */ > - vma = find_vma(mm, addr << PAGE_SHIFT); > - if (!vma || (addr << PAGE_SHIFT) < vma->vm_start) { > + vma = vma_lookup(mm, addr << PAGE_SHIFT); > + if (!vma) { > pr_debug("address 0x%llx VMA is removed\n", addr); > r = 0; > goto out_unlock_range; > @@ -3152,9 +3152,8 @@ svm_range_is_valid(struct kfd_process *p, uint64_t start, uint64_t size) > start <<= PAGE_SHIFT; > end = start + (size << PAGE_SHIFT); > do { > - vma = find_vma(p->mm, start); > - if (!vma || start < vma->vm_start || > - (vma->vm_flags & device_vma)) > + vma = vma_lookup(p->mm, start); > + if (!vma || (vma->vm_flags & device_vma)) > return -EFAULT; > start = min(end, vma->vm_end); > } while (start < end);