From: Dongli Zhang Date: Sat, 23 Jan 2021 08:08:53 +0000 (-0800) Subject: vhost scsi: alloc vhost_scsi with kvzalloc() to avoid delay X-Git-Tag: accepted/tizen/unified/20230118.172025~7623^2~31 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=489084dd3f7e4bd649814bd62839aef4456659e8;p=platform%2Fkernel%2Flinux-rpi.git vhost scsi: alloc vhost_scsi with kvzalloc() to avoid delay The size of 'struct vhost_scsi' is order-10 (~2.3MB). It may take long time delay by kzalloc() to compact memory pages by retrying multiple times when there is a lack of high-order pages. As a result, there is latency to create a VM (with vhost-scsi) or to hotadd vhost-scsi-based storage. The prior commit 595cb754983d ("vhost/scsi: use vmalloc for order-10 allocation") prefers to fallback only when really needed, while this patch allocates with kvzalloc() with __GFP_NORETRY implicitly set to avoid retrying memory pages compact for multiple times. The __GFP_NORETRY is implicitly set if the size to allocate is more than PAGE_SZIE and when __GFP_RETRY_MAYFAIL is not explicitly set. Cc: Aruna Ramakrishna Cc: Joe Jin Signed-off-by: Dongli Zhang Link: https://lore.kernel.org/r/20210123080853.4214-1-dongli.zhang@oracle.com Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang --- diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4ce9f00..5de21ad 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1814,12 +1814,9 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) struct vhost_virtqueue **vqs; int r = -ENOMEM, i; - vs = kzalloc(sizeof(*vs), GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL); - if (!vs) { - vs = vzalloc(sizeof(*vs)); - if (!vs) - goto err_vs; - } + vs = kvzalloc(sizeof(*vs), GFP_KERNEL); + if (!vs) + goto err_vs; vqs = kmalloc_array(VHOST_SCSI_MAX_VQ, sizeof(*vqs), GFP_KERNEL); if (!vqs)