From owner-svn-src-user@FreeBSD.ORG Mon May 9 07:06:35 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7CF81065670; Mon, 9 May 2011 07:06:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CE4218FC08; Mon, 9 May 2011 07:06:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p4976YN4080558; Mon, 9 May 2011 07:06:34 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p4976Ypv080553; Mon, 9 May 2011 07:06:34 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201105090706.p4976Ypv080553@svn.freebsd.org> From: Andriy Gapon Date: Mon, 9 May 2011 07:06:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r221679 - in user/avg/xcpu/sys: amd64/amd64 kern sys X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 May 2011 07:06:35 -0000 Author: avg Date: Mon May 9 07:06:34 2011 New Revision: 221679 URL: http://svn.freebsd.org/changeset/base/221679 Log: simplify the way of execution of reset on BSP instead of restarting the BSP and having a special restart hook, the hook is placed in the spin loop and it is triggered simply by setting hook function to non-NULL Modified: user/avg/xcpu/sys/amd64/amd64/mp_machdep.c user/avg/xcpu/sys/amd64/amd64/vm_machdep.c user/avg/xcpu/sys/kern/subr_smp.c user/avg/xcpu/sys/sys/smp.h Modified: user/avg/xcpu/sys/amd64/amd64/mp_machdep.c ============================================================================== --- user/avg/xcpu/sys/amd64/amd64/mp_machdep.c Mon May 9 07:05:36 2011 (r221678) +++ user/avg/xcpu/sys/amd64/amd64/mp_machdep.c Mon May 9 07:06:34 2011 (r221679) @@ -1435,16 +1435,17 @@ cpustop_handler(void) atomic_set_int(&stopped_cpus, cpumask); /* Wait for restart */ - while (!(started_cpus & cpumask)) - ia32_pause(); + while ((started_cpus & cpumask) == 0) { + if (cpu == 0 && cpustop_hook != NULL) { + cpustop_hook(); + cpustop_hook = NULL; + } + ia32_pause(); + } atomic_clear_int(&started_cpus, cpumask); atomic_clear_int(&stopped_cpus, cpumask); - - if (cpu == 0 && cpustop_restartfunc != NULL) { - cpustop_restartfunc(); - cpustop_restartfunc = NULL; - } + return; } /* Modified: user/avg/xcpu/sys/amd64/amd64/vm_machdep.c ============================================================================== --- user/avg/xcpu/sys/amd64/amd64/vm_machdep.c Mon May 9 07:05:36 2011 (r221678) +++ user/avg/xcpu/sys/amd64/amd64/vm_machdep.c Mon May 9 07:06:34 2011 (r221679) @@ -541,12 +541,11 @@ cpu_reset() } if (PCPU_GET(cpuid) != 0) { cpu_reset_proxyid = PCPU_GET(cpuid); - cpustop_restartfunc = cpu_reset_proxy; cpu_reset_proxy_active = 0; printf("cpu_reset: Restarting BSP\n"); /* Restart CPU #0. */ - atomic_store_rel_int(&started_cpus, 1 << 0); + cpustop_hook = cpu_reset_proxy; cnt = 0; while (cpu_reset_proxy_active == 0 && cnt < 10000000) Modified: user/avg/xcpu/sys/kern/subr_smp.c ============================================================================== --- user/avg/xcpu/sys/kern/subr_smp.c Mon May 9 07:05:36 2011 (r221678) +++ user/avg/xcpu/sys/kern/subr_smp.c Mon May 9 07:06:34 2011 (r221679) @@ -63,7 +63,7 @@ cpumask_t idle_cpus_mask; cpumask_t hlt_cpus_mask; cpumask_t logical_cpus_mask; -void (*cpustop_restartfunc)(void); +void (* volatile cpustop_hook)(void); #endif /* This is used in modules that need to work in both SMP and UP. */ cpumask_t all_cpus; Modified: user/avg/xcpu/sys/sys/smp.h ============================================================================== --- user/avg/xcpu/sys/sys/smp.h Mon May 9 07:05:36 2011 (r221678) +++ user/avg/xcpu/sys/sys/smp.h Mon May 9 07:06:34 2011 (r221679) @@ -68,7 +68,7 @@ struct cpu_group *smp_topo_2level(int l2 int l1count, int l1flags); struct cpu_group *smp_topo_find(struct cpu_group *top, int cpu); -extern void (*cpustop_restartfunc)(void); +extern void (* volatile cpustop_hook)(void); extern int smp_active; extern int smp_cpus; extern volatile cpumask_t started_cpus;