linux-mips
[Top] [All Lists]

.subsection madness

To: linux-mips <linux-mips@linux-mips.org>
Subject: .subsection madness
From: David Daney <ddaney@caviumnetworks.com>
Date: Fri, 14 Aug 2009 11:24:19 -0700
Cc: Adam Nemet <anemet@caviumnetworks.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.21 (X11/20090320)

In atomic.h for atomic_add we have this gem:

        __asm__ __volatile__(
        "  .set    mips3                                   \n"
        "1:        ll      %0, %1          # atomic_add            \n"
        "  addu    %0, %2                                  \n"
        "  sc      %0, %1                                  \n"
        "  beqz    %0, 2f                                  \n"
        "  .subsection 2                                   \n"
        "2:        b       1b                                      \n"
        "  .previous                                       \n"
        "  .set    mips0                                   \n"


What is the purpose of the .subsection here?

It will not affect branch prediction in the beqz as nothing happens in .subsection 2.

For spin locks it is clear that this technique can help, but for atomic_add I don't think so. To make matters worse for some code the subsection is going out of branch range.

David Daney


<Prev in Thread] Current Thread [Next in Thread>