Re: [PATCH] generalized spin_lock_bit

From: Linus Torvalds (torvalds@transmeta.com)
Date: Sat Jul 20 2002 - 18:25:21 EST


On 20 Jul 2002, Robert Love wrote:
>
> My assumption was similar - that the bit locking may be inefficient on
> other architectures - so I put the spin_lock_bit code in per-arch
> headers.

Well, but you also passed it an unsigned long, and the bit number.

Which at least to me implies that they have to set that bit.

Which is totally unnecessary, if they _instead_ decide to set something
else altogether.

For example, the implementation on pte_chain_lock(page) might be something
like this instead:

        static void pte_chain_lock(struct page *page)
        {
                unsigned long hash = hash(page) & PTE_CHAIN_MASK;
                spin_lock(pte_chain[hash]);
        }

        static void pte_chain_unlock(struct page *page)
        {
                unsigned long hash = hash(page) & PTE_CHAIN_MASK;
                spin_unlock(pte_chain[hash]);
        }

> In other words, I assumed we may need to make some changes but to
> bit-locking in general and not rip out the whole design.

bit-locking in general doesn't work. Some architectures can sanely only
lock a byte (or even just a word).

                Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 23 2002 - 22:00:34 EST