From owner-freebsd-virtualization@freebsd.org Wed Dec 14 11:46:59 2016 Return-Path: Delivered-To: freebsd-virtualization@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 B5F06C7690B for ; Wed, 14 Dec 2016 11:46:59 +0000 (UTC) (envelope-from ian.campbell@docker.com) Received: from mail-wj0-x22d.google.com (mail-wj0-x22d.google.com [IPv6:2a00:1450:400c:c01::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4F90A17B0 for ; Wed, 14 Dec 2016 11:46:59 +0000 (UTC) (envelope-from ian.campbell@docker.com) Received: by mail-wj0-x22d.google.com with SMTP id tk12so29513363wjb.3 for ; Wed, 14 Dec 2016 03:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=docker.com; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=dGXF6PSFB1U/SOvvGDP/MDPlVEtOjKhlTBTh1qOchDI=; b=OSYaErF6p5Um0ltDI6Dh0Kihi0o2IirFGNVUNuLMLj1BFAFilI55JhFqUN0+XPo7BW zYHWSg4vNCNLxLp/xzOLUsTaYkSORAcJYQWR5jhfuDdTqT1ahJ4bToXtD9YDeHRT3BMT L74qVnsRzAoGtxMDGDPBZdqg9+BHk3XfZelkU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dGXF6PSFB1U/SOvvGDP/MDPlVEtOjKhlTBTh1qOchDI=; b=f+jqCetH2IAm+VRIUZFaGdaxGGFDOQZi/Hy0ePHntcktcve9JzzKA++K1AjXu3kBl3 4ingqMW/1ZZhNKSBKQBcxFkVScH0ohMebkRswc33cyQQXNTb+eHGVXeHxca7Uq4NxoO1 n+LoNdwFk+8QqmVO118/C4e4H9lszuhzsDeJ/VU9tau9G2MfIMYLoHx+lORLBkkUN23r FqzmHqrSAKTbYQWoCBqGqOE+XGopc1YsjUn32q8VZD8ZSdKo8AKz0V0QPsh2El1FGhvo pWlJoESjX0ID7GAJ5ypG3b5ZlxwxSWsukWyZc0qfhaH/ExHIzttABZL/aMg94uOP9waG 1+ZQ== X-Gm-Message-State: AKaTC01tQqtMrFnewrUwJYk9E9wvPTXY/AG/GuPpKz2H5gp8+MTjjUaki5vajfrxn9eNV5DHAc8UNpfTbKVDtsfT X-Received: by 10.28.133.143 with SMTP id h137mr6556058wmd.58.1481716017211; Wed, 14 Dec 2016 03:46:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.194.107.231 with HTTP; Wed, 14 Dec 2016 03:46:56 -0800 (PST) In-Reply-To: <397B138D-3701-4FB4-A9B3-618CE2624C3C@freebsd.org> References: <631f775d-8d61-55ba-1e7b-8ce4fcadcbf3@freebsd.org> <397B138D-3701-4FB4-A9B3-618CE2624C3C@freebsd.org> From: Ian Campbell Date: Wed, 14 Dec 2016 11:46:56 +0000 Message-ID: Subject: Re: Query about bhyve's blockif_cancel and the signalling mechanisms To: Tycho Nightingale Cc: Peter Grehan , freebsd-virtualization@freebsd.org, Anil Madhavapeddy Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 11:46:59 -0000 On 14 December 2016 at 00:05, Tycho Nightingale wrote: > On Dec 13, 2016, at 1:32 AM, Peter Grehan wrote: >>> I have a secondary concern which is what happens if the IO thread is >>> on its way to making a blocking system call in blockif_proc but has >>> not actually done so when the signal is delivered. It seems like it >>> would simply carry on and make the blocking call with perhaps >>> unexpected consequences (i/o getting wedged, perhaps only until a >>> second reset attempt). I've not actually seen this happening though >>> and there's a chance I'm simply over thinking things after staring at >>> them for so long! >> >> I believe this case is handled - I discussed this at length with Tycho w= hen the code was committed a while back. >> >> Tycho - any thoughts ? > > ahci_port_stop() is called under the protection the port soft-state lock = so that will stem any further requests from landing in the blockif queue. = That=E2=80=99s the easy case. > > As for blockif requests which are queued, those are simply completed. Th= e ones that are in-flight all have their status set to BST_BUSY when they a= re moved from the pending queue to the busy queue just prior to being sent = to blockif_proc(). It=E2=80=99s therefore possible that an in-flight reque= st (one on the busy list) has yet to call blockif_proc(), or is already ins= ide blockif_proc() or has just completed blockif_proc(). In all cases howe= ver BST_BUSY is cleared in blockif_complete(). The key is therefore that r= egardless of where the thread is, blockif_cancel() will continue to issue p= thread_kill() until the request reaches blockif_complete() =E2=80=94 breaki= ng it out of system calls as necessary. > > Does that make sense? Absolutely. Somehow I had read "while (be->be_status =3D=3D BST_BUSY)" as "if (...)", Thanks for setting me straight! Ian.