Commit fa634baf authored by Jon Grimm's avatar Jon Grimm

[SCTP] Optimize SACK generation.

Wanted to try out profiling, so brought up oprofile.  Very 
suprising result of sctp_tsnmap_find_gap_ack() being one of the
hot functions.  This should not be!  Short-circuit by not even 
calling if !has_gap.
parent 34364495
...@@ -599,11 +599,13 @@ sctp_chunk_t *sctp_make_sack(const sctp_association_t *asoc) ...@@ -599,11 +599,13 @@ sctp_chunk_t *sctp_make_sack(const sctp_association_t *asoc)
SCTP_DEBUG_PRINTK("sackCTSNAck sent is 0x%x.\n", ctsn); SCTP_DEBUG_PRINTK("sackCTSNAck sent is 0x%x.\n", ctsn);
/* Count the number of Gap Ack Blocks. */ /* Count the number of Gap Ack Blocks. */
sctp_tsnmap_iter_init(map, &iter); num_gabs = 0;
for (num_gabs = 0;
sctp_tsnmap_next_gap_ack(map, &iter, &gab.start, &gab.end); if (sctp_tsnmap_has_gap(map)) {
num_gabs++) { sctp_tsnmap_iter_init(map, &iter);
/* Do nothing. */ while (sctp_tsnmap_next_gap_ack(map, &iter,
&gab.start, &gab.end))
num_gabs++;
} }
num_dup_tsns = sctp_tsnmap_num_dups(map); num_dup_tsns = sctp_tsnmap_num_dups(map);
...@@ -659,11 +661,15 @@ sctp_chunk_t *sctp_make_sack(const sctp_association_t *asoc) ...@@ -659,11 +661,15 @@ sctp_chunk_t *sctp_make_sack(const sctp_association_t *asoc)
sctp_addto_chunk(retval, sizeof(sack), &sack); sctp_addto_chunk(retval, sizeof(sack), &sack);
/* Put the Gap Ack Blocks into the chunk. */ /* Put the Gap Ack Blocks into the chunk. */
sctp_tsnmap_iter_init(map, &iter); if (num_gabs) {
while(sctp_tsnmap_next_gap_ack(map, &iter, &gab.start, &gab.end)) { sctp_tsnmap_iter_init(map, &iter);
gab.start = htons(gab.start); while(sctp_tsnmap_next_gap_ack(map, &iter,
gab.end = htons(gab.end); &gab.start, &gab.end)) {
sctp_addto_chunk(retval, sizeof(sctp_gap_ack_block_t), &gab); gab.start = htons(gab.start);
gab.end = htons(gab.end);
sctp_addto_chunk(retval, sizeof(sctp_gap_ack_block_t),
&gab);
}
} }
/* Register the duplicates. */ /* Register the duplicates. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment