Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1772625rwi; Thu, 13 Oct 2022 20:00:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Ufy8xvir2HJwI+61IYxXnZblQSVcoH+WiG6X1KiKp4b3PSQl09OONjD8QJGud8/sZd1Oe X-Received: by 2002:a17:907:6eac:b0:78d:ce9c:3761 with SMTP id sh44-20020a1709076eac00b0078dce9c3761mr1924204ejc.738.1665716425638; Thu, 13 Oct 2022 20:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665716425; cv=none; d=google.com; s=arc-20160816; b=RRB76m11YDEkmuojvxswEK2n7UqFZyEnZztDeMqJ0O3gC6pZvzpv4/BbfzvmZjdq12 Y8rsfFt6Nvg1RM2kukuytbJIf8NZ7Lpajj8RJm3sDW7gz2j8K6Sazsr2hsqNKw4aOLkJ VdXYZofrVnhyJ4EsdOCIPHCUz9i/JqrYHRwAGYvhA8cY3aWXcTQP9dwrSWjhPiHeuHhE VbRbIxxaxaZwS5wQ3qaQV4aMlGOj+x9l4JIk4Y+qUQbZd39jXCTDlEycKeTXx/s6t0y3 bxwglajgCj7iCf4ARIlWf7HeN95iz9+UE5SHMZWBkWsTENIfPx8gJWmt4rti+AL7rupj ENAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZJ1ZupV4pNYtfLm2nRk080Y8SXTuWCwx9eOCEUYrnLk=; b=i1FFAMx6XR4ElIeUXWNfbHTp4AIekvXiRs1uywtPpkXFzmUKRgbMMOKIo6iRul28ho XdXHcE5gKkT2s+HICyAbaHtRtDcoNXjbHfqJYFwojwAHFXQf9MaORyBbl6ewKQtelB6v TQCr5+0yoXGG35GmVGF8MQs1qqZQm6y/e+/u6g+6mtHzrBsSVknHdUd51JcJZUrxu8Qn 7OaFEabMOgyUERpsdjcNIUSP7Fzg2+7ei2WZB6AqM1I44Psm3b0nRxgQhKLhwXt4WIcC zbsJTiOY9EIWa5IuiwunkFe+SPFU/ywrtZRTH1pmro3dV7MI+5sZ0H1pmCoC8hG4eGq6 l5QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=mOTc8KRB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020aa7cad4000000b0045bc92ef2c0si1135715edt.195.2022.10.13.19.59.57; Thu, 13 Oct 2022 20:00:25 -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=@chromium.org header.s=google header.b=mOTc8KRB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229624AbiJNClq (ORCPT + 99 others); Thu, 13 Oct 2022 22:41:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiJNCln (ORCPT ); Thu, 13 Oct 2022 22:41:43 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D08318D805 for ; Thu, 13 Oct 2022 19:41:41 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso6802902pjq.1 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=iZW7b5v+xg43GGnuu1tJfi5Y34bXpvrFqHhSpMAOtApwZXoDTnFKtSuLDMUZL+rfsl 95DZ7eRCq/n1NNZ8lNqha6cgYVwTOjDSLH/wMz4Ays73HGld4kBoeMIjD8hKoWBXJ6Sd H+lbuUJS97uY+SgRJ+wi3Px51945KwbaW4lztiyJNdHWi1eX+BWza15XV7irCuIMNEXd MsXqrtXuzcZrzQ79uF/6wLkR3+mgPqCmYyjK6cuUavxmMc+AKTjBXXaDNl0vTYuV6VwC Ce7pqJrwjzAoeWGVkaxCZO/sv1MtMlVggWSGOaEMFLqoXURT1MqYb0PX66iN6IcuVgv4 pgrw== X-Gm-Message-State: ACrzQf3chNIUchgIn88OFx10sIkn2w/hFtLIG9bfD1ehCaECxsKWM84Q Z1KegvULvgN9rF95ARFkUJmutA== 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> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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