Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nV6T2-0005Ra-Va for mharc-grub-devel@gnu.org; Fri, 18 Mar 2022 02:52:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nV6T1-0005NP-Cv for grub-devel@gnu.org; Fri, 18 Mar 2022 02:52:07 -0400 Received: from [2607:f8b0:4864:20::72c] (port=42807 helo=mail-qk1-x72c.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nV6Sz-0006C6-Ba for grub-devel@gnu.org; Fri, 18 Mar 2022 02:52:07 -0400 Received: by mail-qk1-x72c.google.com with SMTP id 85so6135872qkm.9 for ; Thu, 17 Mar 2022 23:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficientek-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9IkondipmuVHmTTBpnAhR5F3MBLcvtprTxI/quRq3t0=; b=U8wNHlJBhneBt+aNwTcBaNNg2fPKM/TCf4m2Dw9wN61pcGSiLKms3a9S0tVNtCIVYa bH/2Rcn7jRqTT41zxZCBTQy8hRfsZqJqZ2zeUuv1TnvVGiIiQ9qd2tOZ+pI0ki3ENtUR dIYkm2FDuvyu6etLYL49sm6HfQLTYYkW0G2Ax2SSaDVHPWwfrVlt68LZzEH7IsnKmKIR BY3O4WJ+myxxH4UkLl8sQRGKsFK9AizbKFEFtNCn+nVhVaYF9litVPxM1m/wGIFRxVCN J1E9oxH+VJ+CZZI6FAapYwZQ3hDMVZYIa8CbiLWGD5yGYcFUf+/dHVjhSFYwkbvoTw2D hIkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9IkondipmuVHmTTBpnAhR5F3MBLcvtprTxI/quRq3t0=; b=8SOY/uRu1NyVjvJK2OmOUgZBDPMsOKIeq2RN4nh9VjvRcob3WwWddaq3QucbuHwEEx IgFqUycX6Kkxuh9ahd2jbMyyxLM9Z55FY+8CnbfQotrcW5G6nSDpYdMR5SvDk9bjtcHk oZOaZGSwR7H7yo25+wdIr6WeT/gMU5zjgylTcj8YO/LKFFkPqDLMSpkQiBMHCb84NMli xN/wncCVsKr9hr61Qom2UCnx2m978MfwNwG8Hj6L4SXqYtH4HZfKXoqZS8wDZSlvYrXt ZA4rehbpT6B//Qt/LXFhRXZjaReV2XHlyB1yIM6GSde7geAw7JPd9ggPN9Ze6YY56eFa RY2w== X-Gm-Message-State: AOAM533nNPXKjXid1ZwtppVl7WPdDilKkTfA1scFoiK/lop+vYVR12JM NdVDdmm/QC4Xu2GnZpfxVXVm7/gO6PkQXA== X-Google-Smtp-Source: ABdhPJyM33uH/Y1gz0PtZEo3SR61ADMOr9x5S+gZ67ILYyy25N6/9/HrKlkYDdI7yk5Igfx7yFttdA== X-Received: by 2002:a05:620a:1929:b0:67d:74f0:a957 with SMTP id bj41-20020a05620a192900b0067d74f0a957mr5023702qkb.743.1647586324407; Thu, 17 Mar 2022 23:52:04 -0700 (PDT) Received: from localhost.localdomain (51-15-0-88.rev.poneytelecom.eu. [51.15.0.88]) by smtp.gmail.com with ESMTPSA id o6-20020a05620a22c600b0067d247816eesm3471324qki.85.2022.03.17.23.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 23:52:04 -0700 (PDT) From: Glenn Washburn To: Daniel Kiper , grub-devel@gnu.org Cc: 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 Message-Id: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::72c (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::72c; envelope-from=development@efficientek.com; helo=mail-qk1-x72c.google.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2022 06:52:07 -0000 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 --- 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