From patchwork Thu Jun 20 11:31:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 18023 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DC2EE2397B for ; Thu, 20 Jun 2013 11:32:48 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id bv4sf2260758qab.6 for ; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-beenthere:x-forwarded-to:x-forwarded-for:delivered-to:to:from :date:message-id:in-reply-to:references:user-agent:mime-version:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:x-google-group-id :content-type:content-transfer-encoding; bh=8e2Zvc6b30FjOJP+UbALx8DCssYfXngnjSrMdqEsblo=; b=OEYzqrTIHBW/xa51fuWpRdLmsQ2z7YPJ8d//TGg7BFrzXPMezqxhgKGpFzwqHCS5u5 CJoyjbvALjNJeU1x48EaFCL5GObmiQ5jCEXVQdIl88wzvr5q72f27VXwhUOJJSckXTgt h4MsHefco2YU5GAPbSSjWG+GjJ60BNog3aAUUfhws2syBy8F93qilGe1m8WzFIeMJhVq nBf77mOiPnAy+Gf+WOnj1maIejg/hUQNghUyxGr/v5m8q9wIQJ8e9+0YZTMIzZvz1Ojp 3O30HCemqHfkA2lzPls9S4KguG1tfUFLbCC4rTLU//4Ke57CICWBvathcQdt8zyavF7e TDsg== X-Received: by 10.236.32.229 with SMTP id o65mr4056204yha.19.1371727968710; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.73.137 with SMTP id l9ls642721qev.0.gmail; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) X-Received: by 10.52.68.212 with SMTP id y20mr2373691vdt.15.1371727968502; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id u10si3103861vcj.128.2013.06.20.04.32.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Jun 2013 04:32:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id hz11so4622083vcb.24 for ; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) X-Received: by 10.58.187.232 with SMTP id fv8mr2828403vec.50.1371727968413; Thu, 20 Jun 2013 04:32:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.165.8 with SMTP id yu8csp17357veb; Thu, 20 Jun 2013 04:32:47 -0700 (PDT) X-Received: by 10.180.20.208 with SMTP id p16mr5133850wie.59.1371727965037; Thu, 20 Jun 2013 04:32:45 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id hs8si2632710wib.15.2013.06.20.04.32.44 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 20 Jun 2013 04:32:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Upd6R-00043Q-MM; Thu, 20 Jun 2013 11:32:35 +0000 Received: from adelie.canonical.com ([91.189.90.139]) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Upd6Q-000431-09 for linaro-mm-sig@lists.linaro.org; Thu, 20 Jun 2013 11:32:34 +0000 Received: from lillypilly.canonical.com ([91.189.89.62]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Upd5U-00052G-V3; Thu, 20 Jun 2013 11:31:37 +0000 Received: by lillypilly.canonical.com (Postfix, from userid 3489) id E54BB26C2972; Thu, 20 Jun 2013 11:31:34 +0000 (UTC) To: linux-kernel@vger.kernel.org From: Maarten Lankhorst Date: Thu, 20 Jun 2013 13:31:30 +0200 Message-ID: <20130620113130.4001.45423.stgit@patser> In-Reply-To: <20130620112811.4001.86934.stgit@patser> References: <20130620112811.4001.86934.stgit@patser> User-Agent: StGit/0.15 MIME-Version: 1.0 Cc: linux-arch@vger.kernel.org, peterz@infradead.org, x86@kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, robclark@gmail.com, rostedt@goodmis.org, daniel@ffwll.ch, tglx@linutronix.de, mingo@kernel.org, linux-media@vger.kernel.org Subject: [Linaro-mm-sig] [PATCH v5 5/7] mutex: add more tests to lib/locking-selftest.c X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: linaro-mm-sig-bounces@lists.linaro.org Sender: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmQsPF4dIVOlb8/3ftWpnnL7NZyJmPvr0p35BqcbWRjrLlqg2F/6Nn01N3SaY3Q0gGfqTWO X-Original-Sender: maarten.lankhorst@canonical.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 None of the ww_mutex codepaths should be taken in the 'normal' mutex calls. The easiest way to verify this is by using the normal mutex calls, and making sure o.ctx is unmodified. Signed-off-by: Maarten Lankhorst --- lib/locking-selftest.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/locking-selftest.c b/lib/locking-selftest.c index 9962262..37faefd 100644 --- a/lib/locking-selftest.c +++ b/lib/locking-selftest.c @@ -1162,6 +1162,67 @@ static void ww_test_fail_acquire(void) #endif } +static void ww_test_normal(void) +{ + int ret; + + WWAI(&t); + + /* + * None of the ww_mutex codepaths should be taken in the 'normal' + * mutex calls. The easiest way to verify this is by using the + * normal mutex calls, and making sure o.ctx is unmodified. + */ + + /* mutex_lock (and indirectly, mutex_lock_nested) */ + o.ctx = (void *)~0UL; + mutex_lock(&o.base); + mutex_unlock(&o.base); + WARN_ON(o.ctx != (void *)~0UL); + + /* mutex_lock_interruptible (and *_nested) */ + o.ctx = (void *)~0UL; + ret = mutex_lock_interruptible(&o.base); + if (!ret) + mutex_unlock(&o.base); + else + WARN_ON(1); + WARN_ON(o.ctx != (void *)~0UL); + + /* mutex_lock_killable (and *_nested) */ + o.ctx = (void *)~0UL; + ret = mutex_lock_killable(&o.base); + if (!ret) + mutex_unlock(&o.base); + else + WARN_ON(1); + WARN_ON(o.ctx != (void *)~0UL); + + /* trylock, succeeding */ + o.ctx = (void *)~0UL; + ret = mutex_trylock(&o.base); + WARN_ON(!ret); + if (ret) + mutex_unlock(&o.base); + else + WARN_ON(1); + WARN_ON(o.ctx != (void *)~0UL); + + /* trylock, failing */ + o.ctx = (void *)~0UL; + mutex_lock(&o.base); + ret = mutex_trylock(&o.base); + WARN_ON(ret); + mutex_unlock(&o.base); + WARN_ON(o.ctx != (void *)~0UL); + + /* nest_lock */ + o.ctx = (void *)~0UL; + mutex_lock_nest_lock(&o.base, &t); + mutex_unlock(&o.base); + WARN_ON(o.ctx != (void *)~0UL); +} + static void ww_test_two_contexts(void) { WWAI(&t); @@ -1415,6 +1476,7 @@ static void ww_tests(void) print_testname("ww api failures"); dotest(ww_test_fail_acquire, SUCCESS, LOCKTYPE_WW); + dotest(ww_test_normal, SUCCESS, LOCKTYPE_WW); dotest(ww_test_unneeded_slow, FAILURE, LOCKTYPE_WW); printk("\n");