Marcelo Ricardo Leitner 182691d099 sctp: improve how SSN, TSN and ASCONF serial are compared
Make it similar to time_before() macros:
- easier to understand
- make use of typecheck() to avoid working on unexpected variable types
  (made the issue on previous patch visible)
- for _[lg]te versions, slighly faster, as the compiler used to generate
  a sequence of cmp/je/cmp/js instructions and now it's sub/test/jle
  (for _lte):

Before, for sctp_outq_sack:
	if (primary->cacc.changeover_active) {
    1f01:	80 b9 84 02 00 00 00 	cmpb   $0x0,0x284(%rcx)
    1f08:	74 6e                	je     1f78 <sctp_outq_sack+0xe8>
		u8 clear_cycling = 0;

		if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
    1f0a:	8b 81 80 02 00 00    	mov    0x280(%rcx),%eax
	return ((s) - (t)) & TSN_SIGN_BIT;
}

static inline int TSN_lte(__u32 s, __u32 t)
{
	return ((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT);
    1f10:	8b 7d bc             	mov    -0x44(%rbp),%edi
    1f13:	39 c7                	cmp    %eax,%edi
    1f15:	74 25                	je     1f3c <sctp_outq_sack+0xac>
    1f17:	39 f8                	cmp    %edi,%eax
    1f19:	78 21                	js     1f3c <sctp_outq_sack+0xac>
			primary->cacc.changeover_active = 0;

After:
	if (primary->cacc.changeover_active) {
    1ee7:	80 b9 84 02 00 00 00 	cmpb   $0x0,0x284(%rcx)
    1eee:	74 73                	je     1f63 <sctp_outq_sack+0xf3>
		u8 clear_cycling = 0;

		if (TSN_lte(primary->cacc.next_tsn_at_change, sack_ctsn)) {
    1ef0:	8b 81 80 02 00 00    	mov    0x280(%rcx),%eax
    1ef6:	2b 45 b4             	sub    -0x4c(%rbp),%eax
    1ef9:	85 c0                	test   %eax,%eax
    1efb:	7e 26                	jle    1f23 <sctp_outq_sack+0xb3>
			primary->cacc.changeover_active = 0;

*_lt() generated pretty much the same code.
Tested with gcc (GCC) 6.1.1 20160621.

This patch also removes SSN_lte as it is not used and cleanups some
comments.

Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-09-23 06:54:58 -04:00
..
2016-06-15 20:41:23 -07:00
2014-09-18 10:54:36 +02:00
2015-03-04 00:23:23 -05:00
2015-06-28 16:55:44 -07:00
2015-11-18 16:17:38 -05:00
2016-06-27 15:06:17 -04:00
2016-07-08 12:20:57 +02:00
2016-04-25 16:44:27 -04:00
2016-04-25 16:44:27 -04:00
2016-06-09 23:41:03 -07:00
2015-03-06 21:50:02 -05:00
2016-08-26 11:55:18 -07:00
2015-09-17 17:18:37 -07:00
2016-02-16 20:21:48 -05:00
2016-06-08 11:36:02 -07:00
2016-05-20 18:03:16 -04:00
2016-04-28 17:03:38 -04:00
2016-04-25 16:45:53 -04:00
2016-04-27 22:48:25 -04:00
2016-05-20 18:03:17 -04:00
2016-08-17 19:36:23 -04:00
2014-01-03 20:56:48 -05:00
2016-08-30 22:27:18 -07:00
2015-10-23 06:26:42 -07:00
2016-06-15 20:41:23 -07:00
2016-05-16 13:46:23 -04:00
2016-07-08 12:20:57 +02:00
2016-03-23 22:09:58 -04:00
2016-04-07 16:53:30 -04:00
2016-09-10 23:12:53 -07:00
2014-06-02 11:00:41 -07:00
2015-03-12 22:58:12 -04:00
2016-05-03 16:08:14 -04:00
2015-10-26 22:24:22 -07:00