public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC -mm] more cpu_relax() places?
@ 2006-06-12 18:37 Andreas Mohr
  2006-06-13 19:53 ` [PATCH -mm] i386: cpu_relax() smp.c (was: [RFC -mm] more cpu_relax() places?) Andreas Mohr
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Andreas Mohr @ 2006-06-12 18:37 UTC (permalink / raw)
  To: linux-kernel

Hi all,

while reviewing 2.6.17-rc6-mm1, I found some places that might
want to make use of cpu_relax() in order to not block secondary
pipelines while busy-polling (probably especially useful on SMT CPUs):

arch/i386/kernel/smp.c/flush_tlb_others():

        while (!cpus_empty(flush_cpumask))
                /* nothing. lockup detection does not belong here */
                mb();

should probably be made

        while (!cpus_empty(flush_cpumask)) {
		cpu_relax();
                /* nothing. lockup detection does not belong here */
                mb();
	}

(to have memory barrier directly before flush_cpumask is read).


Second,
include/asm-i386/apic.h/apic_wait_icr_idle() does use cpu_relax(),
but the version in asm-x86_64/ NOT!
Is this because there's not much use doing cpu_relax() on SMP non-SMT
machines, and x86_64 are always non-SMT? Or rather because someone
screwed up?


And what about include/asm-i386/acpi.h/__acpi_acquire/release_global_lock()?

static inline int
__acpi_acquire_global_lock (unsigned int *lock)
{
        unsigned int old, new, val;
        do {
                old = *lock;
                new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
                val = cmpxchg(lock, old, new);
        } while (unlikely (val != old));
        return (new < 3) ? -1 : 0;
}

could probably be made

static inline int
__acpi_acquire_global_lock (unsigned int *lock)
{
        unsigned int old, new, val;
        while (1) {
                old = *lock;
                new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
                val = cmpxchg(lock, old, new);
		if (likely(val == old))
			break;
		cpu_relax();
        }
        return (new < 3) ? -1 : 0;
}

Andreas Mohr

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-06-14 20:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-12 18:37 [RFC -mm] more cpu_relax() places? Andreas Mohr
2006-06-13 19:53 ` [PATCH -mm] i386: cpu_relax() smp.c (was: [RFC -mm] more cpu_relax() places?) Andreas Mohr
2006-06-14  2:10   ` [PATCH -mm] i386: cpu_relax() smp.c Nick Piggin
2006-06-14 19:32     ` Andreas Mohr
2006-06-13 19:54 ` [PATCH -mm] ACPI lock: cpu_relax() (was: [RFC -mm] more cpu_relax() places?) Andreas Mohr
2006-06-14 19:29   ` Andreas Mohr
2006-06-13 19:54 ` [PATCH -mm] x86_64 apic.h " Andreas Mohr
2006-06-14  5:34   ` Andi Kleen
2007-06-14 20:28 ` [PATCH -mm] i386: add cpu_relax() to cmos_lock() Andreas Mohr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox