Re: [PATCH 1/2] hung_task: Show the blocker task if the task is hung on mutex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2/19/25 9:27 PM, Steven Rostedt wrote:
On Wed, 19 Feb 2025 21:15:08 -0500
Waiman Long <llong@xxxxxxxxxx> wrote:

Writer - setting them:

      WRITE_ONCE(lock)
      smp_wmb()
      WRITE_ONCE(type)

Clearing them:

      WRITE_ONCE(type, 0)
      smp_wmb()
      WRITE_ONCE(lock, NULL)

Reader:

      READ_ONCE(type)
again:
      smp_rmb()
      READ_ONCE(lock)
      smp_rmb()
      if (READ_ONCE(type) != type)
          goto again
Do you really need the READ/WRITE_ONCE() with the memory barriers? From
what I understand, the compiler can't even assume what it read is the same
after passing a memory barrier like that. So there should be no reason it
can reread the memory location after a barrier.

You may be right. However, without using a READ_ONCE/WRITE_ONLY, a compiler can potentially break up the read/write into multiple smaller trunks resulting in partial data. So I will use them to be on the safe side. In this particular scenario above, we may not need to use them on type as we are going to reread it. I will keep them for lock though.

Cheers,
Longman


-- Steve






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux