multifd: Set a higher "backlog" default value for listen()
PATCH 1/1 multifd: Set a higher "backlog" default value for listen()
When destination VM is launched, the "backlog" parameter for listen() is set to 1 as default in socket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.
--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
migration/socket.c +1 -1
@@ -179,7 +179,7 @@ socket_start_incoming_migration_internal(SocketAddress *saddr,QIONetListener *listener =qio_net_listener_new ();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;qio_net_listener_set_name (listener,"migration-socket-listener" );
Signature · 1 line
2.39.1
Quoted 18 lines · On Thursday, May 18, 2023 4:52 PM, Wang, Lei4 wrote:
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c index renamed from migration/socket.c +0
-0
1b6f5baefb..b43a66ef7e100644
migration/socket.c line 184
Quoted 7 lines
migration/socket.c +1
-1@@ -179,7 +179,7 @@socket_start_incoming_migration_internal (SocketAddress *saddr, QIONetListener *listener = qio_net_listener_new();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;
Probably we need a macro for it, e.g.
#define MIGRATION_CHANNEL_MAX 512
Also, I think below lines could be removed, as using a larger value of num (i.e. 512) doesn't seem to consume more resources anywhere:
- if (migrate_use_multifd()) {
- num = migrate_multifd_channels();
- } else if (migrate_postcopy_preempt()) {
- num = RAM_CHANNEL_MAX;
- }
Quoted 30 lines · Wei W
Quoted 18 lines · On Thursday, May 18, 2023 4:52 PM, Wang, Lei4 wrote:
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c index renamed from migration/socket.c +0
-0
1b6f5baefb..b43a66ef7e100644migration/socket.c line 184
Quoted 7 lines
migration/socket.c +1
-1@@ -179,7 +179,7 @@socket_start_incoming_migration_internal (SocketAddress *saddr, QIONetListener *listener = qio_net_listener_new();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;Probably we need a macro for it, e.g.
#defineMIGRATION_CHANNEL_MAX512
Quoted 2 lines
Also, I think below lines could be removed, as using a larger value of num (i.e. 512) doesn't seem to consume more resources anywhere:
Could you confirm that?
Review
Quoted 5 lines
(quoted diff) +0
-5- if (migrate_use_multifd()) { - num = migrate_multifd_channels(); - } else if (migrate_postcopy_preempt()) { - num = RAM_CHANNEL_MAX; - }
Agreed that in this case we should drop this bit.
But on the other hand, if it does'nt consume more resources, why isn't the kernel just ignoring the value passed to listen an just use a big number?
Later, Juan.
Quoted 32 lines · Wei W
Quoted 18 lines · On Thursday, May 18, 2023 4:52 PM, Wang, Lei4 wrote:
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c index renamed from migration/socket.c +0
-0
1b6f5baefb..b43a66ef7e100644migration/socket.c line 184
Quoted 7 lines
migration/socket.c +1
-1@@ -179,7 +179,7 @@socket_start_incoming_migration_internal (SocketAddress *saddr, QIONetListener *listener = qio_net_listener_new();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;Probably we need a macro for it, e.g.
#defineMIGRATION_CHANNEL_MAX512Also, I think below lines could be removed, as using a larger value of num (i.e. 512) doesn't seem to consume more resources anywhere:
Review
Quoted 5 lines
(quoted diff) +0
-5- if (migrate_use_multifd()) { - num = migrate_multifd_channels(); - } else if (migrate_postcopy_preempt()) { - num = RAM_CHANNEL_MAX; - }
Given that this code already exists, why is it not already sufficient ?
The commit description is saying we're setting backlog == 1 wit multifd, but this later code is setting it to match the multfd channels. Why isn't that enough ?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 39 lines · Daniel P. Berrangé
Quoted 32 lines · Wei W
Quoted 18 lines · On Thursday, May 18, 2023 4:52 PM, Wang, Lei4 wrote:
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c index renamed from migration/socket.c +0
-0
1b6f5baefb..b43a66ef7e100644migration/socket.c line 184
Quoted 7 lines
migration/socket.c +1
-1@@ -179,7 +179,7 @@socket_start_incoming_migration_internal (SocketAddress *saddr, QIONetListener *listener = qio_net_listener_new();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;Probably we need a macro for it, e.g.
#defineMIGRATION_CHANNEL_MAX512Also, I think below lines could be removed, as using a larger value of num (i.e. 512) doesn't seem to consume more resources anywhere:
Review
Quoted 5 lines
(quoted diff) +0
-5- if (migrate_use_multifd()) { - num = migrate_multifd_channels(); - } else if (migrate_postcopy_preempt()) { - num = RAM_CHANNEL_MAX; - }
Quoted 1 line
Given that this code already exists, why is it not already sufficient ?
Ah, I "think" I remember now.
Quoted 3 lines
The commit description is saying we're setting backlog == 1 wit multifd, but this later code is setting it to match the multfd channels. Why isn't that enough ?
Are you using -incoming defer?
No? right.
With multifd, you should use -incoming defer. It is more, you should use -incoming defer always. The problem is that the way qemu starts, when we do the initial listen, the parameters migration_channels and migration_multifd hasn't yet been parsed.
Can you confirm that if you start with -incoming defer, everything works as expected?
Later, Juan.
Quoted 7 lines · Juan Quintela
Are you using -incoming defer?
No? right.
With multifd, you should use -incoming defer.
Yes, just confirmed that it works well with deferred incoming. I think we should enforce this kind of requirement in the code. I'll make a patch for this.
Thanks,
Wei
Quoted 5 lines · Wei W
Quoted 4 lines · Juan Quintela
Are you using -incoming defer?
Quoted 7 lines
Quoted 3 lines
No? right.
With multifd, you should use -incoming defer.
Yes, just confirmed that it works well with deferred incoming. I think we should enforce this kind of requirement in the code. I'll make a patch for this.
Actually, we should deprecate everything except defer.
Later, Juan.
Quoted 9 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>
[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is 256.
Daniel, any opinion?
Later, Juan.
Quoted 16 lines
--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c +1
-1@@ -179,7 +179,7 @@ socket_start_incoming_migration_internal(SocketAddress *saddr,QIONetListener *listener =qio_net_listener_new ();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;qio_net_listener_set_name (listener,"migration-socket-listener" );
Quoted 8 lines · Juan Quintela
Quoted 7 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.
Quoted 7 lines
Quoted 2 lines
Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is 256.
You are right, the "multifd-channels" expects uint8_t, so 256 is enough.
Quoted 22 lines
Daniel, any opinion?
Later, Juan.
Quoted 16 lines
--- migration/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)migration/socket.c +1
-1@@ -179,7 +179,7 @@ socket_start_incoming_migration_internal(SocketAddress *saddr,QIONetListener *listener =qio_net_listener_new ();MigrationIncomingState *mis =migration_incoming_get_current ();size_t i; -int num =1 ; +int num =512 ;qio_net_listener_set_name (listener,"migration-socket-listener" );
Quoted 12 lines · On Friday, May 19, 2023 9:31 AM, Wang, Lei4 wrote:
Quoted 11 lines · Juan Quintela
Quoted 9 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>
Quoted 8 lines
Quoted 4 lines
[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is
256.
You are right, the "multifd-channels" expects
uint8_t, so 256 is enough.
We can change it to uint16_t or uint32_t, but need to see if listening on a larger value is OK to everyone.
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog, and it is 4096 by default on my machine.
Quoted 17 lines · Wei W
Quoted 16 lines · On Friday, May 19, 2023 9:31 AM, Wang, Lei4 wrote:
Quoted 15 lines · Juan Quintela
Quoted 9 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is
Quoted 7 lines
Quoted 4 lines
256.
You are right, the "multifd-channels" expects
uint8_t, so 256 is enough.We can change it to
uint16_toruint32_t, but need to see if listening on a larger value is OK to everyone.
Is there any use case to use >256 migration channels? If not, then I suppose it's no need to increase it.
Quoted 4 lines
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using
/proc/sys/net/ipv4/tcp_max_syn_backlog, and it is 4096 by default on my machine
Quoted 5 lines · On Friday, May 19, 2023 10:52 AM, Wang, Lei4 wrote:
Quoted 2 lines
We can change it to
uint16_toruint32_t, but need to see if listening on a larger value is OK to everyone.Is there any use case to use >256 migration channels? If not, then I suppose it's no need to increase it.
People can choose to use more than 256 channels to boost performance.
If it is determined that using larger than 256 channels doesn't increase performance on all the existing platforms, then we need to have it reflected in the code explicitly, e.g. fail with errors messages when user does:migrate_set_parameter multifd-channels 512
Quoted 6 lines
Quoted 6 lines
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using
/proc/sys/net/ipv4/tcp_max_syn_backlog,
and it is 4096 by default on my machine
Quoted 8 lines · Wei W
Quoted 5 lines · On Friday, May 19, 2023 10:52 AM, Wang, Lei4 wrote:
Quoted 2 lines
We can change it to
uint16_toruint32_t, but need to see if listening on a larger value is OK to everyone.Is there any use case to use >256 migration channels? If not, then I suppose it's no need to increase it.
People can choose to use more than 256 channels to boost performance.
See my other email, I doubt it any time soon O:-)
Quoted 4 lines
If it is determined that using larger than 256 channels doesn't increase performance on all the existing platforms, then we need to have it reflected in the code explicitly, e.g. fail with errors messages when user does:
migrate_set_parametermultifd-channels 512
(qemu) migrate_set_parameter multifd-channels 300
Error: Parameter 'multifd-channels' expects uint8_t
So I think that is working.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using
/proc/sys/net/ipv4/tcp_max_syn_backlog,
and it is 4096 by default on my machine
Quoted 17 lines · Wei W
Quoted 16 lines · On Friday, May 19, 2023 9:31 AM, Wang, Lei4 wrote:
Quoted 15 lines · Juan Quintela
Quoted 9 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is
Quoted 7 lines
Quoted 4 lines
256.
You are right, the "multifd-channels" expects
uint8_t, so 256 is enough.We can change it to
uint16_toruint32_t, but need to see if listening on a larger value is OK to everyone.
If we need something more than 256 channels for migration, we ar edoing something really weird. We can saturate a 100Gigabit network relatively easily with 10 channels. 256 Channels would mean that we have at least 2TBit/s networking. I am not expecting that really soon. And as soon as that happens I would expect CPU's to handle easily more that 10Gigabits/second.
Quoted 3 lines
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using
/proc/sys/net/ipv4/tcp_max_syn_backlog, and it is 4096 by default on my machine.
I think that current code is ok. We just need to enforce that we use defer.
Later, Juan.
Quoted 26 lines · Juan Quintela
Quoted 17 lines · Wei W
Quoted 16 lines · On Friday, May 19, 2023 9:31 AM, Wang, Lei4 wrote:
Quoted 15 lines · Juan Quintela
Quoted 9 lines · Lei Wang
When destination VM is launched, the "backlog" parameter for
listen()is set to 1 as default insocket_start_incoming_migration_internal(), which will lead to socket connection error (the queue of pending connections is full) when "multifd" and "multifd-channels" are set later on and a high number of channels are used. Set it to a hard-coded higher default value 512 to fix this issue.Reported-by Wei Wang <[email protected]>Signed-off-by Lei Wang <[email protected]>[cc'd daiel who is the maintainer of qio]
My understanding of that value is that 230 or something like that would be more than enough. The maxiimum number of multifd channels is
Quoted 7 lines
Quoted 4 lines
256.
You are right, the "multifd-channels" expects
uint8_t, so 256 is enough.We can change it to
uint16_toruint32_t, but need to see if listening on a larger value is OK to everyone.
Quoted 6 lines
If we need something more than 256 channels for migration, we ar edoing something really weird. We can saturate a 100Gigabit network relatively easily with 10 channels. 256 Channels would mean that we have at least 2TBit/s networking. I am not expecting that really soon. And as soon as that happens I would expect CPU's to handle easily more that 10Gigabits/second.
Besides the network limitation, I'd also bet when the thread number goes to some degree it'll start to have bottleneck here and there on either scheduling or even cache bouncing between the cores even when atomically updating the counters (afaiu those need mem bus locking).
So I agree 256 would be good enough. We can wait to see when there're higher speed network..
Quoted 10 lines
Quoted 4 lines
Man page of listen mentions that the maximum length of the queue for incomplete sockets can be set using
/proc/sys/net/ipv4/tcp_max_syn_backlog, and it is 4096 by default on my machine.I think that current code is ok. We just need to enforce that we use defer.
Later, Juan.
Signature · 1 line
Peter Xu