From owner-svn-src-head@freebsd.org Mon Nov 27 04:55:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5A4ADF8D90; Mon, 27 Nov 2017 04:55:03 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7B8016381F; Mon, 27 Nov 2017 04:55:02 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 7F02E10A7DB; Sun, 26 Nov 2017 23:54:56 -0500 (EST) From: John Baldwin To: Nathan Whitehorn Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r326218 - head/sys/kern Date: Sun, 26 Nov 2017 20:50:12 -0800 Message-ID: <3170692.kvv90QqB0X@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) In-Reply-To: <201711252341.vAPNf5Qx001464@repo.freebsd.org> References: <201711252341.vAPNf5Qx001464@repo.freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Sun, 26 Nov 2017 23:54:56 -0500 (EST) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Mon, 27 Nov 2017 04:55:03 -0000 On Saturday, November 25, 2017 11:41:05 PM Nathan Whitehorn wrote: > Author: nwhitehorn > Date: Sat Nov 25 23:41:05 2017 > New Revision: 326218 > URL: https://svnweb.freebsd.org/changeset/base/326218 > > Log: > Remove some, but not all, assumptions that the BSP is CPU 0 and that CPUs > are numbered densely from there to n_cpus. > > MFC after: 1 month > > Modified: > head/sys/kern/kern_clock.c > head/sys/kern/kern_clocksource.c > head/sys/kern/kern_shutdown.c > head/sys/kern/kern_timeout.c > head/sys/kern/sched_ule.c > head/sys/kern/subr_pcpu.c > > Modified: head/sys/kern/kern_clock.c > ============================================================================== > --- head/sys/kern/kern_clock.c Sat Nov 25 23:23:24 2017 (r326217) > +++ head/sys/kern/kern_clock.c Sat Nov 25 23:41:05 2017 (r326218) > @@ -573,7 +573,9 @@ hardclock_cnt(int cnt, int usermode) > void > hardclock_sync(int cpu) > { > - int *t = DPCPU_ID_PTR(cpu, pcputicks); > + int *t; > + KASSERT(!CPU_ABSENT(cpu), ("Absent CPU %d", cpu)); Blank line before the KASSERT() perhaps? > + t = DPCPU_ID_PTR(cpu, pcputicks); > > *t = ticks; Probably don't need this blank line though? > } > > Modified: head/sys/kern/sched_ule.c > ============================================================================== > --- head/sys/kern/sched_ule.c Sat Nov 25 23:23:24 2017 (r326217) > +++ head/sys/kern/sched_ule.c Sat Nov 25 23:41:05 2017 (r326218) > @@ -2444,6 +2451,7 @@ sched_add(struct thread *td, int flags) > * Pick the destination cpu and if it isn't ours transfer to the > * target cpu. > */ > + td_get_sched(td)->ts_cpu = curcpu; /* Pick something valid to start */ > cpu = sched_pickcpu(td, flags); It is not obvious why every sched_add() needs this once you've fixed thread0. Shouldn't new threads just inherit from thread0's already-fixed value? If not, perhaps fix thread0's value sooner? > tdq = sched_setcpu(td, cpu, flags); > tdq_add(tdq, td, flags); > > Modified: head/sys/kern/subr_pcpu.c > ============================================================================== > --- head/sys/kern/subr_pcpu.c Sat Nov 25 23:23:24 2017 (r326217) > +++ head/sys/kern/subr_pcpu.c Sat Nov 25 23:41:05 2017 (r326218) > @@ -279,6 +279,8 @@ pcpu_destroy(struct pcpu *pcpu) > struct pcpu * > pcpu_find(u_int cpuid) > { > + KASSERT(cpuid_to_pcpu[cpuid] != NULL, > + ("Getting uninitialized PCPU %d", cpuid)); This KASSERT seems unnecessary? If the caller uses an invalid one, it will just fault anyway. > return (cpuid_to_pcpu[cpuid]); > } > @@ -409,7 +411,7 @@ DB_SHOW_ALL_COMMAND(pcpu, db_show_cpu_all) > int id; > > db_printf("Current CPU: %d\n\n", PCPU_GET(cpuid)); > - for (id = 0; id <= mp_maxid; id++) { > + CPU_FOREACH(id) { If you remove the KASSERT you don't need this change since it checks the return value of pcpu_find() (which you didn't change). In particular, this DDB command shows all valid pcpu structures safely even if that set is inconsistent with the all_cpus mask (or the old version did at least). There is also nothing about this that assumes BSP == 0 either. CPU_FOREACH() is doing a loop from 0 to mp_maxid under the covers as well. > pc = pcpu_find(id); > if (pc != NULL) { > show_pcpu(pc); > -- John Baldwin