From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 456CBC43217 for ; Fri, 14 Oct 2022 02:41:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229594AbiJNClp (ORCPT ); Thu, 13 Oct 2022 22:41:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229624AbiJNCln (ORCPT ); Thu, 13 Oct 2022 22:41:43 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95057196B5D for ; Thu, 13 Oct 2022 19:41:41 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id q10-20020a17090a304a00b0020b1d5f6975so3601417pjl.0 for ; Thu, 13 Oct 2022 19:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ZJ1ZupV4pNYtfLm2nRk080Y8SXTuWCwx9eOCEUYrnLk=; b=mOTc8KRBadMqtPwLlQpMoDRG7Y/LhVh3ONQQ0+J/2DeJP9z2WBpqzM2zCbruFAwGQ2 Cg9NrAsdBApxkVi7G6+/BmIIhGYCILZRVDKJgLmeZAjnkd+DscSYsrIh2d0DhZEicFJ4 JC0NBSOAxXyESKVnAJK6Z1UcYpKzjFbwvjdW4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZJ1ZupV4pNYtfLm2nRk080Y8SXTuWCwx9eOCEUYrnLk=; b=c/PuWAvRTCadktSE6GoZ5aqkQ2ji4sr0yXv5CNlUaLpdtKQagMRk3HcHGjUf5pCsj1 7FKpRAge/ZAA8a621cLSZO1CuRFePbDEzUy6cFdxJToLXbMwRAlVSQzhUonXpHqwYcER Vw9Cdo7zJhj1FOKpoKC9BL7eY/8QYknZX9dDTiaK+/DUqXor29KGejT0V/bGK7Ihwnye SONNRWH/CWueEf4oD/WOezdvg7deyRZ+t5/63lrf5gFD1luOjTeInqbqwi6MI2HyWk4A tz23CO6in2L3ycm2WR88J08d8aXyybgPoNPtHwuaxVV5eeZFWKmblzwWS3LqmQl9iO9y 4PRQ== X-Gm-Message-State: ACrzQf194GK6P7dWyq0NbuPAemAt1zRzRSJuhooO83Wm4+FewaBAZiX4 ygUFEgm/0sCVEDT/wuNLwwVKSw== X-Google-Smtp-Source: AMsMyM4+EvyJIPbh8SsjJ5/w//6R6z4mUB4NPnFpN2sJpNlsISjzDqMI4t1DceTMwEIjNQHzGR0rDg== X-Received: by 2002:a17:90a:d983:b0:20a:ec04:e028 with SMTP id d3-20020a17090ad98300b0020aec04e028mr14425285pjv.122.1665715301104; Thu, 13 Oct 2022 19:41:41 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o2-20020a170902d4c200b001708c4ebbaesm467745plg.309.2022.10.13.19.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 19:41:40 -0700 (PDT) Date: Thu, 13 Oct 2022 19:41:39 -0700 From: Kees Cook To: "Fabio M. De Francesco" Cc: Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Christian Brauner , Sumit Semwal , Jean Delvare , Guenter Roeck , 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, "Venkataramanan, Anirudh" , Ira Weiny Subject: Re: [PATCH] drm/radeon: Replace kmap() with kmap_local_page() Message-ID: <202210131941.5D2AD4403E@keescook> References: <20221013210714.16320-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221013210714.16320-1-fmdefrancesco@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On Thu, Oct 13, 2022 at 11:07:14PM +0200, Fabio M. De Francesco wrote: > 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: Kees Cook -- Kees Cook