From patchwork Sun May 29 17:32:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 827902 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4THXXkD004816 for ; Sun, 29 May 2011 17:33:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755033Ab1E2RdI (ORCPT ); Sun, 29 May 2011 13:33:08 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:47815 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754767Ab1E2RdF (ORCPT ); Sun, 29 May 2011 13:33:05 -0400 Received: by wwa36 with SMTP id 36so3267491wwa.1 for ; Sun, 29 May 2011 10:33:04 -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 :in-reply-to:references; bh=aPdr4GDbzYqgLAkHzGDiIUgwqAPg5xJeEDSilLYe3U4=; b=cVmKYxE/GyKSNzMMbod+YCJ2NKrnNnmOLgm7mmoM/1csvOmxp34m0c/0c5GvLdQ2pT WX0RX76emR2HiIbglqG3Zl/nChj8lIvqi9x1tI5CP1A+ri100UPXVF4XBRid+NhyLzo7 NhKb4huaoS2ZurjY/8mss80nDW4uIm+89zTiI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=FI2fBUcJo/g9RbuV07b/WFo7HoT90VNZGsN5DkuUEe/gAtYM06a5IlXNOT0fPA5/n/ Yq/2SPO185piYXXIT9SsHAHdrojFjDbndVq65IqMWD1eeeZztk04X19lqfnALM6G2ORp YWApmeB1oOIXjY9phFPmWi5VT37CahzHMAhhg= Received: by 10.227.23.200 with SMTP id s8mr4097669wbb.87.1306690384047; Sun, 29 May 2011 10:33:04 -0700 (PDT) Received: from localhost.localdomain (bzq-79-181-201-100.red.bezeqint.net [79.181.201.100]) by mx.google.com with ESMTPS id ex2sm2521511wbb.31.2011.05.29.10.33.02 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 29 May 2011 10:33:03 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: avi@redhat.com, kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH 3/4] kvm tools: Add a brlock Date: Sun, 29 May 2011 20:32:27 +0300 Message-Id: <1306690348-23260-3-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306690348-23260-1-git-send-email-levinsasha928@gmail.com> References: <1306690348-23260-1-git-send-email-levinsasha928@gmail.com> 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 (demeter1.kernel.org [140.211.167.41]); Sun, 29 May 2011 17:33:51 +0000 (UTC) brlock is a lock which is very cheap for reads, but very expensive for writes. This lock will be used when updates are very rare and reads are common. This lock is currently implemented by stopping the guest while performing the updates. We assume that the only threads which read from the locked data are VCPU threads, and the only writer isn't a VCPU thread. Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/brlock.h | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) create mode 100644 tools/kvm/include/kvm/brlock.h diff --git a/tools/kvm/include/kvm/brlock.h b/tools/kvm/include/kvm/brlock.h new file mode 100644 index 0000000..f192071 --- /dev/null +++ b/tools/kvm/include/kvm/brlock.h @@ -0,0 +1,12 @@ +#ifndef KVM__BRLOCK_H +#define KVM__BRLOCK_H + +#include "kvm/kvm.h" +#include "kvm/barrier.h" + +#define br_read_lock() mb() +#define br_read_unlock() mb() + +#define br_write_lock() kvm__pause() +#define br_write_unlock() kvm__continue() +#endif