From patchwork Sat Apr 30 13:30:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 743372 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p3UDUb6t001149 for ; Sat, 30 Apr 2011 13:30:38 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756809Ab1D3Nae (ORCPT ); Sat, 30 Apr 2011 09:30:34 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:33344 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756679Ab1D3Nae (ORCPT ); Sat, 30 Apr 2011 09:30:34 -0400 Received: by bwz15 with SMTP id 15so3694296bwz.19 for ; Sat, 30 Apr 2011 06:30:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=+bh5y7xLBWXDcqytQS8a9H/mUZ+ZJOTCHOUSCosHlm4=; b=qIh617PLzXz9wxq2cVWZumpx2iwuSmhKT12DEWq7lKRUZsIiusnQg4iagrO5f4vfrU lmKfmyGVqOy3kIIXWmE1A79kXEDt3qTyD5uBrTZ272Rp5qDhAe/czzak3+zyuuIWJdAv 1Ba94pnrGdeKLJ+V12StvVAHoKt4SB/YKkoHc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=fcMJ98uqivNN+8iCaLMbQakFDxNUdZXKgWInenPArMNy2YWD0pt0M2/Cri0p3/XhZP D5SIBDKogMwuxeJE0PIAwbSVLBl7t4p7RgRa6c9MRtCAvwCRhj2vB8kAyV13p8HPydDt +YB6xctoKUmEC0TeiPxdpEy07zFTwrP4GdO88= Received: by 10.204.25.20 with SMTP id x20mr521705bkb.112.1304170233048; Sat, 30 Apr 2011 06:30:33 -0700 (PDT) Received: from localhost.localdomain ([94.230.82.242]) by mx.google.com with ESMTPS id q24sm2169224bks.21.2011.04.30.06.30.31 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 30 Apr 2011 06:30:32 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, kvm@vger.kernel.org, Sasha Levin Subject: [PATCH 1/3] kvm tools: Lock job_mutex before signalling Date: Sat, 30 Apr 2011 16:30:23 +0300 Message-Id: <1304170225-4859-1-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sat, 30 Apr 2011 13:30:38 +0000 (UTC) Locking mutex before signalling to prevent unexpected scheduling. Signed-off-by: Sasha Levin --- tools/kvm/threadpool.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/tools/kvm/threadpool.c b/tools/kvm/threadpool.c index c584ec7..700c08f 100644 --- a/tools/kvm/threadpool.c +++ b/tools/kvm/threadpool.c @@ -166,5 +166,7 @@ void thread_pool__signal_work(void *job) thread_pool__job_info_push_locked(job); mutex_unlock(&jobinfo->mutex); + mutex_lock(&job_mutex); pthread_cond_signal(&job_cond); + mutex_unlock(&job_mutex); }