From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46649) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIDrA-0000AC-HU for qemu-devel@nongnu.org; Mon, 02 Feb 2015 05:03:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIDr5-0007j1-IQ for qemu-devel@nongnu.org; Mon, 02 Feb 2015 05:03:48 -0500 Received: from mail-wi0-x233.google.com ([2a00:1450:400c:c05::233]:42084) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIDr5-0007is-BH for qemu-devel@nongnu.org; Mon, 02 Feb 2015 05:03:43 -0500 Received: by mail-wi0-f179.google.com with SMTP id l15so14003927wiw.0 for ; Mon, 02 Feb 2015 02:03:42 -0800 (PST) Sender: Paolo Bonzini Message-ID: <54CF4B78.5040102@redhat.com> Date: Mon, 02 Feb 2015 11:03:36 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1421428797-23697-1-git-send-email-fred.konrad@greensocs.com> <1421428797-23697-10-git-send-email-fred.konrad@greensocs.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC 09/10] cpu: remove exit_request global. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , =?UTF-8?B?S09OUkFEIEZyw6lkw6k=?= =?UTF-8?B?cmlj?= Cc: mttcg@listserver.greensocs.com, "J. Kiszka" , Mark Burton , QEMU Developers , Alexander Graf On 29/01/2015 16:52, Peter Maydell wrote: >> > + CPU_FOREACH(cpu) { >> > + cpu->exit_loop_request = 1; >> > + } >> > } > You can't do this -- this code is a signal handler so it could > get run at any time including while the list of CPUs is being > updated. (This is why we have the exit_request flag in the > first place rather than just setting the exit_request flag in > each CPU...) Actually you can do this if you are careful. In particular, you can do it while you are under the big QEMU lock. If you are not, basically you have to treat the CPU list as RCU-protected, and this is doable because the CPU object cannot be removed and added back into the CPU list. Unfortunately RCU doesn't support QTAILQ, at least not yet, so you'd have to convert the CPU list to QLIST. But the basic idea of this patch can be done. Paolo