drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter
authorTaotao Chen <chentaotao@didiglobal.com>
Wed, 16 Jul 2025 09:36:04 +0000 (09:36 +0000)
committerChristian Brauner <brauner@kernel.org>
Wed, 16 Jul 2025 12:48:18 +0000 (14:48 +0200)
commit048832a3f4003113c3a0f060b08376c103622099
treea700a7bf6cc720af73b5415fffc0a7b69fe1bde4
parente7b840fd4956da86e93a8258155cf3e127f509e7
drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter

Refactors shmem_pwrite() to replace the ->write_begin/end logic
with a write_iter-based implementation using kiocb and iov_iter.

While kernel_write() was considered, it caused about 50% performance
regression. vfs_write() is not exported for kernel use. Therefore,
file->f_op->write_iter() is called directly with a synchronously
initialized kiocb to preserve performance and remove write_begin
usage.

Performance results use gem_pwrite on Intel CPU i7-10700
(average of 10 runs):

- ./gem_pwrite --run-subtest bench -s 16384
  Before: 0.205s, After: 0.214s

- ./gem_pwrite --run-subtest bench -s 524288
  Before: 6.1021s, After: 4.8047s

Part of a series refactoring address_space_operations write_begin and
write_end callbacks to use struct kiocb for passing write context and
flags.

Signed-off-by: Taotao Chen <chentaotao@didiglobal.com>
Link: https://lore.kernel.org/20250716093559.217344-3-chentaotao@didiglobal.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
drivers/gpu/drm/i915/gem/i915_gem_shmem.c