Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3315852ybt; Mon, 29 Jun 2020 22:49:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYl89mhWrmxnntrviSrTkKD0H1U3J3oppi7wUFhyKAK1iDaQFYytX22Zj8jzyV3WTKGfnl X-Received: by 2002:a50:bec2:: with SMTP id e2mr22077396edk.3.1593496195152; Mon, 29 Jun 2020 22:49:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593496195; cv=none; d=google.com; s=arc-20160816; b=ml7B6tNw5jALbQx2J66LhMfzKiLXGhwoKtglPtgEO+ZtQ2VlLodjbiQd5D7Nx+nyU8 9KkmoijNMHfOJjUiSrSSqjIXLvSd48tzb9tD31SrmEPv1BwCaoS4DvaViT0TwBU69JAa sjI0Kgd4oKpNG2q2Jr0E7PO1TLuDyQr0Mp6Pu+Zk+zvbtJgGOmOmDyAyTWlKFhoPjv6E JCTuPt2s77ufhEJxkXyrxHEJmWvA2UziH9ByBuZQyS9UqMuRwv/9SekYbkoP9KVhmQDN VWOuOPxInXRZlUXu3OiKmhhNMkA6+/JiilH7xi7NwNQPNzYxFuZ//68emew4Evaj4Pth CqCw== 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 :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=vfYSUZS8JZq7HVay19OnCOeM8/mTHwEIgTvq+ENWzMI=; b=QGfyz3C3Uv5e9UxxKonMZQcv2tgKHe5KkDtwp/t3Hk1TZzIt/MyFsI7PcTAcYpG/A1 EcqLPGy2DK3HYutTeL+e+aop5APNCkn8HhKlcJOzCV0VxVvJSEE0CqmxoLrWKAysEIbo IXdenoDEpQuBKxJMS9uhb8eM8zAg3LZFWEIk6rA31PkNgNjBJnhzllC6lW8Ck6D1ZDco 5wU8fftcZ7lb3J2d4sfotVm4MbW6K/vRZWIO3FWNlgz8q3qgSdk1Rb5MzVnOWWlOwg7g KbLLp3zVxRRBjS6w3GgSoJafFo44Pv4Chg6m+bEKmiKx4CJj7FNquH39uL1QGSj6PgaA tUcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pvp96H4i; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=bubS8uRO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds16si1542938ejc.112.2020.06.29.22.49.32; Mon, 29 Jun 2020 22:49:55 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pvp96H4i; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=bubS8uRO; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbgF3FqV (ORCPT + 99 others); Tue, 30 Jun 2020 01:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729811AbgF3FqS (ORCPT ); Tue, 30 Jun 2020 01:46: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 E8AB5C061755; Mon, 29 Jun 2020 22:46:17 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593495974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vfYSUZS8JZq7HVay19OnCOeM8/mTHwEIgTvq+ENWzMI=; b=pvp96H4iQqNONXW4zyWYZzvxi1jOlybOnNyCWu2riCBBYMbwf0ApWBSHmJuJUveUB6U9GX UMTNbHIHYs6GON3rEQkV2mBUAX7/XOfvg8O3UZ2nRBB2dA5DAShNRylOZYLjv7U33WYT7J F/BRVCPSOBzjGQkZIJS3XydlncswTLb0YKs9yHVO9Bf1VmJpi3W7kIHdvPYIY9hg07kePP Jv0U/Z1gjOiyr8T+k82QWvh+eQeknAjDftyu9fM3wknrVv16BNikn16OmkHZrogeMhzBD5 GWksKGwAeNNFUwyggz9V1j1iyH7whyZSRBr3Nrv8SWRkgZe6ymnFmq7+RHG1tA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593495974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vfYSUZS8JZq7HVay19OnCOeM8/mTHwEIgTvq+ENWzMI=; b=bubS8uROJrXnhzhr5fH8WHY2+wNeGelizK4c4jDcoCej4j/YkrRrRRjw9edPLPSmPW7ytA 2ZtBSo6QOIsXANCw== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Jens Axboe , linux-block@vger.kernel.org Subject: [PATCH v3 16/20] iocost: Use sequence counter with associated spinlock Date: Tue, 30 Jun 2020 07:44:48 +0200 Message-Id: <20200630054452.3675847-17-a.darwish@linutronix.de> In-Reply-To: <20200630054452.3675847-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200630054452.3675847-1-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A sequence counter write side critical section must be protected by some form of locking to serialize writers. A plain seqcount_t does not contain the information of which lock must be held when entering a write side critical section. Use the new seqcount_spinlock_t data type, which allows to associate a spinlock with the sequence counter. This enables lockdep to verify that the spinlock used for writer serialization is held when the write side critical section is entered. If lockdep is disabled this lock association is compiled out and has neither storage size nor runtime overhead. Signed-off-by: Ahmed S. Darwish --- block/blk-iocost.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 8ac4aad66ebc..8e940c27c27c 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -406,7 +406,7 @@ struct ioc { enum ioc_running running; atomic64_t vtime_rate; - seqcount_t period_seqcount; + seqcount_spinlock_t period_seqcount; u32 period_at; /* wallclock starttime */ u64 period_at_vtime; /* vtime starttime */ @@ -873,7 +873,6 @@ static void ioc_now(struct ioc *ioc, struct ioc_now *now) static void ioc_start_period(struct ioc *ioc, struct ioc_now *now) { - lockdep_assert_held(&ioc->lock); WARN_ON_ONCE(ioc->running != IOC_RUNNING); write_seqcount_begin(&ioc->period_seqcount); @@ -2001,7 +2000,7 @@ static int blk_iocost_init(struct request_queue *q) ioc->running = IOC_IDLE; atomic64_set(&ioc->vtime_rate, VTIME_PER_USEC); - seqcount_init(&ioc->period_seqcount); + seqcount_spinlock_init(&ioc->period_seqcount, &ioc->lock); ioc->period_at = ktime_to_us(ktime_get()); atomic64_set(&ioc->cur_period, 0); atomic_set(&ioc->hweight_gen, 0); -- 2.20.1