Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp31152ybh; Mon, 20 Jul 2020 09:35:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0KDio7jId3VagaFI7hKAPAL83yKL3M/RYwzy2e+GnhPIWP1mWV4aNfFf3y5LeiqQqEvVx X-Received: by 2002:a50:8e53:: with SMTP id 19mr22832025edx.185.1595262939624; Mon, 20 Jul 2020 09:35:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595262939; cv=none; d=google.com; s=arc-20160816; b=YbzNvNWP8j83ED/tQiWtuaRB5VQwTiVTR5EnJ1wEVgt4sxAU0C/0G68fu5oCYiwwmU 0Umw/KEi6M0cgqx2B2ul6eonXR2rt6aMI2jka9w1ipe4lGlFh6/BQvz9hqbINJqT7kEE 1WmcjI9KdDCzKa+O6Rf6mQHWHqZYvA1ptzIAyFCC8/QAplx0VujAivWc32a6pdgtibXD X7mv9XZcemJ2pBbOhgDO+0RR0RQtDVmepTAJFNhLeqBPhDJy+kr1L9QowvKhX3astWXH uIsXhDOi2oCZPFvzz6opQ1xrVNQUQso7kHfgYuxTGfnxbh91tWn4B++xjbBx3Noi50wn LGlA== 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=u8dxK0yYYZ2TmdZueYqwzVlsb3EwKsvtatP/Xk9jtMk=; b=J4CQVmzVtzF+8rj7roceREC7JEiAKS/TMuJBEOpzOSnWhIMtoOhat2VLaPxtnzjghW kiBckWhaM7pZI557BeUiJjOiu6g0+fQCPlCZx5aGV0inRA9hWzenp20kgrt/CiX3TUMv +PgcYD9vZq62nFtjjpzNhO36DiQ60xzitMLAJo60zIoKQx6HfTPbHt9TvWj6rnvvO2FS w8c2OowqiLmSLQ6k8ZIAoRnU6tCUmU/2x5tRVNEEA3VT1MsP8fXnLT1/XHWVoxLPTEUW RhPkj6NBpM2HWySVwUDTeQezOR8N7RCdwO8BNYV4MfJYEwTgAkCRRA877rVpCclcrKzG 9zkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=dc7urap3; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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 z13si10199559ejc.295.2020.07.20.09.35.17; Mon, 20 Jul 2020 09:35:39 -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=dc7urap3; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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 S2388769AbgGTQbw (ORCPT + 99 others); Mon, 20 Jul 2020 12:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731251AbgGTP5J (ORCPT ); Mon, 20 Jul 2020 11:57:09 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B319C061794 for ; Mon, 20 Jul 2020 08:57:09 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595260628; 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=u8dxK0yYYZ2TmdZueYqwzVlsb3EwKsvtatP/Xk9jtMk=; b=dc7urap3yvHuZhPsL/67K/n3FtxXJ/aPt04GyjFsl4IZJtOdPIdsLUe8pHl+n5IghMHhMV u8lTTWweg7jogoTmIkSCBrLHf4BS1wX7tSXtgzSS54Ns3y9qTk5k+iUX53T4GUYqXxJg6i MDOK6XSRvRYv5DSQ7x0r8Qer2LVigwRVM103OOXF7naomiZ2DeHFaJOkw7kXaD6ftv1DE7 bssi8t02hE2/fimi7fMmANrX2WQdtGWj0LzuBv2RMaIN/sU1amY2Zzs+hQTk2tA4EnxDiq OrcwR1MiJ8vCYS3DdivOhYE4N5pWABkLzQZU5k3c3HksiSJvOrlEmGaceuoymg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595260628; 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=u8dxK0yYYZ2TmdZueYqwzVlsb3EwKsvtatP/Xk9jtMk=; b=fBBCXzrf8tqAAmIAhpByHL7L93QgpN13azazim0BD4wXDwOmwejjBdArYwBrUtXwFovGqi UNtJT7iVFACx+lAQ== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Daniel Wagner Subject: [PATCH v4 20/24] iocost: Use sequence counter with associated spinlock Date: Mon, 20 Jul 2020 17:55:26 +0200 Message-Id: <20200720155530.1173732-21-a.darwish@linutronix.de> In-Reply-To: <20200720155530.1173732-1-a.darwish@linutronix.de> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200720155530.1173732-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 Reviewed-by: Daniel Wagner --- 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