From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l140sm3422275wmg.12.2017.02.03.07.02.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 07:02:49 -0800 (PST) Received: from zen (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTPS id 5DA793E00E9; Fri, 3 Feb 2017 15:02:54 +0000 (GMT) References: <20170201150553.9381-1-alex.bennee@linaro.org> <20170201150553.9381-21-alex.bennee@linaro.org> User-agent: mu4e 0.9.19; emacs 25.1.91.7 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: Peter Maydell Cc: MTTCG Devel , QEMU Developers , KONRAD =?utf-8?B?RnLDqWTDqXJpYw==?= , Alvise Rigo , "Emilio G. Cota" , Pranith Kumar , Nikunj A Dadhania , Mark Burton , Paolo Bonzini , Jan Kiszka , Fedorov Sergey , Richard Henderson , Bamvor Zhang Jian , "open list\:ARM" Subject: Re: [PATCH v9 20/25] target-arm/powerctl: defer cpu reset work to CPU context In-reply-to: Date: Fri, 03 Feb 2017 15:02:54 +0000 Message-ID: <87poizfhb5.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-TUID: 15u4MXMeq6WM Peter Maydell writes: > On 1 February 2017 at 15:05, Alex Bennée wrote: >> When switching a new vCPU on we want to complete a bunch of the setup >> work before we start scheduling the vCPU thread. To do this cleanly we >> defer vCPU setup to async work which will run the vCPUs execution >> context as the thread is woken up. The scheduling of the work will kick >> the vCPU awake. >> >> This avoids potential races in MTTCG system emulation. >> >> Signed-off-by: Alex Bennée >> Reviewed-by: Richard Henderson > > Can we now have races between arm_set_cpu_on() and > arm_set_cpu_off() ? It's not clear to me what prevents that. > > With this change our PSCI CPU_ON is no longer effectively > atomic, which means we need to think about the races > between PSCI CPU_ON and CPU_OFF, and the fact that the > core might be in what the PSCI spec section 6.6 > calls an ON_PENDING state (ie CPU_ON has been called > for it but it hasn't actually booted yet). Would it be enough to also queue the set_cpu_off work? The queue itself is safe to add to so you'll end up with a series of on/off deferred work that will eventually unwind itself when the CPU thread runs. > > thanks > -- PMM -- Alex Bennée From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cZfO5-0008Vx-Cs for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:03:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cZfNz-00054d-Qi for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:02:57 -0500 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]:34308) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cZfNz-00054X-Il for qemu-devel@nongnu.org; Fri, 03 Feb 2017 10:02:51 -0500 Received: by mail-wm0-x22a.google.com with SMTP id 196so15483672wmm.1 for ; Fri, 03 Feb 2017 07:02:51 -0800 (PST) References: <20170201150553.9381-1-alex.bennee@linaro.org> <20170201150553.9381-21-alex.bennee@linaro.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: Date: Fri, 03 Feb 2017 15:02:54 +0000 Message-ID: <87poizfhb5.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v9 20/25] target-arm/powerctl: defer cpu reset work to CPU context List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: MTTCG Devel , QEMU Developers , KONRAD =?utf-8?B?RnLDqWTDqXJpYw==?= , Alvise Rigo , "Emilio G. Cota" , Pranith Kumar , Nikunj A Dadhania , Mark Burton , Paolo Bonzini , Jan Kiszka , Fedorov Sergey , Richard Henderson , Bamvor Zhang Jian , "open list:ARM" Peter Maydell writes: > On 1 February 2017 at 15:05, Alex Bennée wrote: >> When switching a new vCPU on we want to complete a bunch of the setup >> work before we start scheduling the vCPU thread. To do this cleanly we >> defer vCPU setup to async work which will run the vCPUs execution >> context as the thread is woken up. The scheduling of the work will kick >> the vCPU awake. >> >> This avoids potential races in MTTCG system emulation. >> >> Signed-off-by: Alex Bennée >> Reviewed-by: Richard Henderson > > Can we now have races between arm_set_cpu_on() and > arm_set_cpu_off() ? It's not clear to me what prevents that. > > With this change our PSCI CPU_ON is no longer effectively > atomic, which means we need to think about the races > between PSCI CPU_ON and CPU_OFF, and the fact that the > core might be in what the PSCI spec section 6.6 > calls an ON_PENDING state (ie CPU_ON has been called > for it but it hasn't actually booted yet). Would it be enough to also queue the set_cpu_off work? The queue itself is safe to add to so you'll end up with a series of on/off deferred work that will eventually unwind itself when the CPU thread runs. > > thanks > -- PMM -- Alex Bennée