Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp966738ybk; Wed, 20 May 2020 17:12:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyepS9HhmCf54DvU49wvdGfFY6vYATZC8cUI1FGP51GdApAVXPV2Utr/KE1/GltANgaqqsz X-Received: by 2002:a17:906:c7d1:: with SMTP id dc17mr1477538ejb.166.1590019970246; Wed, 20 May 2020 17:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590019970; cv=none; d=google.com; s=arc-20160816; b=eJ4fTyVGkpKGewwrnyWl42+6xDOiFQQI4KWNXvxHLJYh52qceOpZb3cgna9DQXPXvF Z2YUioTMQlBVnkCgCCBQFZbAzyHF3+Z8RJEVWFUXHyxdtFgERAqrRTz2hzqx0s0cgOfL dwjE68gfWR/vtAtlax5x2tSaWF25a7/vHR4yHk5fFHW0SmV5N1VAEfUfuRG3xIB0TIeX l+vPcIHXlEhyEwberZh4PGr1Rb37XzKeWIi1I6sVAYikR8peQU3QbunStYGi5tWJrXIe VVJnnFls+dp6V7ocaatm6LshIlF4ubs52SObKqNN0cixHtB84itBPcAyFX2CuVURgsml NZEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=WRUJAeV8lcl1Az9u9r/V2fo86GrpsuuGv72nS1KyOeA=; b=SIrPjz6tW+P8pqODNtD1dQkbc0xoAquZf7xS/xQhW5qiJwylIk8vv6r+unux4xArQH KOWEEIbsNF0XOC/qpjc7rWiKoS4EqllFcARinyuGxr6fWzPKK/6ycaXEtdCmbq7HZw2G jmyiITLzmgKPrHSedSKScTz4QTzJoivHKj+mUUePO/tkGgqXmQG55Hq4dq2v3uZckv19 umoOyaXCJP5JeypfkVTFB3/USChmlJR3Fy5xV0Mlyxw8Wq1X3KhHJ3PWm6Vaw8Ocplxq TC0wow2A/a+Nhy6PTWz+Faw705YQz06MD+H0NHynPfCkWGCVi+CslCfaW6L4YIenpbUi Jvng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si2454642ejr.357.2020.05.20.17.12.13; Wed, 20 May 2020 17:12:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726799AbgEUAKT (ORCPT + 99 others); Wed, 20 May 2020 20:10:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726619AbgEUAKS (ORCPT ); Wed, 20 May 2020 20:10:18 -0400 Received: from Galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AD09C061A0E; Wed, 20 May 2020 17:10:18 -0700 (PDT) Received: from [5.158.153.53] (helo=debian-buster-darwi.lab.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1jbYmC-0006mO-Af; Thu, 21 May 2020 02:09:32 +0200 Date: Thu, 21 May 2020 02:09:30 +0200 From: "Ahmed S. Darwish" To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , "David (ChunMing) Zhou" , amd-gfx@lists.freedesktop.org, "Paul E. McKenney" , David Airlie , "Sebastian A. Siewior" , LKML , Steven Rostedt , Christian =?iso-8859-1?Q?K=F6nig?= , dri-devel@lists.freedesktop.org, Daniel Vetter , Alex Deucher , Felix Kuehling , Thomas Gleixner , Sumit Semwal , linux-media@vger.kernel.org Subject: Re: [PATCH v1 13/25] dma-buf: Use sequence counter with associated wound/wait mutex Message-ID: <20200521000930.GA359643@debian-buster-darwi.lab.linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200519214547.352050-14-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2020, Christian K?nig wrote: > Am 19.05.20 um 23:45 schrieb Ahmed S. Darwish: > > A sequence counter write side critical section must be protected by some > > form of locking to serialize writers. If the serialization primitive is > > not disabling preemption implicitly, preemption has to be explicitly > > disabled before entering the sequence counter write side critical > > section. > > > > The dma-buf reservation subsystem uses plain sequence counters to manage > > updates to reservations. Writer serialization is accomplished through a > > wound/wait mutex. > > > > Acquiring a wound/wait mutex does not disable preemption, so this needs > > to be done manually before and after the write side critical section. > > > > Use the newly-added seqcount_ww_mutex_t instead: > > > > - It associates the ww_mutex with the sequence count, which enables > > lockdep to validate that the write side critical section is properly > > serialized. > > > > - It removes the need to explicitly add preempt_disable/enable() > > around the write side critical section because the write_begin/end() > > functions for this new data type automatically do this. > > > > If lockdep is disabled this ww_mutex lock association is compiled out > > and has neither storage size nor runtime overhead. > > Mhm, is the dma_resv object the only user of this new seqcount_ww_mutex > variant ? > > If yes we are trying to get rid of this sequence counter for quite some > time, so I would rather invest the additional time to finish this. > In this patch series, each extra "seqcount with associated lock" data type costs us, exactly: - 1 typedef definition, seqcount_ww_mutex_t - 1 static initializer, SEQCNT_WW_MUTEX_ZERO() - 1 runtime initializer, seqcount_ww_mutex_init() Definitions for the typedef and the 2 initializers above are template-code one liners. The logic which automatically disables preemption upon entering a seqcount_ww_mutex_t write side critical section is also already shared with seqcount_mutex_t and any future, preemptible, associated lock. So, yes, dma-resv is the only user of seqcount_ww_mutex. But even in that case, given the one liner template code nature of seqcount_ww_mutex_t logic, it does not make sense to block the dma_resv and amdgpu change until at some point in the future the sequence counter is completely removed. **If and when** the sequence counter gets removed, please just remove the seqcount_ww_mutex_t data type with it. It will be extremely simple. > Regards, > Christian. > Thanks, -- Ahmed S. Darwish Linutronix GmbH