Thread (30 messages) 30 messages, 5 authors, 2017-12-11

Re: [PATCHv2 net-next 04/12] sctp: implement make_datafrag for sctp_stream_interleave

flat view

From: 'Marcelo Ricardo Leitner' <marcelo.leitner@gmail.com>
Date: 2017-12-08 20:37:48
Also in: linux-sctp

On Fri, Dec 08, 2017 at 11:08:56AM -0500, Neil Horman wrote:
On Fri, Dec 08, 2017 at 04:04:58PM +0000, David Laight wrote:
quoted
From: Marcelo Ricardo Leitner
quoted
Sent: 08 December 2017 16:00
...
quoted
quoted
Is it worth replacing the si struct with an index/enum value, and indexing an
array of method pointer structs?  That would save you at least one dereference.
Hmmm, maybe, yes. It would be like
sctp_stream_interleave[asoc->stream.si].make_datafrag(...)
If you only expect 2 choices then an if () is likely
to produce better code that the above.

The actual implementation can be hidden inside a #define
or static inline function.
Thats the real question though, will we expect more than two interleaving
strategies?  Currently its a boolean operation so the answer seems like yes, but
is there a possiblity of a biased interleaving, or other worthwhile algorithm?
For the chunk format, I don't think so. It would require another RFC
update.
For other possibilities on having a 3rd choice in there, I also don't
think so. Stream scheduling is handled apart from it and rx buffer
stuff is being covered by it now, don't see how we could have a 3rd
option without another chunk format.

But that said, I don't think the macro or even inline wrappers are as
clear as the struct with function pointers here and in some cases it
even won't avoid the second deref. I wouldn't like to compromise code
readability and OO because of 1 fetch, specially considering that this
will be barely noticeable.

Neil's idea on using the array of structs and indexing on it is nice.
Saves a deref and keeps the abstractions without inserting too much
noise on it. Plus, it also allows replacing the struct pointer in
sctp_stream with a bit. If then placed before the union in there, we
can save up to the whole pointer. Looks like a good compromise to me.

  Marcelo
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help