[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89iJUzrrJgriSWfbaPKZDoevBnzhshB-3YLpv8oWB+oMLug@mail.gmail.com>
Date: Tue, 8 Mar 2022 14:42:34 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: David Laight <David.Laight@...lab.com>
Cc: Jakub Kicinski <kuba@...nel.org>, netdev <netdev@...r.kernel.org>,
Willem de Bruijn <willemb@...gle.com>,
Neal Cardwell <ncardwell@...gle.com>,
Yuchung Cheng <ycheng@...gle.com>
Subject: Re: [RFC net-next] tcp: allow larger TSO to be built under overload
On Tue, Mar 8, 2022 at 2:26 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
>
> Thanks, I think I will make sure that we use the 32bit divide then,
> because compiler might not be smart enough to detect both operands are < ~0U
BTW, it seems the compiler (clang for me) is smart enough.
bytes = min_t(unsigned long, bytes, sk->sk_gso_max_size);
return max_t(u32, bytes / mss_now, min_tso_segs);
Compiler is using the divide by 32bit operation (div %ecx)
If you remove the min_t() clamping, and only keep:
return max_t(u32, bytes / mss_now, min_tso_segs);
Then clang makes a special case if bytes >= (1UL<<32)
790d: 48 89 c2 mov %rax,%rdx
7910: 48 c1 ea 20 shr $0x20,%rdx
7914: 74 07 je 791d <tcp_tso_autosize+0x4d>
7916: 31 d2 xor %edx,%edx
7918: 48 f7 f1 div %rcx
# More expensive divide
791b: eb 04 jmp 7921 <tcp_tso_autosize+0x51>
791d: 31 d2 xor %edx,%edx
791f: f7 f1 div %ecx
7921: 44 39 c0 cmp %r8d,%eax
7924: 44 0f 47 c0 cmova %eax,%r8d
7928: 44 89 c0 mov %r8d,%eax
792b: 5d pop %rbp
792c: c3 ret
Powered by blists - more mailing lists