From owner-svn-src-all@freebsd.org Sun Dec 8 01:17:39 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 645551D2C21; Sun, 8 Dec 2019 01:17:39 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47VpN31vc9z4S1H; Sun, 8 Dec 2019 01:17:39 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 25C9B2276C; Sun, 8 Dec 2019 01:17:39 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xB81Hdd0004612; Sun, 8 Dec 2019 01:17:39 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xB81Hchp004609; Sun, 8 Dec 2019 01:17:38 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201912080117.xB81Hchp004609@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Sun, 8 Dec 2019 01:17:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355512 - in head/sys: kern sys X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: in head/sys: kern sys X-SVN-Commit-Revision: 355512 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Dec 2019 01:17:39 -0000 Author: jeff Date: Sun Dec 8 01:17:38 2019 New Revision: 355512 URL: https://svnweb.freebsd.org/changeset/base/355512 Log: Handle multiple clock interrupts simultaneously in sched_clock(). Reviewed by: kib, markj, mav Differential Revision: https://reviews.freebsd.org/D22625 Modified: head/sys/kern/kern_clock.c head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c head/sys/sys/sched.h Modified: head/sys/kern/kern_clock.c ============================================================================== --- head/sys/kern/kern_clock.c Sun Dec 8 01:16:22 2019 (r355511) +++ head/sys/kern/kern_clock.c Sun Dec 8 01:17:38 2019 (r355512) @@ -711,8 +711,7 @@ statclock(int cnt, int usermode) td->td_incruntime += runtime; PCPU_SET(switchtime, new_switchtime); - for ( ; cnt > 0; cnt--) - sched_clock(td); + sched_clock(td, cnt); thread_unlock(td); #ifdef HWPMC_HOOKS if (td->td_intr_frame != NULL) Modified: head/sys/kern/sched_4bsd.c ============================================================================== --- head/sys/kern/sched_4bsd.c Sun Dec 8 01:16:22 2019 (r355511) +++ head/sys/kern/sched_4bsd.c Sun Dec 8 01:17:38 2019 (r355512) @@ -706,8 +706,8 @@ sched_rr_interval(void) * favor processes which haven't run much recently, and to round-robin * among other processes. */ -void -sched_clock(struct thread *td) +static void +sched_clock_tick(struct thread *td) { struct pcpuidlestat *stat; struct td_sched *ts; @@ -734,6 +734,14 @@ sched_clock(struct thread *td) stat = DPCPU_PTR(idlestat); stat->oldidlecalls = stat->idlecalls; stat->idlecalls = 0; +} + +void +sched_clock(struct thread *td, int cnt) +{ + + for ( ; cnt > 0; cnt--) + sched_clock_tick(td); } /* Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Sun Dec 8 01:16:22 2019 (r355511) +++ head/sys/kern/sched_ule.c Sun Dec 8 01:17:38 2019 (r355512) @@ -2421,7 +2421,7 @@ sched_userret_slowpath(struct thread *td) * threads. */ void -sched_clock(struct thread *td) +sched_clock(struct thread *td, int cnt) { struct tdq *tdq; struct td_sched *ts; @@ -2432,8 +2432,10 @@ sched_clock(struct thread *td) /* * We run the long term load balancer infrequently on the first cpu. */ - if (balance_tdq == tdq && smp_started != 0 && rebalance != 0) { - if (balance_ticks && --balance_ticks == 0) + if (balance_tdq == tdq && smp_started != 0 && rebalance != 0 && + balance_ticks != 0) { + balance_ticks -= cnt; + if (balance_ticks <= 0) sched_balance(); } #endif @@ -2455,14 +2457,15 @@ sched_clock(struct thread *td) } ts = td_get_sched(td); sched_pctcpu_update(ts, 1); - if (td->td_pri_class & PRI_FIFO_BIT) + if ((td->td_pri_class & PRI_FIFO_BIT) || TD_IS_IDLETHREAD(td)) return; + if (PRI_BASE(td->td_pri_class) == PRI_TIMESHARE) { /* * We used a tick; charge it to the thread so * that we can compute our interactivity. */ - td_get_sched(td)->ts_runtime += tickincr; + td_get_sched(td)->ts_runtime += tickincr * cnt; sched_interact_update(td); sched_priority(td); } @@ -2471,7 +2474,8 @@ sched_clock(struct thread *td) * Force a context switch if the current thread has used up a full * time slice (default is 100ms). */ - if (!TD_IS_IDLETHREAD(td) && ++ts->ts_slice >= tdq_slice(tdq)) { + ts->ts_slice += cnt; + if (ts->ts_slice >= tdq_slice(tdq)) { ts->ts_slice = 0; td->td_flags |= TDF_NEEDRESCHED | TDF_SLICEEND; } Modified: head/sys/sys/sched.h ============================================================================== --- head/sys/sys/sched.h Sun Dec 8 01:16:22 2019 (r355511) +++ head/sys/sys/sched.h Sun Dec 8 01:17:38 2019 (r355512) @@ -135,7 +135,7 @@ sched_userret(struct thread *td) * Threads are moved on and off of run queues */ void sched_add(struct thread *td, int flags); -void sched_clock(struct thread *td); +void sched_clock(struct thread *td, int ticks); void sched_preempt(struct thread *td); void sched_rem(struct thread *td); void sched_relinquish(struct thread *td);