Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4765086rwi; Mon, 17 Oct 2022 10:21:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5jsh4Znva6DVhBh+yecfK1TnD9dvQuyHbVAQzRY65GHuglpVQKteWFu9Ydsnt1qlVz/r3D X-Received: by 2002:a63:86c1:0:b0:458:b8d7:71d3 with SMTP id x184-20020a6386c1000000b00458b8d771d3mr11295137pgd.385.1666027273249; Mon, 17 Oct 2022 10:21:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666027273; cv=none; d=google.com; s=arc-20160816; b=hfeHPzsXNMi3375ZCqFs9UrQlSOBNVXrE8g6lNG8NBtrA7UPtJjPugMZZ3Yk3HIfQL 4ztLDsTWP0ww3lo4qB1cpnyujS3k6Yp1en55pVFns6yXqOy1csgfqhPOexCTf7h0smQa 48BA6ADwqrluIhkNTPukY1a76Mqnkv+ZEUCOLhKD//snxZVO428eyTfeEnuWacS/Vzv2 0cxwZTt9IoqMdeV1W9d+C7v99s5SYfx1yCcWhp4t3dlHIiyBKoJSihteyqr5HYY1vFqW FVpHSgUkDsczydPi3cbxf6QujvK9Yx79V/Ivi4SJHc5YNb+L7aUEyO/BKj08Xgidm7qR ZBrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=+1LwX5bRFQXNkq6PB+GJkYIHW1maFFhRT+npXlh3EBU=; b=grg72ZNJcG0yPtJphGPLMM/+sSepQO4Bemkli11s8luexuplpQaTXPmViq60BGZ8jS bP+zCuk4bZNNrbfuNfqH+K+eiQzUGgNOkzu01z5mOOXEIZ/RZ9uN6b8ku6bPw6/YGMZf WRB6NHAv8OmIgDVV0e9fBFKBdPXU++rfB1ECn0C3pV15cbErmi+D7QRkMsSs9rmJG02+ r0Ln/wJfCcCa5Hrza1EDAwgSk0of9cjuf4gV3TOCU4fFZHQVdwqnJxYT5yfMLoRCd8Wj RuLw/VB0zYurb4LYRk84w94azXHkbC6JSz2gLOONSceHpmSag8wKZhNrvEqhNmrVUpqt ii+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Wli2+vCU; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w62-20020a638241000000b0045f979b5f2dsi11554842pgd.823.2022.10.17.10.20.59; Mon, 17 Oct 2022 10:21:13 -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=@gmail.com header.s=20210112 header.b=Wli2+vCU; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229922AbiJQQwZ (ORCPT + 99 others); Mon, 17 Oct 2022 12:52:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbiJQQwX (ORCPT ); Mon, 17 Oct 2022 12:52:23 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E86CF031; Mon, 17 Oct 2022 09:52:22 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id n130so12753068oia.6; Mon, 17 Oct 2022 09:52:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+1LwX5bRFQXNkq6PB+GJkYIHW1maFFhRT+npXlh3EBU=; b=Wli2+vCUPK20VH6qBK0/9u0+D86Cprn715QA3rGfohk6lLxfaKQ/gr2fBPGeUKivfV 9scv3keMMR40vWDmdGPV9mBFqcrR3IHAjiKgk9g2HFz+2GzmZeYm2V80n+MJ78WVfpcT yeYzVTE/N/xMeay1FUkdDXp4VjEEugswL6+/mgtjc3koOgAHsXFOFPuqyxYHHSkwavDv C+M6uSoIBnLjtzFoB6Ioq0cJQ0heFLwsSXacVrlHTrT1UMeP6VkCilRtw5NikcgJK2rM 52sgzEMrbJk98DoOJk/9P8dvOgrS6rFCixGcl08kKYuIS08WWQTsUWkkSY90XgZi+dpx Y0Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+1LwX5bRFQXNkq6PB+GJkYIHW1maFFhRT+npXlh3EBU=; b=XSSNn23qw/E0UN8ffxR5ZpQNZdHRIaPHIlYMLIJLCONrfLQIoossvJu098Kea8vvO2 G5p0I6/uftBfotA8cjJf1RSS0ZeRM4B9pHLzgW8N+nchKJAXMWS9WnQQFOTveSrmpFz1 LJPzUWMqtgLdQtCg0YO8ErZTb441Rw1H8ESpjpJiHgKoE5ECP7HdobC1fwvUMO3TAvjP o/EDCPb3qkytJQsjKDCbXVFoZ+ndFgO9eU7vwm+UTQaFqOF0G9bPxY3cZD5AJ+eFWmzN rQGK5eJtpMmx5zuNYmewxjPQORkDlSBPuPafKz6olaQw88m5DdqcbqJrPPXdMhnbL8Go CDJw== X-Gm-Message-State: ACrzQf1nQvzPzYESHAA6ACxGrbAm0A5rvo5pjGpqaWYFcDUskChRdIP0 78bH5vQJ4wLob1gR+FTOcHKKCv3ma4n03pcuBIM= X-Received: by 2002:a05:6808:14d2:b0:354:c733:abd3 with SMTP id f18-20020a05680814d200b00354c733abd3mr5577155oiw.96.1666025541711; Mon, 17 Oct 2022 09:52:21 -0700 (PDT) MIME-Version: 1.0 References: <20221013210714.16320-1-fmdefrancesco@gmail.com> In-Reply-To: From: Alex Deucher Date: Mon, 17 Oct 2022 12:52:10 -0400 Message-ID: Subject: Re: [PATCH] drm/radeon: Replace kmap() with kmap_local_page() To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: "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, "Venkataramanan, Anirudh" , Ira Weiny Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 Applied. Thanks! On Fri, Oct 14, 2022 at 3:03 AM Christian K=C3=B6nig wrote: > > 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 t= he > > kmap=E2=80=99s 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, t= he > > 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=C3=B6nig > > > --- > > 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/rade= on/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 =3D rdev->gart.pages[p]; > > if (page) { > > - ptr =3D kmap(page); > > + ptr =3D kmap_local_page(page); > > ptr +=3D off; > > > > r =3D copy_to_user(buf, ptr, cur_size); > > - kunmap(rdev->gart.pages[p]); > > + kunmap_local(ptr); > > } else > > r =3D clear_user(buf, cur_size); > > >