virtio: console: Replace deprecated kmap_atomic with kmap_local_page
Subsystems (3)
PATCH 1/1 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
--- drivers/char/virtio_console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/virtio_console.c +2 -2
@@ -883,9 +883,9 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf,if (len + offset >PAGE_SIZE ) len =PAGE_SIZE - offset; - src =kmap_atomic (buf->page); + src =kmap_local_page (buf->page);memcpy (page_address (page) + offset, src + buf->offset, len); -kunmap_atomic (src); +kunmap_local (src);sg_set_page (&(sgl->sg[sgl->n]), page, len, offset); }
Quoted 16 lines · David Reaver
kmap_atomic()is deprecated and should be replaced withkmap_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()andkunmap_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.
Quoted 5 lines
[1] https://lwn.net/Articles/836144/
[2]
https://docs.kernel.org/mm/highmem.html#temporary-virtual-mappingsSigned-off-by David Reaver <[email protected]>
Quoted 3 lines · David Reaver
kmap_atomic()is deprecated and should be replaced withkmap_local_page()[1][2].kmap_local_page()is faster in kernels with HIGHMEM enabled, can take page faults, and allows preemption.
Thanks for taking these on! It is good to see some progress here.
Quoted 20 lines
According to [2], this replacement is safe as long as the code between
kmap_atomic()andkunmap_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-mappingsSigned-off-by David Reaver <[email protected]>--- drivers/char/virtio_console.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/char/virtio_console.c +0
-0
drivers/char/virtio_console.c static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf, · line 888
Quoted 8 lines
drivers/char/virtio_console.c +2
-2@@ -883,9 +883,9 @@ static int pipe_to_sg(struct pipe_inode_info *pipe, struct pipe_buffer *buf,if (len + offset >PAGE_SIZE ) len =PAGE_SIZE - offset; - src =kmap_atomic (buf->page); + src =kmap_local_page (buf->page);memcpy (page_address (page) + offset, src + buf->offset, len); -kunmap_atomic (src); +kunmap_local (src);
memcpy_to_page()
Ira
[snip]