On Thu, Sep 26, 2019 at 6:30 PM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > And once you have that cookie, and you see "ok, I didn't get the > answer immediately" only THEN do you start filling in things like > callback stuff, or maybe you set up a wait-queue and start waiting for > it, or whatever". Side note: almost nobody does this. Almost every single async interface I've ever seen ends up being "only designed for async". And I think the reason is that everybody first does the simply synchronous interfaces, and people start using those, and a lot of people are perfectly happy with them. They are simple, and they work fine for the huge majority of users. And then somebody comes along and says "no, _we_ need to do this asynchronously", and by definition that person does *not* care for the synchronous case, since that interface already existed and was simpler and already was mostly sufficient for the people who used it, and so the async interface ends up being _only_ designed for the new async workflow. Because that whole new world was written with just that case is mind, and the synchronous case clearly didn't matter. So then you end up with that kind of dichotomous situation, where you have a strict black-and-white either-synchronous-or-async model. And then some people - quite reasonably - just want the simplicity of the synchronous code and it performs better for them because the interfaces are simpler and better suited to their lack of extra work. And other people feel they need the async code, because they can take advantage of it. And never the twain shall meet, because the async interface is actively _bad_ for the people who have sync workloads and the sync interface doesn't work for the async people. Non-crypto example: [p]read() vs aio_read(). They do the same thing (on a high level) apart from that sync/async issue. And there's no way to get the best of both worlds. Doing aio_read() on something that is already cached is actively much worse than just doing a synchronous read() of cached data. But aio_read() _can_ be much better if you know your workload doesn't cache well and read() blocks too much for you. There's no "read_potentially_async()" interface that just does the synchronous read for any cached portion of the data, and then delays just the IO parts and returns a "here, I gave you X bytes right now, use this cookie to wait for the rest". Maybe nobody would use it. But it really should be possibly to have interfaces where a good synchronous implementation is _possible_ without the extra overhead, while also allowing async implementations. Linus