[Devel] [PATCH RH9 26/30] tty: use kvmalloc for screenbuffer allocation
Andrey Zhadchenko
andrey.zhadchenko at virtuozzo.com
Tue Sep 28 21:49:17 MSK 2021
From: Oleg Babin <obabin at virtuozzo.com>
Console driver allocates a screenbuffer with kmalloc(). The
size of the buffer can be up to 32768 bytes which is the 3rd
memory order.
Use kvmalloc() for screenbuffer allocation to fallback to vmalloc()
in case of high order page is not available at the moment.
https://jira.sw.ru/browse/HCI-53
Signed-off-by: Oleg Babin <obabin at virtuozzo.com>
[VvS RHEL7.8 rebase] context changes
(cherry picked from vz7 commit 472011f16561 ("tty: use kvmalloc for
screenbuffer allocation"))
VZ 8 rebase part https://jira.sw.ru/browse/PSBM-127798
Signed-off-by: Alexander Mikhalitsyn <alexander.mikhalitsyn at virtuozzo.com>
(cherry picked from vz8 commit 41eb48611eb41a923882c095b63c92455efb7b0b)
Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
---
drivers/tty/vt/vt.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index ef981d3..ff58736 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1144,7 +1144,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size)
goto err_free;
err = -ENOMEM;
- vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
+ vc->vc_screenbuf = kvzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
if (!vc->vc_screenbuf)
goto err_free;
@@ -1160,7 +1160,7 @@ int vc_allocate(unsigned int currcons) /* return 0 on success */
return 0;
err_free:
visual_deinit(vc);
- kfree(vc);
+ kvfree(vc);
vc_cons[currcons].d = NULL;
return err;
}
@@ -1224,14 +1224,14 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
if (new_screen_size > KMALLOC_MAX_SIZE || !new_screen_size)
return -EINVAL;
- newscreen = kzalloc(new_screen_size, GFP_USER);
+ newscreen = kvzalloc(new_screen_size, GFP_USER);
if (!newscreen)
return -ENOMEM;
if (get_vc_uniscr(vc)) {
new_uniscr = vc_uniscr_alloc(new_cols, new_rows);
if (!new_uniscr) {
- kfree(newscreen);
+ kvfree(newscreen);
return -ENOMEM;
}
}
@@ -1244,7 +1244,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
err = resize_screen(vc, new_cols, new_rows, user);
if (err) {
- kfree(newscreen);
+ kvfree(newscreen);
vc_uniscr_free(new_uniscr);
return err;
}
@@ -1302,7 +1302,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
vc->vc_screenbuf = newscreen;
vc->vc_screenbuf_size = new_screen_size;
set_origin(vc);
- kfree(oldscreen);
+ kvfree(oldscreen);
/* do part of a reset_terminal() */
vc->vc_top = 0;
@@ -1384,7 +1384,7 @@ struct vc_data *vc_deallocate(unsigned int currcons)
con_free_unimap(vc);
put_pid(vc->vt_pid);
vc_uniscr_set(vc, NULL);
- kfree(vc->vc_screenbuf);
+ kvfree(vc->vc_screenbuf);
vc_cons[currcons].d = NULL;
}
return vc;
--
1.8.3.1
More information about the Devel
mailing list