Message ID | 20231203132947.2328805-4-zhao1.liu@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp2229078vqy; Sun, 3 Dec 2023 05:18:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+hPjQXFIIjXOyW9O8ud+g64t5cc+kD5kFxLxj4HSJWg7d9B280H1/y06n4bgOT7Qv8LRo X-Received: by 2002:a92:c609:0:b0:35d:6ea6:4cba with SMTP id p9-20020a92c609000000b0035d6ea64cbamr385415ilm.2.1701609497298; Sun, 03 Dec 2023 05:18:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701609497; cv=none; d=google.com; s=arc-20160816; b=j+MnB2D9N/r05C269J4pa/t1FiOQbod3olikT7To/Rs1tw4VlFCwrImFsMG0LldJSg lU8ta6TsJavQOAVGk4Dm/NtqKGVvjvSQUfY5WZR4iWHuuOpCmtw+qspbabMRilytt8tf HN4oWn4zXK5ZSu+4kdZc/Y+kR9LTiBFwOGDnKfh/XZLGgevXtcBSi9TRmLfTe1XiSCgs VUETwDILopuFAbvm0WYiAv/h5UXiGlGDoYaSvRmNwp1oY8pOQSo8rPVG+VO/yt7C7l+5 dwSLDnwJyJUEjM8ahP9gwy0Cca6a2JqrFXTiSIH0qRV5HcJ7yktfqJp3ubc+6UQAhdnI sUag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xP3do6Qu8y1Gsi9NpJLfZtIdpYHPIed1DXj+Uqc/TZI=; fh=aOKhvLhXHslfuzaDqJh6ZHsMiX4q2rttF8xXq/x74s8=; b=lZ+Kdm5T/R7U7RI/mTOJtw+QQRsWaWgyTZTEQEoiD1OGQVePLJrvUYbVZ2dE7OXdZs A0z1g3DWs6x85ihqTwS1C3zp0kfbReVY3oiGGWB5S4pwrfXlchJsGT4l5wotLwa8Vdkg ONN+XwJEkr09QjI6mn5lRYtFwKKGfc9W8Pnm9+GKuDoepx1cPkhqmOuHnkVnUs3+PfOZ wZ0eS2dbyyKICJBaO1vZQvUrguM+jIkv1hNTlgHiebFwJr5Ch8tT+qFsAfDMz3Ntkqq9 RkJDq3LdxY2veSDFp9ZrjGQ4LL70/31d4pfy5t6D6Rha/NIzF/dxlupGZJxGM9JIu9Bv VhYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BcHlv1lo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id i17-20020a63d451000000b005c626072edfsi6329189pgj.773.2023.12.03.05.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 05:18:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BcHlv1lo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D17DC8068968; Sun, 3 Dec 2023 05:18:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233617AbjLCNSA (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sun, 3 Dec 2023 08:18:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjLCNRx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 3 Dec 2023 08:17:53 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D6B1102 for <linux-kernel@vger.kernel.org>; Sun, 3 Dec 2023 05:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701609477; x=1733145477; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xk0v3edNgmlsBbxSQneTxOyfsCMSJWY4MBCAqYlM+Qk=; b=BcHlv1loRqlFTYqxluUKp5CmOQMrgURAVq5XJuhi6Uf94Fmpm4srF0AG pDk35EvghzaGqapiFQjSSxehqNLIRn0mbzw59xzTb/WDAzJrkNNiCPW/4 umQaGd+kE76/XS0ktW42a8mxiPXJq+N9XFJNxFJtMKq/MTKQNtonhdSVk 9yVaJsLYRcA0ovomPJNyuKJOi0IsRmoQcDYa7cY/GUAN2gdcKfdkdCcil WmhLk3+c2wFiRXAfK3ZqAwHq4NvI+zrnkpVtWATqpp9cbWAzlBlu+zk+l xmbM/Nif592bdWqiRP+e+9+ywHCqQAICq92MV+NMw2VyGSvttsR3Kpcnx A==; X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="498224" X-IronPort-AV: E=Sophos;i="6.04,247,1695711600"; d="scan'208";a="498224" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2023 05:17:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10912"; a="770262372" X-IronPort-AV: E=Sophos;i="6.04,247,1695711600"; d="scan'208";a="770262372" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga002.jf.intel.com with ESMTP; 03 Dec 2023 05:17:52 -0800 From: Zhao Liu <zhao1.liu@linux.intel.com> To: Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, Ira Weiny <ira.weiny@intel.com>, "Fabio M . De Francesco" <fmdefrancesco@gmail.com>, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Dave Hansen <dave.hansen@intel.com>, Zhenyu Wang <zhenyu.z.wang@intel.com>, Zhao Liu <zhao1.liu@intel.com> Subject: [PATCH v3 3/9] drm/i915: Use kmap_local_page() in gem/i915_gem_shmem.c Date: Sun, 3 Dec 2023 21:29:41 +0800 Message-Id: <20231203132947.2328805-4-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231203132947.2328805-1-zhao1.liu@linux.intel.com> References: <20231203132947.2328805-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 03 Dec 2023 05:18:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784266880169239758 X-GMAIL-MSGID: 1784266880169239758 |
Series |
drm/i915: Replace kmap_atomic() with kmap_local_page()
|
|
Commit Message
Zhao Liu
Dec. 3, 2023, 1:29 p.m. UTC
From: Zhao Liu <zhao1.liu@intel.com> The use of kmap_atomic() is being deprecated in favor of kmap_local_page()[1]. The main difference between atomic and local mappings is that local mappings doesn't disable page faults or preemption (the preemption is disabled for !PREEMPT_RT case, otherwise it only disables migration). With kmap_local_page(), we can avoid the often unwanted side effect of unnecessary page faults or preemption disables. In drm/i915/gem/i915_gem_shmem.c, the function shmem_pwrite() need to disable pagefault to eliminate the potential recursion fault[2]. But here __copy_from_user_inatomic() doesn't need to disable preemption and local mapping is valid for sched in/out. So it can use kmap_local_page() / kunmap_local() with pagefault_disable() / pagefault_enable() to replace atomic mapping. [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny@intel.com [2]: https://patchwork.freedesktop.org/patch/295840/ Suggested-by: Ira Weiny <ira.weiny@intel.com> Suggested-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> --- Suggested by credits: Ira: Referred to his suggestions about keeping pagefault_disable(). Fabio: Referred to his description about why kmap_local_page() should be preferred. --- drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c index 73a4a4eb29e0..38b72d86560f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c @@ -485,11 +485,13 @@ shmem_pwrite(struct drm_i915_gem_object *obj, if (err < 0) return err; - vaddr = kmap_atomic(page); + vaddr = kmap_local_page(page); + pagefault_disable(); unwritten = __copy_from_user_inatomic(vaddr + pg, user_data, len); - kunmap_atomic(vaddr); + pagefault_enable(); + kunmap_local(vaddr); err = aops->write_end(obj->base.filp, mapping, offset, len, len - unwritten, page, data);