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: > > From: Marcelo Ricardo Leitner > > > Sent: 08 December 2017 16:00 > > ... > > > > 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 -- To unsubscribe from this list: send the line "unsubscribe linux-sctp" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html