From owner-svn-src-head@freebsd.org Sun Jul 29 00:30:08 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F245A1062CFD; Sun, 29 Jul 2018 00:30:07 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A43CC8742E; Sun, 29 Jul 2018 00:30:07 +0000 (UTC) (envelope-from truckman@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 811A4649A; Sun, 29 Jul 2018 00:30:07 +0000 (UTC) (envelope-from truckman@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6T0U79K055128; Sun, 29 Jul 2018 00:30:07 GMT (envelope-from truckman@FreeBSD.org) Received: (from truckman@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6T0U74H055127; Sun, 29 Jul 2018 00:30:07 GMT (envelope-from truckman@FreeBSD.org) Message-Id: <201807290030.w6T0U74H055127@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: truckman set sender to truckman@FreeBSD.org using -f From: Don Lewis Date: Sun, 29 Jul 2018 00:30:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336855 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: truckman X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 336855 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Jul 2018 00:30:08 -0000 Author: truckman Date: Sun Jul 29 00:30:06 2018 New Revision: 336855 URL: https://svnweb.freebsd.org/changeset/base/336855 Log: Fix the long term ULE load balancer so that it actually works. The initial call to sched_balance() during startup is meant to initialize balance_ticks, but does not actually do that since smp_started is still zero at that time. Since balance_ticks does not get set, there are no further calls to sched_balance(). Fix this by setting balance_ticks in sched_initticks() since we know the value of balance_interval at that time, and eliminate the useless startup call to sched_balance(). We don't need to randomize the intial value of balance_ticks. Since there is now only one call to sched_balance(), we can hoist the tests at the top of this function out to the caller and avoid the overhead of the function call when running a SMP kernel on UP hardware. PR: 223914 Reviewed by: kib MFC after: 2 weeks Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Sun Jul 29 00:12:16 2018 (r336854) +++ head/sys/kern/sched_ule.c Sun Jul 29 00:30:06 2018 (r336855) @@ -884,9 +884,6 @@ sched_balance(void) { struct tdq *tdq; - if (smp_started == 0 || rebalance == 0) - return; - balance_ticks = max(balance_interval / 2, 1) + (sched_random() % balance_interval); tdq = TDQ_SELF(); @@ -1413,7 +1410,6 @@ sched_setup_smp(void) panic("Can't find cpu group for %d\n", i); } balance_tdq = TDQ_SELF(); - sched_balance(); } #endif @@ -1474,6 +1470,7 @@ sched_initticks(void *dummy) * what realstathz is. */ balance_interval = realstathz; + balance_ticks = balance_interval; affinity = SCHED_AFFINITY_DEFAULT; #endif if (sched_idlespinthresh < 0) @@ -2382,7 +2379,7 @@ sched_clock(struct thread *td) /* * We run the long term load balancer infrequently on the first cpu. */ - if (balance_tdq == tdq) { + if (balance_tdq == tdq && smp_started != 0 && rebalance != 0) { if (balance_ticks && --balance_ticks == 0) sched_balance(); }