From patchwork Thu Dec 1 14:06:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Nicolai_H=C3=A4hnle?= X-Patchwork-Id: 9456245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5608E60235 for ; Thu, 1 Dec 2016 14:07:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C6B284E2 for ; Thu, 1 Dec 2016 14:07:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3EDCD284E4; Thu, 1 Dec 2016 14:07:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F20AE284E6 for ; Thu, 1 Dec 2016 14:07:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9D3F6E816; Thu, 1 Dec 2016 14:07:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B76116E7F6 for ; Thu, 1 Dec 2016 14:07:13 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m203so34329402wma.3 for ; Thu, 01 Dec 2016 06:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GgFXtklTpb40XzmCZBlE0OIhgNXt93pE1PisfSrrpWg=; b=EoWtcS9Qy3eX5Hj8QdFkWxKMsPkveph34mfvA9+5szPA4fxbeCP3e8t5DXZjsZskq1 yOPGSFjxgwQMkobSmJeUx17o2zUs5fEuOoOp0Q4SQGcv9TXodYQr0jkiKELHomaE5WHn 9OMSQA8960RTFV6CVQy+APpTcA36YOon0YCfIWQ/l+wUxYE80AuUolLrwrBvCZjEc47I nAvPJ+mI9WYTzXzQuyII0l2CBM9LNsprzaf029cinzMCIae3+B1+U5eH2FfXl0Zo+BIt z51MMiTDEhGYpuf7HrDXTR5s6mTz12q6qBchi+IbZtOStgSNvCqQXJvKkmiUw/KGaIO7 F3wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GgFXtklTpb40XzmCZBlE0OIhgNXt93pE1PisfSrrpWg=; b=EZErYmhRG9d783sqz1n0kOjTR7AwpfzlsX+64jSfb5/57YykWlfL16kssdQEz1uMwW FGhcy2B99Ayx7S85pmOugd6TPbR1ZLnkUsVNw1DtV/UCi07N+DTuogf83jjwa0+ujOvk 0a+E72iURH120oaGbOwZsLQ1FH5FwXsuTNnQwV/iBdvYcpSwnHayqNXXNGrM1seHoGoX Zzz8aqAYqefT+g0IUbk3/d+fFb9GxzoLZvrFO40+ZQo3C9ZwpZ1oIV/pBsFQoGheNWj3 VOekMQUu1Hsc7bLJFLzD+KdcRbGlgkaByHD2+7Q8WfPrI2ovctVVcVOVUg9R23LTe8Wc FY9g== X-Gm-Message-State: AKaTC03nVLsXAQhgBszwk3ivY9JXk23leFQKIb2/nn+VsUy/osAWLwPzkzUonXdDaRUO0g== X-Received: by 10.28.22.193 with SMTP id 184mr34050257wmw.100.1480601232025; Thu, 01 Dec 2016 06:07:12 -0800 (PST) Received: from cassiopeia.fritz.box ([2001:a61:116e:7d01:dc12:8e88:ab9d:8694]) by smtp.gmail.com with ESMTPSA id vr9sm411514wjc.35.2016.12.01.06.07.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Dec 2016 06:07:11 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: linux-kernel@vger.kernel.org Subject: [PATCH v2 10/11] Documentation/locking/ww_mutex: Update the design document Date: Thu, 1 Dec 2016 15:06:53 +0100 Message-Id: <1480601214-26583-11-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480601214-26583-1-git-send-email-nhaehnle@gmail.com> References: <1480601214-26583-1-git-send-email-nhaehnle@gmail.com> MIME-Version: 1.0 Cc: Maarten Lankhorst , =?UTF-8?q?Nicolai=20H=C3=A4hnle?= , Peter Zijlstra , dri-devel@lists.freedesktop.org, Ingo Molnar X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Nicolai Hähnle Document the invariants we maintain for the wait list of ww_mutexes. Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Maarten Lankhorst Cc: Daniel Vetter Cc: Chris Wilson Cc: dri-devel@lists.freedesktop.org Signed-off-by: Nicolai Hähnle --- Documentation/locking/ww-mutex-design.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Documentation/locking/ww-mutex-design.txt b/Documentation/locking/ww-mutex-design.txt index 8a112dc..34c3a1b 100644 --- a/Documentation/locking/ww-mutex-design.txt +++ b/Documentation/locking/ww-mutex-design.txt @@ -309,11 +309,15 @@ Design: normal mutex locks, which are far more common. As such there is only a small increase in code size if wait/wound mutexes are not used. + We maintain the following invariants for the wait list: + (1) Waiters with an acquire context are sorted by stamp order; waiters + without an acquire context are interspersed in FIFO order. + (2) Among waiters with contexts, only the first one can have other locks + acquired already (ctx->acquired > 0). Note that this waiter may come + after other waiters without contexts in the list. + In general, not much contention is expected. The locks are typically used to - serialize access to resources for devices. The only way to make wakeups - smarter would be at the cost of adding a field to struct mutex_waiter. This - would add overhead to all cases where normal mutexes are used, and - ww_mutexes are generally less performance sensitive. + serialize access to resources for devices. Lockdep: Special care has been taken to warn for as many cases of api abuse