netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue
@ 2017-09-18 20:48 Arnd Bergmann
  2017-09-19 21:02 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-09-18 20:48 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: Arnd Bergmann, Eric Dumazet, Neal Cardwell, Yuchung Cheng,
	Soheil Hassas Yeganeh, Florian Westphal, netdev, linux-kernel

gcc-4.9 warns that it cannot trace the state of the 'last_ackt'
variable since the change to the TCP timestamping code, when
CONFIG_PROFILE_ANNOTATED_BRANCHES is set:

net/ipv4/tcp_input.c: In function 'tcp_clean_rtx_queue':
include/net/tcp.h:757:23: error: 'last_ackt' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Other gcc versions, both older and newer do now show this
warning. Removing the 'likely' annotation makes it go away,
and has no effect on the object code without
CONFIG_PROFILE_ANNOTATED_BRANCHES, as tested with gcc-4.9
and gcc-7.1.1, so this seems to be a safe workaround.

Fixes: 9a568de4818d ("tcp: switch TCP TS option (RFC 7323) to 1ms clock")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/ipv4/tcp_input.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index c5d7656beeee..c52bc8e35d4d 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3173,7 +3173,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
 	if (skb && (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED))
 		flag |= FLAG_SACK_RENEGING;
 
-	if (likely(first_ackt) && !(flag & FLAG_RETRANS_DATA_ACKED)) {
+	if (first_ackt && !(flag & FLAG_RETRANS_DATA_ACKED)) {
 		seq_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, first_ackt);
 		ca_rtt_us = tcp_stamp_us_delta(tp->tcp_mstamp, last_ackt);
 	}
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue
  2017-09-18 20:48 [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue Arnd Bergmann
@ 2017-09-19 21:02 ` David Miller
  2017-09-19 21:32   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2017-09-19 21:02 UTC (permalink / raw)
  To: arnd
  Cc: kuznet, yoshfuji, edumazet, ncardwell, ycheng, soheil, fw,
	netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Mon, 18 Sep 2017 22:48:47 +0200

> gcc-4.9 warns that it cannot trace the state of the 'last_ackt'
> variable since the change to the TCP timestamping code, when
> CONFIG_PROFILE_ANNOTATED_BRANCHES is set:
> 
> net/ipv4/tcp_input.c: In function 'tcp_clean_rtx_queue':
> include/net/tcp.h:757:23: error: 'last_ackt' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> Other gcc versions, both older and newer do now show this
> warning. Removing the 'likely' annotation makes it go away,
> and has no effect on the object code without
> CONFIG_PROFILE_ANNOTATED_BRANCHES, as tested with gcc-4.9
> and gcc-7.1.1, so this seems to be a safe workaround.
> 
> Fixes: 9a568de4818d ("tcp: switch TCP TS option (RFC 7323) to 1ms clock")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This reaches the limits at which I am willing to work around compiler
stuff.

What cpu did you test the object code generation upon and does that
cpu have branch prediction hints in the target you are building for?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue
  2017-09-19 21:02 ` David Miller
@ 2017-09-19 21:32   ` Arnd Bergmann
  2017-09-19 22:01     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2017-09-19 21:32 UTC (permalink / raw)
  To: David Miller
  Cc: Alexey Kuznetsov, yoshfuji, Eric Dumazet, Neal Cardwell, ycheng,
	soheil, Florian Westphal, Networking, Linux Kernel Mailing List

On Tue, Sep 19, 2017 at 11:02 PM, David Miller <davem@davemloft.net> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> Date: Mon, 18 Sep 2017 22:48:47 +0200
>
>> gcc-4.9 warns that it cannot trace the state of the 'last_ackt'
>> variable since the change to the TCP timestamping code, when
>> CONFIG_PROFILE_ANNOTATED_BRANCHES is set:
>>
>> net/ipv4/tcp_input.c: In function 'tcp_clean_rtx_queue':
>> include/net/tcp.h:757:23: error: 'last_ackt' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>
>> Other gcc versions, both older and newer do now show this
>> warning. Removing the 'likely' annotation makes it go away,
>> and has no effect on the object code without
>> CONFIG_PROFILE_ANNOTATED_BRANCHES, as tested with gcc-4.9
>> and gcc-7.1.1, so this seems to be a safe workaround.
>>
>> Fixes: 9a568de4818d ("tcp: switch TCP TS option (RFC 7323) to 1ms clock")
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> This reaches the limits at which I am willing to work around compiler
> stuff.

I see. It is a definitely a really obscure case, so if there is any doubt
that the workaround is harmless, then we shouldn't take it. The warning
only shows up on gcc-4.9 but not anything newer, and we disable
-Wmaybe-uninitialized on all older versions because of the false
positives.

It's also possible that it needed a combination of multiple other options,
not just CONFIG_PROFILE_ANNOTATED_BRANCHES. I build-tested
with gcc-4.9 to see if anything would show up that we don't also get a
warning for in gcc-7, and this came up once in several hundred randconfig
builds across multiple architectures (no other new warnings appeared
with gcc-4.9).

> What cpu did you test the object code generation upon and does that
> cpu have branch prediction hints in the target you are building for?

This was a randconfig build targetting ARMv5. I'm pretty sure that has
no such hint instructions.

       Arnd

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue
  2017-09-19 21:32   ` Arnd Bergmann
@ 2017-09-19 22:01     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-09-19 22:01 UTC (permalink / raw)
  To: arnd
  Cc: kuznet, yoshfuji, edumazet, ncardwell, ycheng, soheil, fw,
	netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 19 Sep 2017 23:32:33 +0200

> On Tue, Sep 19, 2017 at 11:02 PM, David Miller <davem@davemloft.net> wrote:
>> What cpu did you test the object code generation upon and does that
>> cpu have branch prediction hints in the target you are building for?
> 
> This was a randconfig build targetting ARMv5. I'm pretty sure that has
> no such hint instructions.

I just tested on sparc64 and it changed the branch prediction:

 .L2157:
-       brz,pn  %i3, .L1898     ! first_ackt,
+       brz,pt  %i2, .L1898     ! first_ackt,
         mov    -1, %o2 !, seq_rtt_us

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-19 22:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-18 20:48 [PATCH] tcp: avoid bogus warning in tcp_clean_rtx_queue Arnd Bergmann
2017-09-19 21:02 ` David Miller
2017-09-19 21:32   ` Arnd Bergmann
2017-09-19 22:01     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).