From patchwork Mon May 30 08:30:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 829472 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 p4U8VqMr026511 for ; Mon, 30 May 2011 08:33:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751769Ab1E3Iby (ORCPT ); Mon, 30 May 2011 04:31:54 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:44843 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753901Ab1E3Ibr (ORCPT ); Mon, 30 May 2011 04:31:47 -0400 Received: by mail-wy0-f174.google.com with SMTP id 21so2460435wya.19 for ; Mon, 30 May 2011 01:31:47 -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=T7lQWkZd8rn4DKvhYgm1zO9sC0j+ooHQe334a9dOt5I=; b=GiNiEJEzpT1EsNxon2W4LIOkFFfTuTpVTKjzs37Pl0WETS8QGiVYzjJUwkYKh01Q21 TbVwC0mq3bQHTIPWtjazwEN79544NfEJ8lJ1B2zB8MYWZ7woBBpSbhuAQJmrJzl9NMiD ziGgJ1XVi9903YNa1q1g1YcpMPtQ1tfAGIFQE= 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=mbNIrlfRJpb7FDt3D/CiS5XBkcFvzhLnljS37C9OXkX0mjn+T7NBPpHbXxkJnncYpG wBr5kyWFwiTo+3nBIfuPpbh18jbRgyr6o7ioBImzMW34Iido58TH5baTecV2P1b0/CsC DPjeMLSgniRMZZxfgHiBlzHLD6oEZgqZvZ7DI= Received: by 10.216.205.26 with SMTP id i26mr4569461weo.58.1306744307054; Mon, 30 May 2011 01:31:47 -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 z66sm2331147weq.24.2011.05.30.01.31.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 May 2011 01:31:46 -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 v2 7/8] kvm tools: Add debug mode to brlock Date: Mon, 30 May 2011 11:30:46 +0300 Message-Id: <1306744247-26051-7-git-send-email-levinsasha928@gmail.com> X-Mailer: git-send-email 1.7.5.rc3 In-Reply-To: <1306744247-26051-1-git-send-email-levinsasha928@gmail.com> References: <1306744247-26051-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 08:33:28 +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 1863166..4cc0521 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