Skip to content

Commit 4cabaa0

Browse files
jdreavergregkh
authored andcommitted
virtio: console: Replace deprecated kmap_atomic with kmap_local_page
kmap_atomic() is deprecated and should be replaced with kmap_local_page() [1][2]. kmap_local_page() is faster in kernels with HIGHMEM enabled, can take page faults, and allows preemption. According to [2], this replacement is safe as long as the code between kmap_atomic() and kunmap_atomic() does not implicitly depend on disabling page faults or preemption. In this patch, the only thing happening between mapping and unmapping the page is a memcpy, and I don't suspect it depends on disabling page faults or preemption. [1] https://lwn.net/Articles/836144/ [2] https://docs.kernel.org/mm/highmem.html#temporary-virtual-mappings Signed-off-by: David Reaver <[email protected]> Reviewed-by: Amit Shah <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a01f628 commit 4cabaa0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/char/virtio_console.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -883,9 +883,9 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
883883
if (len + offset > PAGE_SIZE)
884884
len = PAGE_SIZE - offset;
885885

886-
src = kmap_atomic(buf->page);
886+
src = kmap_local_page(buf->page);
887887
memcpy(page_address(page) + offset, src + buf->offset, len);
888-
kunmap_atomic(src);
888+
kunmap_local(src);
889889

890890
sg_set_page(&(sgl->sg[sgl->n]), page, len, offset);
891891
}

0 commit comments

Comments
 (0)