From owner-freebsd-hackers@FreeBSD.ORG Thu May 15 17:29:31 2014 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id C50E6617 for ; Thu, 15 May 2014 17:29:31 +0000 (UTC) Received: from elf.torek.net (50-73-42-1-utah.hfc.comcastbusiness.net [50.73.42.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 85BF82EC2 for ; Thu, 15 May 2014 17:29:30 +0000 (UTC) Received: from elf.torek.net (localhost [127.0.0.1]) by elf.torek.net (8.14.5/8.14.5) with ESMTP id s4FHK8RC065430 for ; Thu, 15 May 2014 11:20:08 -0600 (MDT) (envelope-from torek@torek.net) Message-Id: <201405151720.s4FHK8RC065430@elf.torek.net> From: Chris Torek To: freebsd-hackers@freebsd.org Subject: bad call to sched_bind() => hang, even with INVARIANTS Date: Thu, 15 May 2014 11:20:08 -0600 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (elf.torek.net [127.0.0.1]); Thu, 15 May 2014 11:20:08 -0600 (MDT) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 May 2014 17:29:31 -0000 I was poking around with a bhyve emulation, where the emulation has only one CPU but the real systems have more. In our real-system code we had a sched_bind() that just assumed there were 2 or more CPUs, instead of just the 1. This caused the entire system to hang. (Note: using SCHED_ULE.) It's not immediately obvious to me what went wrong "underneath" to cause the whole-system hang, but clearly it is wrong to attempt to pin a thread to a CPU that does not exist. Should sched_bind() have a KASSERT in it to make sure that the cpu argument is sensible? (Or maybe even something a little more aggressive?) Chris