Skip to content

Commit 637784a

Browse files
marceloleitnerdavem330
authored andcommitted
sctp: introduce priority based stream scheduler
This patch introduces RFC Draft ndata section 3.4 Priority Based Scheduler (SCTP_SS_PRIO). It works by having a struct sctp_stream_priority for each priority configured. This struct is then enlisted on a queue ordered per priority if, and only if, there is a stream with data queued, so that dequeueing is very straightforward: either finish current datamsg or simply dequeue from the highest priority queued, which is the next stream pointed, and that's it. If there are multiple streams assigned with the same priority and with data queued, it will do round robin amongst them while respecting datamsgs boundaries (when not using idata chunks), to be reasonably fair. We intentionally don't maintain a list of priorities nor a list of all streams with the same priority to save memory. The first would mean at least 2 other pointers per priority (which, for 1000 priorities, that can mean 16kB) and the second would also mean 2 other pointers but per stream. As SCTP supports up to 65535 streams on a given asoc, that's 1MB. This impacts when giving a priority to some stream, as we have to find out if the new priority is already being used and if we can free the old one, and also when tearing down. The new fields in struct sctp_stream_out_ext and sctp_stream are added under a union because that memory is to be shared with other schedulers. See-also: https://tools.ietf.org/html/draft-ietf-tsvwg-sctp-ndata-13 Tested-by: Xin Long <[email protected]> Signed-off-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0ccdf3c commit 637784a

File tree

5 files changed

+377
-2
lines changed

5 files changed

+377
-2
lines changed

include/net/sctp/structs.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,10 +1328,27 @@ struct sctp_inithdr_host {
13281328
__u32 initial_tsn;
13291329
};
13301330

1331+
struct sctp_stream_priorities {
1332+
/* List of priorities scheduled */
1333+
struct list_head prio_sched;
1334+
/* List of streams scheduled */
1335+
struct list_head active;
1336+
/* The next stream stream in line */
1337+
struct sctp_stream_out_ext *next;
1338+
__u16 prio;
1339+
};
1340+
13311341
struct sctp_stream_out_ext {
13321342
__u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1];
13331343
__u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1];
13341344
struct list_head outq; /* chunks enqueued by this stream */
1345+
union {
1346+
struct {
1347+
/* Scheduled streams list */
1348+
struct list_head prio_list;
1349+
struct sctp_stream_priorities *prio_head;
1350+
};
1351+
};
13351352
};
13361353

13371354
struct sctp_stream_out {
@@ -1351,6 +1368,13 @@ struct sctp_stream {
13511368
__u16 incnt;
13521369
/* Current stream being sent, if any */
13531370
struct sctp_stream_out *out_curr;
1371+
union {
1372+
/* Fields used by priority scheduler */
1373+
struct {
1374+
/* List of priorities scheduled */
1375+
struct list_head prio_list;
1376+
};
1377+
};
13541378
};
13551379

13561380
#define SCTP_STREAM_CLOSED 0x00

include/uapi/linux/sctp.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,8 @@ struct sctp_add_streams {
10991099
/* SCTP Stream schedulers */
11001100
enum sctp_sched_type {
11011101
SCTP_SS_FCFS,
1102-
SCTP_SS_MAX = SCTP_SS_FCFS
1102+
SCTP_SS_PRIO,
1103+
SCTP_SS_MAX = SCTP_SS_PRIO
11031104
};
11041105

11051106
#endif /* _UAPI_SCTP_H */

net/sctp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sctp-y := sm_statetable.o sm_statefuns.o sm_sideeffect.o \
1212
inqueue.o outqueue.o ulpqueue.o \
1313
tsnmap.o bind_addr.o socket.o primitive.o \
1414
output.o input.o debug.o stream.o auth.o \
15-
offload.o stream_sched.o
15+
offload.o stream_sched.o stream_sched_prio.o
1616

1717
sctp_probe-y := probe.o
1818

net/sctp/stream_sched.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ static struct sctp_sched_ops sctp_sched_fcfs = {
121121

122122
/* API to other parts of the stack */
123123

124+
extern struct sctp_sched_ops sctp_sched_prio;
125+
124126
struct sctp_sched_ops *sctp_sched_ops[] = {
125127
&sctp_sched_fcfs,
128+
&sctp_sched_prio,
126129
};
127130

128131
int sctp_sched_set_sched(struct sctp_association *asoc,

0 commit comments

Comments
 (0)