From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D07C433DF for ; Tue, 30 Jun 2020 05:46:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2670120672 for ; Tue, 30 Jun 2020 05:46:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="pvp96H4i"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bubS8uRO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730008AbgF3FqW (ORCPT ); Tue, 30 Jun 2020 01:46:22 -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