grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] net/tcp: Only call grub_get_time_ms when there are sockets t


From: Glenn Washburn
Subject: [PATCH 3/3] net/tcp: Only call grub_get_time_ms when there are sockets to potentially retransmit for
Date: Fri, 18 Mar 2022 01:51:33 -0500

If the machine has network cards found, but there are no tcp open sockets
(because the user doesn't use the network to boot), then
grub_net_tcp_retransmit() should be a noop. Thus GRUB doesn't need to call
grub_get_time_ms(), which does a call into firmware on powerpc-ieee1275,
and probably other targets. So only call grub_get_time_ms() if there are tcp
sockets.

Aside from improving performace, its also useful to stay out of the firmware
as much as possible when debugging via QEMU because its a pain to get back
in to GRUB execution. grub_net_tcp_retransmit() can get called very
frequently via grub_net_poll_cards_idle() when GRUB is waiting for a
keypress (grub_getkey_noblock() calls grub_net_poll_cards_idle()). This can
be annoying when debugging an issue in GRUB on powerpc in QEMU with GDB when
GRUB is waiting for a keypress because interrupting via GDB nearly always
lands in the OpenBIOS firmware's milliseconds call.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/net/tcp.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c
index 2004601212..48930fdfef 100644
--- a/grub-core/net/tcp.c
+++ b/grub-core/net/tcp.c
@@ -362,8 +362,13 @@ void
 grub_net_tcp_retransmit (void)
 {
   grub_net_tcp_socket_t sock;
-  grub_uint64_t ctime = grub_get_time_ms ();
-  grub_uint64_t limit_time = ctime - TCP_RETRANSMISSION_TIMEOUT;
+  grub_uint64_t ctime = 0, limit_time = 0;
+
+  if (tcp_sockets == NULL)
+    {
+      ctime = grub_get_time_ms ();
+      limit_time = ctime - TCP_RETRANSMISSION_TIMEOUT;
+    }
 
   FOR_TCP_SOCKETS (sock)
   {
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]