From owner-svn-src-stable-8@FreeBSD.ORG Wed Nov 10 17:33:47 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA63A1065673; Wed, 10 Nov 2010 17:33:47 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B7B8B8FC12; Wed, 10 Nov 2010 17:33:47 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAAHXluS029825; Wed, 10 Nov 2010 17:33:47 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAAHXlqv029822; Wed, 10 Nov 2010 17:33:47 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201011101733.oAAHXlqv029822@svn.freebsd.org> From: John Baldwin Date: Wed, 10 Nov 2010 17:33:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215092 - in stable/8/sys: amd64/amd64 i386/i386 X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2010 17:33:47 -0000 Author: jhb Date: Wed Nov 10 17:33:47 2010 New Revision: 215092 URL: http://svn.freebsd.org/changeset/base/215092 Log: MFC 211117: Simplify the logic for handling ipi_selected() and ipi_cpu() in the amd64/i386 case. Modified: stable/8/sys/amd64/amd64/mp_machdep.c stable/8/sys/i386/i386/mp_machdep.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/mp_machdep.c Wed Nov 10 17:17:38 2010 (r215091) +++ stable/8/sys/amd64/amd64/mp_machdep.c Wed Nov 10 17:33:47 2010 (r215092) @@ -1081,6 +1081,30 @@ smp_targeted_tlb_shootdown(cpumask_t mas mtx_unlock_spin(&smp_ipi_mtx); } +/* + * Send an IPI to specified CPU handling the bitmap logic. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (old_pending) + return; + } + lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); +} + void smp_cache_flush(void) { @@ -1172,14 +1196,6 @@ void ipi_selected(cpumask_t cpus, u_int ipi) { int cpu; - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1193,20 +1209,7 @@ ipi_selected(cpumask_t cpus, u_int ipi) while ((cpu = ffs(cpus)) != 0) { cpu--; cpus &= ~(1 << cpu); - - KASSERT(cpu_apic_ids[cpu] != -1, - ("IPI to non-existent CPU %d", cpu)); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - continue; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); + ipi_send_cpu(cpu, ipi); } } @@ -1216,14 +1219,6 @@ ipi_selected(cpumask_t cpus, u_int ipi) void ipi_cpu(int cpu, u_int ipi) { - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1234,18 +1229,7 @@ ipi_cpu(int cpu, u_int ipi) atomic_set_int(&ipi_nmi_pending, 1 << cpu); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); - KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - return; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); + ipi_send_cpu(cpu, ipi); } /* Modified: stable/8/sys/i386/i386/mp_machdep.c ============================================================================== --- stable/8/sys/i386/i386/mp_machdep.c Wed Nov 10 17:17:38 2010 (r215091) +++ stable/8/sys/i386/i386/mp_machdep.c Wed Nov 10 17:33:47 2010 (r215092) @@ -1212,6 +1212,30 @@ smp_targeted_tlb_shootdown(cpumask_t mas mtx_unlock_spin(&smp_ipi_mtx); } +/* + * Send an IPI to specified CPU handling the bitmap logic. + */ +static void +ipi_send_cpu(int cpu, u_int ipi) +{ + u_int bitmap, old_pending, new_pending; + + KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); + + if (IPI_IS_BITMAPED(ipi)) { + bitmap = 1 << ipi; + ipi = IPI_BITMAP_VECTOR; + do { + old_pending = cpu_ipi_pending[cpu]; + new_pending = old_pending | bitmap; + } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], + old_pending, new_pending)); + if (old_pending) + return; + } + lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); +} + void smp_cache_flush(void) { @@ -1333,14 +1357,6 @@ void ipi_selected(cpumask_t cpus, u_int ipi) { int cpu; - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1354,20 +1370,7 @@ ipi_selected(cpumask_t cpus, u_int ipi) while ((cpu = ffs(cpus)) != 0) { cpu--; cpus &= ~(1 << cpu); - - KASSERT(cpu_apic_ids[cpu] != -1, - ("IPI to non-existent CPU %d", cpu)); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - continue; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); + ipi_send_cpu(cpu, ipi); } } @@ -1377,14 +1380,6 @@ ipi_selected(cpumask_t cpus, u_int ipi) void ipi_cpu(int cpu, u_int ipi) { - u_int bitmap = 0; - u_int old_pending; - u_int new_pending; - - if (IPI_IS_BITMAPED(ipi)) { - bitmap = 1 << ipi; - ipi = IPI_BITMAP_VECTOR; - } /* * IPI_STOP_HARD maps to a NMI and the trap handler needs a bit @@ -1395,18 +1390,7 @@ ipi_cpu(int cpu, u_int ipi) atomic_set_int(&ipi_nmi_pending, 1 << cpu); CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi); - KASSERT(cpu_apic_ids[cpu] != -1, ("IPI to non-existent CPU %d", cpu)); - - if (bitmap) { - do { - old_pending = cpu_ipi_pending[cpu]; - new_pending = old_pending | bitmap; - } while (!atomic_cmpset_int(&cpu_ipi_pending[cpu], - old_pending, new_pending)); - if (old_pending) - return; - } - lapic_ipi_vectored(ipi, cpu_apic_ids[cpu]); + ipi_send_cpu(cpu, ipi); } /*