From patchwork Mon May 30 17:27:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 830682 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 p4UHTG2P018765 for ; Mon, 30 May 2011 17:29:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757612Ab1E3R3V (ORCPT ); Mon, 30 May 2011 13:29:21 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:46736 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757346Ab1E3R3U (ORCPT ); Mon, 30 May 2011 13:29:20 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so2766739wya.19 for ; Mon, 30 May 2011 10:29:19 -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=F+QKUt8boV9tB4OHH9qVaa4Jgs0d/tZhXPuoUjGqzgs=; b=IrgQ0CVaAEBgAkFqWMuu5dIaAv95QbzZb/VU9qHTALxmvnkGAshOXnfm6tmpZxmIRW FBplyYca/38TPC23/34Ft0XqUne5QNZtk+vekWOqTlCycnnXrBotAJOTiB8XdgEjKlx2 cjkk8AyHvO8tg3bwgF5Nh+83YlZxvtiqPZ3nk= 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=UGxpyRgn8YKAiMP6Tj+MxRUTCroORQxfcn82iN/633JT+KyX8O2F5HMrjOyBALm0no y4InGCZVNYpQHmemmrhDByxMQ7dPg3cmAQ4zU1UuDxO3wa3GgmLozSnLFg7LpewcyJPB 5yIesbxmPJPAvr8LPQQdi7aiD3xstbeNCTeuM= Received: by 10.216.229.82 with SMTP id g60mr2653920weq.70.1306776559508; Mon, 30 May 2011 10:29:19 -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 gb6sm3194848wbb.17.2011.05.30.10.29.17 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2011 10:29:19 -0700 (PDT) From: Sasha Levin To: penberg@kernel.org Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com, Sasha Levin Subject: [PATCH v3 7/8] kvm tools: Add debug mode to brlock Date: Mon, 30 May 2011 20:27:57 +0300 Message-Id: <1306776478-29613-8-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1306776478-29613-1-git-send-email-levinsasha928@gmail.com> References: <1306776478-29613-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]); Mon, 30 May 2011 17:29:49 +0000 (UTC) Adds a debug mode which allows to switch the brlock into a big rwlock. This can be used to verify we don't end up with a BKL kind of lock with the current brlock implementation. Signed-off-by: Sasha Levin --- tools/kvm/include/kvm/brlock.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/tools/kvm/include/kvm/brlock.h b/tools/kvm/include/kvm/brlock.h index 2e2e0f8..bd1d882 100644 --- a/tools/kvm/include/kvm/brlock.h +++ b/tools/kvm/include/kvm/brlock.h @@ -17,9 +17,25 @@ #define barrier() __asm__ __volatile__("": : :"memory") #endif +#ifdef KVM_BRLOCK_DEBUG + +#include "kvm/rwsem.h" + +DECLARE_RWSEM(brlock_sem); + +#define br_read_lock() down_read(&brlock_sem); +#define br_read_unlock() up_read(&brlock_sem); + +#define br_write_lock() down_write(&brlock_sem); +#define br_write_unlock() up_write(&brlock_sem); + +#else + #define br_read_lock() barrier() #define br_read_unlock() barrier() #define br_write_lock() kvm__pause() #define br_write_unlock() kvm__continue() #endif + +#endif