Potential memory reordering problem in JfrBuffer flush mechanism

XMLWordPrintable

    • jfr
    • b26

      There is a moment that a thread A writes event data to its thread-local Jfrbuffer, and other thread B flushes the content of the JfrBuffer to file concurrently.

      The pos of the JfrBuffer will be updated by the thread A after an event is written done(jfrStorageAdapter.hpp commit),

      the thread B will flush the content between the top and pos of the JfrBuffer(jfrStorage.cpp ThreadLocalConcurrentWriteOperation).

      The question is how to ensure that the content flushed by the thread B is correct.

      There is no release store when the thread A updates the value of pos and no load-acquire when the flush thread read the value of pos.

      So it is possible that the thread B reads the new value of pos, but can't read the correct value between the top and pos of the JfrBuffer on hardware having weaker memory models.

            Assignee:
            Markus Grönlund
            Reporter:
            Denghui Dong
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: