Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp262871rwi; Fri, 14 Oct 2022 01:22:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4wcxD3SRphLrsnNI1auZHhaVqx7L7A1aDTvb4/q0tLezmQKxjyjNebZbK9hUA0kzWZBhjr X-Received: by 2002:a05:6402:2710:b0:45c:d7b4:6948 with SMTP id y16-20020a056402271000b0045cd7b46948mr3257572edd.215.1665735723931; Fri, 14 Oct 2022 01:22:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665735723; cv=pass; d=google.com; s=arc-20160816; b=PStgCSes1ZHbO6KI/1M/b1/S8sqCBw16yy6fa2z0sqLLATIT8bAD3wQlRNdTHg2jze uY4qsFc9gxg4Zc49J0k51khLCGVip5vJFzW74RwYKNa6HW3yD4Q43zZgFYNfHTuiW742 AffIrBKSs7ptTBeK7U8Lo3/SqxFRDesviiqAGMwHG7fjMvnedSjDybk14OYEJyJr0plI aZT9veyItFU2Vrum0cTP603HsiZuD/c4StHR3XXlGEExg6Fsf8YqqwxSz4N/D7+9olg8 KbBQe/iixIyjYxLGY/R4LlB963OErjX+FPkFyriflmLNmI3X8Ct9HVotnYAHtUaSTNE9 ByDw== 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=xw4/FMVSDBV0eAhVw7GA1Kj/0wrxO3sTs6tlBbQ0nM0=; b=kdaITDQkWAniqXOgOG3yN4M6ENXzWZFvLmGYL0nKX6sucVgSCFlx8wBD6MSQm0Cg+T Rdz7YPfU7TxrC2NPfGBuIHqfCANXEL46WrM/jlfwiIKDy07zHyV4DN3dRGLWd66olRJJ AmyusV50qZfsB86eP9+SSkq+kHBU3DZKTW1fvmY3LHj+YZHln1oCIAgQ/SsxRXFDBfgO 4vh7RXLKdNrAkpfV3oSkmBf9DdEXkoBYtZuYQooFBdwiGpxFb/eMAMDBQp9eBE6XI73S TqSY6EV6f7FaDeQZrYg5o6HxqTT7M8ATR9+2h0Cj8NFuibDU20McnajDUksGLyXK9p4D v3mg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=JoHifG1J; 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 go6-20020a1709070d8600b0078b0865d469si2347239ejc.751.2022.10.14.01.21.38; Fri, 14 Oct 2022 01:22:03 -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=JoHifG1J; 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 S229919AbiJNHDh (ORCPT + 99 others); Fri, 14 Oct 2022 03:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbiJNHDe (ORCPT ); Fri, 14 Oct 2022 03:03:34 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2066.outbound.protection.outlook.com [40.107.243.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B393F4185; Fri, 14 Oct 2022 00:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M+i6jm7+H5+FHQam4eqFqtc5E3EgtyvJvQiZpgBtr90z4wTZ0EEfCSl4YB6UHsspZY2wXlah3l8YQHyXUfFWovVTpE03o3GT2cVUlF9lwITRzhmLmgvJFqC5+MQmUKlU94NrXPA03GCcKOFnHr3uvmhO0AQFIF+xbtdc8iVjSLnVywWRTYL5S3hPWcdwftq5NwMa8PEFhFVfFXIrum2RB3OYlrUWeAr5gRWosziKsgAzzr7XP4XD/jxknaB8AQKxFY2I9yLy7qTLH7zcrlz6JTVEoF1w294/jxq40DpvHDn5nHJmgnHYvmhQ3LZt4QYXas9/eVmaa4r1Tx7sn//T6A== 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=xw4/FMVSDBV0eAhVw7GA1Kj/0wrxO3sTs6tlBbQ0nM0=; b=QCaUVBfIuj4Pp//Bry0poMU1B7pMGmko4K1v3g+MzS4TLqkh/TtmVIyeSWse3OASxRBcRcduo9xo6Ge+PzB3PqScEwUkt1IdVcWtynUkWHI/N6RojomrmVu51frQ+dRkmZJ+7knVLKsPMFNx5vahIZvTqVMwtvgED/o8sf7Ksg6DqAz0agbGB+BWHSakaokdUcJh90xZPLqcVKgKQY3ywgqip1DllUxoyBRR+1FQ9/o07oOZWo3C4/7UyjjwmxE5UrsDPRYTyOw5BESt78OU70+Z6BvFgqB9UY0KgjgEKRzco2LpfxuCrLmQ+HR+JqMEY1Zcqndn0ekg4KxIPpllPg== 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=xw4/FMVSDBV0eAhVw7GA1Kj/0wrxO3sTs6tlBbQ0nM0=; b=JoHifG1J1oK13WcnWhYUtPrhD+0D3yPl3wkb0Ih96Lo/xm4///S1gkbVtnM1e5/9pDWadpC0soBbOmV1YTNbhi90kl3ex600zSPF/2cXEu/qm+w6WcVe9n5775EQnjElzSsfN0XhIEfabbny6xaAscN5rdsR1/Ho+sXYOYp4Vko= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by CY5PR12MB6297.namprd12.prod.outlook.com (2603:10b6:930:22::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Fri, 14 Oct 2022 07:03:27 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::805b:58b6:1f27:d644]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::805b:58b6:1f27:d644%6]) with mapi id 15.20.5723.022; Fri, 14 Oct 2022 07:03:28 +0000 Message-ID: Date: Fri, 14 Oct 2022 09:03:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] drm/radeon: Replace kmap() with kmap_local_page() Content-Language: en-US To: "Fabio M. De Francesco" , Alex Deucher , "Pan, Xinhui" , David Airlie , Daniel Vetter , Christian Brauner , Sumit Semwal , Jean Delvare , Guenter Roeck , Kees Cook , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, linux-hwmon@vger.kernel.org, linux-hardening@vger.kernel.org Cc: "Venkataramanan, Anirudh" , Ira Weiny References: <20221013210714.16320-1-fmdefrancesco@gmail.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20221013210714.16320-1-fmdefrancesco@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR0P281CA0056.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::6) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|CY5PR12MB6297:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a4f244d-552c-476a-55a3-08daadb231d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bIMjYxzIGeZ31EXyLxaBvnbIdeHliJbZKp7V26Z5TiWURHlbS80q0AEI9djTmPAph1oPVGmb39+w3krgPwoLqDCq6VfnMUXwLinYWV0Z408tZGAjCMM3KAhnlf63Td1M3mLmpxe5rfztBpwhUsi994PJY7SsyTSvDKrBnS0kmCLbF0N/sbRFyF3AMAJ/KuQjcLQ9lLYM9WRgvlEkiZja5v/I99BEOFeS82mWR/qC7N59NK7XiQcZ8BkyQvGP/UrVyIFywSmZXstPboX0te2PNE/xcAgHUwB8gtAdeJCo3YS/IpdYogvjRfB/LKOXvu7lLHxcOZa+DZc22nncATT9I2tHg6Twqq1zhtOlI6hRe3l/feLnfbUAQET0GAHpmLvK4e0gjsueW8MRiSxTkCS+bJ4OBZ6UJpg7mSmkthu73FOaXV3XbLhFHNdrCOMjhSPKiaB4UpLJh2iPTPcNOqNqViXGg688mU8b1G45lzAGi3/h1qBqsoLNe4uxQAiL0cpZDThyzIQBqfrxD/5Iepu6UDQXF+tRpmyx8YgQCZh03m8/JpAAROXv3QHQjooLpmFp7VZaMUlHr0mui3FJAtaizDjJz4PiBg39MEJUMVMHrRBF9hxEdDx6ZeXljU6ZVkkOAQJjVYtlyUNGudD8IlVo2q3O9tJUUpeLtLLZNWB+X6wk3ndvoUQx7CUsFqhXvcfcj740bOTj+vfA9jE3KJsfNVFPG5Uj9b55SooSPFLrqiVNgdFsk4UNhcEjPCrpeW23R6FWaPRQOaIb4TJESkHtOeJGSrF8q7x67XtPc2xUahNWWJ0I/xvtjlmN5czATi/k X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(366004)(136003)(376002)(346002)(451199015)(31686004)(83380400001)(2616005)(66574015)(186003)(2906002)(86362001)(31696002)(8676002)(4326008)(36756003)(41300700001)(6506007)(921005)(5660300002)(316002)(38100700002)(66556008)(66476007)(8936002)(54906003)(6512007)(7416002)(66946007)(6666004)(478600001)(6486002)(110136005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?NUM1UUQxZElBM1lEZk9PeGIrY2Y0akQ4N0xoOEJjODdXYkU0aUV6Y0hJUFZE?= =?utf-8?B?aEdiN1UyZkovZU5jVEh6ZW9QbGRpaXVoL3ovOWh6QUlWcGxQUzBGYnNYUWdI?= =?utf-8?B?aDFJZGJWUkYyU1RlcXI3UjJRUVZiNEliSWZKTXNOQUhYeXc4VGYwNjQzWkFG?= =?utf-8?B?NlBmYmNsY0NYYlRPMlhxbW5JWXAxT0V0cVNGOVUzSndwUTN6bldjOWN2OC91?= =?utf-8?B?amlXeVhFR0c4STAwUHluVEJtckV1a2VyZm1WNXBUMnZ4YXkzZUMxOEV4SDMv?= =?utf-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IZXMwSkUxYkxPNEpXL3NGdDBROEZMbXNz?= =?utf-8?B?OW5hUldxVlhyLy9LbW9zVVhOamVzU0J3OGE1TExYL2x5eW1EUWlDbVlCMDlq?= =?utf-8?Q?Dql86tNOAKt7ekIgXNUsFTN2k+Nfsh5QTorx46rk4RKx?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a4f244d-552c-476a-55a3-08daadb231d2 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 07:03:28.0342 (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: XxPqStKG7Mzf4ZZ4anyw/9htG68UlKaFqYOuZTslpi22IroQ6GrFay3yTy21OnOr X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR12MB6297 X-Spam-Status: No, score=-3.4 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 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 13.10.22 um 23:07 schrieb Fabio M. De Francesco: > The use of kmap() is being deprecated in favor of kmap_local_page(). > > There are two main problems with kmap(): (1) It comes with an overhead as > the mapping space is restricted and protected by a global lock for > synchronization and (2) it also requires global TLB invalidation when the > kmap’s pool wraps and it might block when the mapping space is fully > utilized until a slot becomes available. > > With kmap_local_page() the mappings are per thread, CPU local, can take > page faults, and can be called from any context (including interrupts). > It is faster than kmap() in kernels with HIGHMEM enabled. Furthermore, > the tasks can be preempted and, when they are scheduled to run again, the > kernel virtual addresses are restored and still valid. > > Therefore, replace kmap() with kmap_local_page() in radeon_ttm_gtt_read(). > > Cc: "Venkataramanan, Anirudh" > Suggested-by: Ira Weiny > Signed-off-by: Fabio M. De Francesco Reviewed-by: Christian König > --- > drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c > index d33fec488713..bdb4c0e0736b 100644 > --- a/drivers/gpu/drm/radeon/radeon_ttm.c > +++ b/drivers/gpu/drm/radeon/radeon_ttm.c > @@ -869,11 +869,11 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf, > > page = rdev->gart.pages[p]; > if (page) { > - ptr = kmap(page); > + ptr = kmap_local_page(page); > ptr += off; > > r = copy_to_user(buf, ptr, cur_size); > - kunmap(rdev->gart.pages[p]); > + kunmap_local(ptr); > } else > r = clear_user(buf, cur_size); >