From: Dongli Zhang <dongli.zhang@oracle.com> To: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, stefanha@redhat.com, joe.jin@oracle.com, aruna.ramakrishna@oracle.com Subject: [PATCH 1/1] vhost scsi: allocate vhost_scsi with GFP_NOWAIT to avoid delay Date: Wed, 20 Jan 2021 21:03:28 -0800 [thread overview] Message-ID: <20210121050328.7891-1-dongli.zhang@oracle.com> (raw) The size of 'struct vhost_scsi' is order-10 (~2.3MB). It may take long time delay by kzalloc() to compact memory pages 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 changes allocation to GFP_NOWAIT in order to avoid the delay caused by memory page compact. Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> Cc: Joe Jin <joe.jin@oracle.com> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com> --- Another option is to rework by reducing the size of 'struct vhost_scsi', e.g., by replacing inline vhost_scsi.vqs with just memory pointers while each vhost_scsi.vqs[i] should be allocated separately. Please let me know if that option is better. drivers/vhost/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4ce9f00ae10e..85eaa4e883f4 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1814,7 +1814,7 @@ 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); + vs = kzalloc(sizeof(*vs), GFP_NOWAIT | __GFP_NOWARN); if (!vs) { vs = vzalloc(sizeof(*vs)); if (!vs) -- 2.17.1
WARNING: multiple messages have this Message-ID (diff)
From: Dongli Zhang <dongli.zhang@oracle.com> To: virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, netdev@vger.kernel.org Cc: aruna.ramakrishna@oracle.com, mst@redhat.com, joe.jin@oracle.com, linux-kernel@vger.kernel.org, stefanha@redhat.com, pbonzini@redhat.com Subject: [PATCH 1/1] vhost scsi: allocate vhost_scsi with GFP_NOWAIT to avoid delay Date: Wed, 20 Jan 2021 21:03:28 -0800 [thread overview] Message-ID: <20210121050328.7891-1-dongli.zhang@oracle.com> (raw) The size of 'struct vhost_scsi' is order-10 (~2.3MB). It may take long time delay by kzalloc() to compact memory pages 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 changes allocation to GFP_NOWAIT in order to avoid the delay caused by memory page compact. Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> Cc: Joe Jin <joe.jin@oracle.com> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com> --- Another option is to rework by reducing the size of 'struct vhost_scsi', e.g., by replacing inline vhost_scsi.vqs with just memory pointers while each vhost_scsi.vqs[i] should be allocated separately. Please let me know if that option is better. drivers/vhost/scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 4ce9f00ae10e..85eaa4e883f4 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -1814,7 +1814,7 @@ 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); + vs = kzalloc(sizeof(*vs), GFP_NOWAIT | __GFP_NOWARN); if (!vs) { vs = vzalloc(sizeof(*vs)); if (!vs) -- 2.17.1 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next reply other threads:[~2021-01-21 5:08 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-01-21 5:03 Dongli Zhang [this message] 2021-01-21 5:03 ` [PATCH 1/1] vhost scsi: allocate vhost_scsi with GFP_NOWAIT to avoid delay Dongli Zhang 2021-01-21 9:00 ` Jason Wang 2021-01-21 9:00 ` Jason Wang 2021-01-23 8:01 ` Dongli Zhang 2021-01-23 8:01 ` Dongli Zhang
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210121050328.7891-1-dongli.zhang@oracle.com \ --to=dongli.zhang@oracle.com \ --cc=aruna.ramakrishna@oracle.com \ --cc=jasowang@redhat.com \ --cc=joe.jin@oracle.com \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mst@redhat.com \ --cc=netdev@vger.kernel.org \ --cc=pbonzini@redhat.com \ --cc=stefanha@redhat.com \ --cc=virtualization@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.