From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOpYq-0008M1-NM for qemu-devel@nongnu.org; Mon, 10 Aug 2015 12:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZOpYl-0001wS-Rm for qemu-devel@nongnu.org; Mon, 10 Aug 2015 12:04:28 -0400 Received: from greensocs.com ([193.104.36.180]:39416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZOpYl-0001vi-Jb for qemu-devel@nongnu.org; Mon, 10 Aug 2015 12:04:23 -0400 Message-ID: <55C8CB83.1020608@greensocs.com> Date: Mon, 10 Aug 2015 18:04:19 +0200 From: Frederic Konrad MIME-Version: 1.0 References: <1439220437-23957-1-git-send-email-fred.konrad@greensocs.com> <1439220437-23957-2-git-send-email-fred.konrad@greensocs.com> <55C8CA70.7090809@redhat.com> In-Reply-To: <55C8CA70.7090809@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH V7 01/19] cpus: protect queued_work_* with work_mutex. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org, mttcg@greensocs.com Cc: mark.burton@greensocs.com, alex.bennee@linaro.org, a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com On 10/08/2015 17:59, Paolo Bonzini wrote: > > On 10/08/2015 17:26, fred.konrad@greensocs.com wrote: >> >> + qemu_mutex_lock(&cpu->work_mutex); >> while ((wi = cpu->queued_work_first)) { >> cpu->queued_work_first = wi->next; >> + qemu_mutex_unlock(&cpu->work_mutex); >> wi->func(wi->data); >> + qemu_mutex_lock(&cpu->work_mutex); >> wi->done = true; > This should be atomic_mb_set Isn't that protected by the mutex? Or maybe it's used somewhere else? > >> if (wi->free) { >> g_free(wi); >> } >> } >> cpu->queued_work_last = NULL; > ... and I'm a bit afraid of leaving the state of the list inconsistent, > so I'd move this after the cpu->queued_work_first assignment. Otherwise > the patch looks good, I'm queuing it for 2.5. > > Paolo > >> + qemu_mutex_unlock(&cpu->work_mutex); >> +