On Mon, 18 May 2026 11:29:54 +0100 Pavel Begunkov asml.silence@gmail.com wrote:
On 5/13/26 09:19, Christoph Hellwig wrote:
- if (!bio_flagged(bio_src, BIO_DMABUF_MAP)) {
bio->bi_io_vec = bio_src->bi_io_vec;- } else {
bio->dmabuf_map = bio_src->dmabuf_map;bio_set_flag(bio, BIO_DMABUF_MAP);- }
This is backwards, please avoid pointless negations:
I can flip it, but compilers tend to prefer the true branch. E.g. this
if (cond) A; else B; C;
can get compiled into:
jmpcc cond B A: ... C: return; B: ... jmp C;
I'm pretty sure gcc completely ignores the order. Some very old compilers didn't - to the extreme of generating a short conditional branch around a long unconditional branch to get past a large 'true' code block.
likely() and unlikely() can change things, they are definitely useful comments to a human (or Human) reader.
I'm not sure you can rely on the branch predictor to do anything sensible outside of a loop.
-- David