Re: Non-reproducible AIO failure

From: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Non-reproducible AIO failure
Date: 2025-06-06 11:03:12
Message-ID: c680c157-d848-4932-a383-6fa5e0ae0e17@garret.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There is really essential difference in code generated by clang 15
(working) and 16 (not working).

```

pgaio_io_stage(PgAioHandle *ioh, PgAioOp op)

{

     ...

     HOLD_INTERRUPTS();

    ioh->op = op;
    ioh->result = 0;

    pgaio_io_update_state(ioh, PGAIO_HS_DEFINED);
    ...

}

```

clang15:

```

postgres[0x10035d4ac] <+84>:  add    x22, x22, #0x5d4          ;
InterruptHoldoffCount
postgres[0x10035d4b0] <+88>:  ldr    w8, [x22]
postgres[0x10035d4b4] <+92>:  add    w8, w8, #0x1
postgres[0x10035d4b8] <+96>:  str    w8, [x22]
*postgres[0x10035d4bc] <+100>: strb   w20, [x19, #0x2]
*postgres[0x10035d4c0] <+104>: str    wzr, [x19, #0x14]
postgres[0x10035d4c4] <+108>: mov    x0, x19
postgres[0x10035d4c8] <+112>: mov    w1, #0x2
postgres[0x10035d4cc] <+116>: bl 0x10035cbdc               ;
pgaio_io_update_state at aio.c:384
```

clang16:

```

postgres[0x100699e8c] <+200>: add    x9, x9, #0xd74 ; InterruptHoldoffCount
postgres[0x100699e90] <+204>: ldr    w8, [x9]
postgres[0x100699e94] <+208>: mov    w10, #0x1 ; =1
postgres[0x100699e98] <+212>: stur   w10, [x29, #-0x18]
postgres[0x100699e9c] <+216>: add    w8, w8, #0x1
postgres[0x100699ea0] <+220>: str    w8, [x9]
postgres[0x100699ea4] <+224>: ldur   w10, [x29, #-0xc]
postgres[0x100699ea8] <+228>: ldur   x9, [x29, #-0x8]
postgres[0x100699eac] <+232>: ldrh   w8, [x9]
postgres[0x100699eb0] <+236>: and    w10, w10, #0xff
postgres[0x100699eb4] <+240>: orr    w10, w8, w10, lsl #16
postgres[0x100699eb8] <+244>: lsr    w8, w10, #16
*postgres[0x100699ebc] <+248>: strh   w10, [x9]
postgres[0x100699ec0] <+252>: strb   w8, [x9, #0x2]
*postgres[0x100699ec4] <+256>: ldur   x8, [x29, #-0x8]
postgres[0x100699ec8] <+260>: str    wzr, [x8, #0x14]
postgres[0x100699ecc] <+264>: ldur   x0, [x29, #-0x8]
postgres[0x100699ed0] <+268>: mov    w1, #0x2 ; =2
postgres[0x100699ed4] <+272>: bl     0x100698efc    ;
pgaio_io_update_state at aio.c:384
```

As you can see pg16 just updates third byte of the structure (`op`
field). It is not affecting 'state' field at all.

While clang16 is also updating `state` field! And looks like it is moved
before memory barrier (in `pgaio_io_update_state` function),

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2025-06-06 11:22:43 Re: Missing program_XXX calling in pgbench tests
Previous Message Fujii Masao 2025-06-06 10:31:25 Re: CHECKPOINT unlogged data