From patchwork Wed Dec 21 18:46:40 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: 9483659 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 062F3601D3 for ; Wed, 21 Dec 2016 18:48:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF0FD27D85 for ; Wed, 21 Dec 2016 18:47:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3FD427F9E; Wed, 21 Dec 2016 18:47:59 +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 A460927D85 for ; Wed, 21 Dec 2016 18:47:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2C69E6F0DC; Wed, 21 Dec 2016 18:47:56 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wj0-x242.google.com (mail-wj0-x242.google.com [IPv6:2a00:1450:400c:c01::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id AFBDF6ECAC for ; Wed, 21 Dec 2016 18:47:02 +0000 (UTC) Received: by mail-wj0-x242.google.com with SMTP id hb5so120123wjc.2 for ; Wed, 21 Dec 2016 10:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GgFXtklTpb40XzmCZBlE0OIhgNXt93pE1PisfSrrpWg=; b=ckhoCI0QLprgWrKFa+08C3BDFg5uW+zvFDS5H1L+PKK2dS7Pid4L3+BVAEILevwISU Yg5w7XUCUC1G9kkldQ+UaQZe+1qTlMcRnygHdVGy3k65v0hUXnQyN2yhknuWc0aPRwun FU+qM3J0KomlVT98v9CHQrBHAow5qJkN91OjTq1KEBnYwqwmndTJMEBrIrJneDuAlOu+ HJvXJaQmM2FXn3otnKQ8GklybBk/YXoLeTF+2ibf3X88e6U4Z7P+B+RPCmZFiHoa9O0X zflMVxsOMlUy1jVrcwYYfGP78fV8KzU62KUbGpYch4/0m7/xFEM2zpUcAA4GdTyEu3Or lZJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GgFXtklTpb40XzmCZBlE0OIhgNXt93pE1PisfSrrpWg=; b=IFJijOqgUNOK8OmkQ1SCzzN5lga3P9SEadxc1G2luN7eAdixAEwNCyAFw8cVuHMXZE 22GMJJsSl2I5P0JWFOUGZj6aRV91nQlxlAis/kfZxBFVBmMZLYPwKP367uLmzducTOlG LNxOvVFZqhxzfFkmh+4Ak9dvyVmucoT10Mo7vBA/0HHXSRS197h+8n1opL02OVwYrV8i YTo7bOJIJ0U0Yw+A8fQt5zb/71CosLn4lkR1DXJkfD3xh82Jk1yf5UWYxJp8g+W+HxWV eJXaCfaFdeZOqlCL/J0XVW3WXe+qsCwLHoAKKlQhDrcQllS4uciBf4CtCKryKH1H1Zo/ bKKQ== X-Gm-Message-State: AIkVDXISN8GDMOMckmVkba3F5anpcqOPqidEGZhSdSY6llOXlJp/eEnID+j+lt2je7PuHg== X-Received: by 10.194.9.8 with SMTP id v8mr5942802wja.140.1482346021038; Wed, 21 Dec 2016 10:47:01 -0800 (PST) Received: from cassiopeia.fritz.box ([2001:a61:110a:1701:2511:6687:1ba5:b45b]) by smtp.gmail.com with ESMTPSA id ke6sm31840526wjb.21.2016.12.21.10.46.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Dec 2016 10:47:00 -0800 (PST) From: =?UTF-8?q?Nicolai=20H=C3=A4hnle?= To: linux-kernel@vger.kernel.org Subject: [PATCH v3 12/12] Documentation/locking/ww_mutex: Update the design document Date: Wed, 21 Dec 2016 19:46:40 +0100 Message-Id: <1482346000-9927-13-git-send-email-nhaehnle@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482346000-9927-1-git-send-email-nhaehnle@gmail.com> References: <1482346000-9927-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