Date: Mon, 2 Dec 2019 22:34:19 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355311 - head/sys/x86/x86 Message-ID: <201912022234.xB2MYJrQ039438@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Mon Dec 2 22:34:19 2019 New Revision: 355311 URL: https://svnweb.freebsd.org/changeset/base/355311 Log: Don't run sched_preempt() inside of an extra critical section. This disables the sched_preempt() switch optimization and causes the sched lock to be dropped and immediately reacquired. Reviewed by: jhb, kib, mav, markj (with changes) Differential Revision: https://reviews.freebsd.org/D22623 Modified: head/sys/x86/x86/mp_x86.c Modified: head/sys/x86/x86/mp_x86.c ============================================================================== --- head/sys/x86/x86/mp_x86.c Mon Dec 2 22:15:26 2019 (r355310) +++ head/sys/x86/x86/mp_x86.c Mon Dec 2 22:34:19 2019 (r355311) @@ -1261,18 +1261,11 @@ ipi_bitmap_handler(struct trapframe frame) int cpu = PCPU_GET(cpuid); u_int ipi_bitmap; - critical_enter(); td = curthread; td->td_intr_nesting_level++; oldframe = td->td_intr_frame; td->td_intr_frame = &frame; ipi_bitmap = atomic_readandclear_int(&cpuid_to_pcpu[cpu]->pc_ipi_bitmap); - if (ipi_bitmap & (1 << IPI_PREEMPT)) { -#ifdef COUNT_IPIS - (*ipi_preempt_counts[cpu])++; -#endif - sched_preempt(td); - } if (ipi_bitmap & (1 << IPI_AST)) { #ifdef COUNT_IPIS (*ipi_ast_counts[cpu])++; @@ -1280,14 +1273,23 @@ ipi_bitmap_handler(struct trapframe frame) /* Nothing to do for AST */ } if (ipi_bitmap & (1 << IPI_HARDCLOCK)) { + critical_enter(); #ifdef COUNT_IPIS (*ipi_hardclock_counts[cpu])++; #endif hardclockintr(); + critical_exit(); } + + /* Run preempt after clock handlers since it may switch. */ + if (ipi_bitmap & (1 << IPI_PREEMPT)) { +#ifdef COUNT_IPIS + (*ipi_preempt_counts[cpu])++; +#endif + sched_preempt(td); + } td->td_intr_frame = oldframe; td->td_intr_nesting_level--; - critical_exit(); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912022234.xB2MYJrQ039438>