Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2456635imd; Fri, 2 Nov 2018 11:43:22 -0700 (PDT) X-Google-Smtp-Source: AJdET5eIcwixwID7b1+TPn9azWmIXI5i3qjJZRHml7rzlzsqoALEufk3WVnqWYfAlUMrAR+oGcMI X-Received: by 2002:a62:cac4:: with SMTP id y65-v6mr12748365pfk.27.1541184202896; Fri, 02 Nov 2018 11:43:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184202; cv=none; d=google.com; s=arc-20160816; b=D1505dF2UHZA+37PNzbjxYFYIhTEkGop1f0nZRy/yJi/Mvm1835KO/55l06ISH1K4S fncPQ4i4VKEYCDrk6674kjFFo/+9AA5/ST3oIi95BxnWcA7jSA3OzDm2B0Pxnr8gymXP dUk1HsVN02ONnY29Yr0cIBy7Qog1fn8CEKbgEDY+O06byu8E1RbD9/xDqpzdAD5r4Jrs wjYhM6kllcKsES16WBgu34RzEShn0cmD6f2D+8lHAB5LYtOE3DaqYm6rSREfcMiNgUbq niM+YFixUcXqIjYg4O6tK0a014sZ9aYgD/v7nclcahlVrb3/AqUAnF0LEWKNNTgHa7Pl 42gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=piyxkZJlPklkNr+mZxJAv256ZZuviFhMcMsueVgRXo0=; b=BoLGS6l4AQJkN2Mc5iZC/vOVKRhqzWkGzNKSs7ZO9tVsFYMuqq2HneZTFND4rgjJoh iwZK2LU/aW6AF8a8t52Wa+J5mJBDinf1uqKvuxy5xDwddDUbJNulV/nB00/KFKbVJU6H NKIwJQ0INO2tuELxKikPAgKi5FQB+44lVgMPa3TPmwC9VefDhwGIv2L8FBE7Vi+3upoG sKvffhgnXSlIvJ5so2Mzhnow4TxyVrud5V7sXTdSLXeFNGGwxN2alibn5b6TCiRbRhBg ugPm8gS0LrMuaTi7eFqsgvOo9F0a3E2b6EwfOHSpOquPDXD+X5h8sgkqTM3R0YlmsFi/ rp5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Q4qh4ul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w33-v6si30486315pga.590.2018.11.02.11.43.07; Fri, 02 Nov 2018 11:43:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0Q4qh4ul; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729460AbeKCDtE (ORCPT + 99 others); Fri, 2 Nov 2018 23:49:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:43552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728578AbeKCDtE (ORCPT ); Fri, 2 Nov 2018 23:49:04 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37E8D20847; Fri, 2 Nov 2018 18:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184051; bh=kOxteSRExmDSkUY1c9uqI60AZ9Uuvd7Sze2JYVlaXvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0Q4qh4ulA+Hgq/AXlnIdpHO2xFptRFX+vfEchixRrIbqvdqqYUZ63OipQLXRVZlK0 6xCHkqWKMOBf/eHgt9NzOmzpvCnSuxiKtp8oAUVQcirk62Xcci4NcgjgQdExSJ9gzd cd/+fwXvYIuSnHamxrLO/Tv1gQ5Rp6kkeGk5Q2VA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guenter Roeck , Chris Wilson , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Will Deacon , Ingo Molnar , Sasha Levin Subject: [PATCH 4.18 064/150] locking/ww_mutex: Fix runtime warning in the WW mutex selftest Date: Fri, 2 Nov 2018 19:33:46 +0100 Message-Id: <20181102182908.079653218@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e4a02ed2aaf447fa849e3254bfdb3b9b01e1e520 ] If CONFIG_WW_MUTEX_SELFTEST=y is enabled, booting an image in an arm64 virtual machine results in the following traceback if 8 CPUs are enabled: DEBUG_LOCKS_WARN_ON(__owner_task(owner) != current) WARNING: CPU: 2 PID: 537 at kernel/locking/mutex.c:1033 __mutex_unlock_slowpath+0x1a8/0x2e0 ... Call trace: __mutex_unlock_slowpath() ww_mutex_unlock() test_cycle_work() process_one_work() worker_thread() kthread() ret_from_fork() If requesting b_mutex fails with -EDEADLK, the error variable is reassigned to the return value from calling ww_mutex_lock on a_mutex again. If this call fails, a_mutex is not locked. It is, however, unconditionally unlocked subsequently, causing the reported warning. Fix the problem by using two error variables. With this change, the selftest still fails as follows: cyclic deadlock not resolved, ret[7/8] = -35 However, the traceback is gone. Signed-off-by: Guenter Roeck Cc: Chris Wilson Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Will Deacon Fixes: d1b42b800e5d0 ("locking/ww_mutex: Add kselftests for resolving ww_mutex cyclic deadlocks") Link: http://lkml.kernel.org/r/1538516929-9734-1-git-send-email-linux@roeck-us.net Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- kernel/locking/test-ww_mutex.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/locking/test-ww_mutex.c b/kernel/locking/test-ww_mutex.c index 0e4cd64ad2c0..654977862b06 100644 --- a/kernel/locking/test-ww_mutex.c +++ b/kernel/locking/test-ww_mutex.c @@ -260,7 +260,7 @@ static void test_cycle_work(struct work_struct *work) { struct test_cycle *cycle = container_of(work, typeof(*cycle), work); struct ww_acquire_ctx ctx; - int err; + int err, erra = 0; ww_acquire_init(&ctx, &ww_class); ww_mutex_lock(&cycle->a_mutex, &ctx); @@ -270,17 +270,19 @@ static void test_cycle_work(struct work_struct *work) err = ww_mutex_lock(cycle->b_mutex, &ctx); if (err == -EDEADLK) { + err = 0; ww_mutex_unlock(&cycle->a_mutex); ww_mutex_lock_slow(cycle->b_mutex, &ctx); - err = ww_mutex_lock(&cycle->a_mutex, &ctx); + erra = ww_mutex_lock(&cycle->a_mutex, &ctx); } if (!err) ww_mutex_unlock(cycle->b_mutex); - ww_mutex_unlock(&cycle->a_mutex); + if (!erra) + ww_mutex_unlock(&cycle->a_mutex); ww_acquire_fini(&ctx); - cycle->result = err; + cycle->result = err ?: erra; } static int __test_cycle(unsigned int nthreads) -- 2.17.1