From patchwork Mon Nov 28 12:20:11 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: 9449471 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 49EB0600CB for ; Mon, 28 Nov 2016 12:20:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A5F320453 for ; Mon, 28 Nov 2016 12:20:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EA6627BFF; Mon, 28 Nov 2016 12:20:50 +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 126A720453 for ; Mon, 28 Nov 2016 12:20:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45CEE6E2CF; Mon, 28 Nov 2016 12:20:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C0B36E2BD for ; Mon, 28 Nov 2016 12:20:33 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id m203so18632158wma.3 for ; Mon, 28 Nov 2016 04:20:33 -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=dW3DKK26peb8iO5TF17VK8ZP1GVo8IqnhkGzDJtNhTlVEwWNsnc5VUbk0vhczivC0l ErJly76DBF1otThkakhzoJeLtjK3+LNdZfe06UtXoq0F8c2Sb2OhKClC/Sv4JywGLZs4 8/q+dPatuJFqiL+reNJi3+tSVC2n9Wl1h3OZGMVZOWvNv0zmnSqOqxNBOmnb2Mugm1dQ PJTc9m/lW6Vb4ENeuxdZPO8pntbY9vV3QE8BPEgRycZtojWRkHRHL0R9dMOETVsRHIWu 6/eb2GtyLI5VZMMs+OSjhyeE1DSZCeod6FFXPLpygN0VXpO0oSi+c53zmhRoPAvn5zq7 CprA== 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=OiE3/PILP7njj+O53f6Y/wMEKjH+lxfyHPEQYT23IEAmFVwRlYSVUzh5+p2vQN0L4x jhsRD7LZKKnEoCrdJD+9/Hvw7mulnNvcIEUNsFEvu+cdqqVVPzueIoxSQOYUG2Rlt/6R juzjPiwI+V+tcYi+GortVjkrlenzHF4fjtR51Nvddxx2tLKNfLVnDv/soQgMA5iW14R3 xep+MVOtzxZMkRjtdAlrw0f6FMoWa5qsxfTPPy3rf+42afnA6B6r8E48nIRX7lfMaW2X 79k2fjgbmItghO1wpWRx4iQP4EmdtgM1S0vMkEampj2OjlHkMhwSvZ4KZdaKfoSgNMAk P7dg== X-Gm-Message-State: AKaTC0380exYGRWaTYTHI2RDrZkqbtSSE1PwI0UFSAOofa0ghKIsLm1xXwnLd1p+4ql3Qg== X-Received: by 10.28.21.1 with SMTP id 1mr20708435wmv.133.1480335631780; Mon, 28 Nov 2016 04:20:31 -0800 (PST) Received: from cassiopeia.fritz.box ([2001:a61:1119:dc01:d88b:9432:f601:27ed]) by smtp.gmail.com with ESMTPSA id a13sm28830511wma.18.2016.11.28.04.20.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Nov 2016 04:20:31 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: linux-kernel@vger.kernel.org Subject: [PATCH 10/11] Documentation/locking/ww_mutex: Update the design document Date: Mon, 28 Nov 2016 13:20:11 +0100 Message-Id: <1480335612-12069-11-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480335612-12069-1-git-send-email-nhaehnle@gmail.com> References: <1480335612-12069-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