Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1443ybh; Mon, 20 Jul 2020 09:00:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyB8zh3p8OoWgi5fsDqb8oNEmRQfo8Qa0EfhhMpeYbgiF3liPHTiq7MqBxI7GIPMpdd/buw X-Received: by 2002:a17:906:355b:: with SMTP id s27mr22496779eja.368.1595260810108; Mon, 20 Jul 2020 09:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595260810; cv=none; d=google.com; s=arc-20160816; b=QLv1LfngbGEIu5CMnuy7E6+1Kh26nIvmUOulg1gsjzgAvVVYLbrntNd0mJg0Nspb+i QrbATFtVU4vyN41LyXXJmIlhKIES2OdPVCLEEGF5vI1r1yNg/5JWKzEbqsI0LvwumLkw yNI5QjxVZSGLI3FBV0rBVjkklm9JkOkIz9Dge1peEHSF9mjVET47HdhngMFKaHdiH/Vv pk7Ue5IQP3wbeUM4TcrYnTTPSxDwK1D/xMJl4SUi/eNLpthspwLvJJQAjFqkLSd+Ssza ItJV+Ttwj+lV2fGYzsRjw+DawQYT4W6nLNBoKO+v/zomsXpr6POmMA9rRJ9gLmwj4Nl6 f6EA== 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=xAbB9oKLEGHYN+w+z0ndpRUVlVFavwl3/3bbk6nkTI4=; b=rP5lEiC6tNjVIrQE0zISBVfaPvZLVM8zmFswQKN3wf2BUaqNp/8GOTx2+H3/NTdkeE LL049JdIf7BTrjPuAGvc8B90kedCucYusQVFTzDJLjFB5rQUE+ztjN86uYVxopyx3pZI MDuutJZgCxpRTlcCLC/PmmK+EwsHPjMkjcbWXDk+tf/AJbuDv1R3Dcnz9YNGcx9dii9d FWMAWDmF8NB0vsAMnGrFgKpIXtpo5cu9zN4zNqQaUm8S68gEKLNP6FcI2bUEy8xqk3Ch qkgrfH2Hcd8vTzRDx/rgwXwlLWxMTsW6FGRU5iaZh85MYj9mASYlE56t06B0VzHlcCgh 71YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aE6HVWQ7; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=8sQVdjG9; 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 mm15si9994581ejb.561.2020.07.20.08.59.23; Mon, 20 Jul 2020 09:00:10 -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=aE6HVWQ7; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e header.b=8sQVdjG9; 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 S1730824AbgGTP5T (ORCPT + 99 others); Mon, 20 Jul 2020 11:57:19 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58948 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731865AbgGTP5F (ORCPT ); Mon, 20 Jul 2020 11:57:05 -0400 From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1595260623; 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=xAbB9oKLEGHYN+w+z0ndpRUVlVFavwl3/3bbk6nkTI4=; b=aE6HVWQ7elJ3Wu43Nx5S0EQ9uUnwoWtplV7pqe9NN1rsZuauKrP9qAmb6mHlhJ7U1sFSgw AxExVzSlqPCo7f2hJBEUQ9fxPD9kfIMD9fn/jzMWs+qYfqBdFwIBDMFtaR+nroor6T2IO7 B/lq1xpYO7qfSDgiEwK/u5bUU4jAo1f4liQajoKBqfgyKSWxKOhglHIcUJDJ/uovzhkW3t /r/U3lkl0ScjCT828osOd2wnToGbfvCzbQjnfJFcm9G20jbVFIei/qonANgpXdfibLORrG LXIwwdJ69ykwevM0BHecoxt3L9lD15kOCm2dUBPivw0BpPHrBTBCvQOtdWMd2Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1595260623; 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=xAbB9oKLEGHYN+w+z0ndpRUVlVFavwl3/3bbk6nkTI4=; b=8sQVdjG9J9NWk5nP1uFu8LkSAunXaXDWeXbROR0vV/v1xYMoVS1qTisuyD7tE97Y+Dlut3 5SAPGx+i1aRtshCQ== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Song Liu , linux-raid@vger.kernel.org Subject: [PATCH v4 19/24] raid5: Use sequence counter with associated spinlock Date: Mon, 20 Jul 2020 17:55:25 +0200 Message-Id: <20200720155530.1173732-20-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 --- drivers/md/raid5.c | 2 +- drivers/md/raid5.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index ab8067f9ce8c..892aefe88fa7 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -6935,7 +6935,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) } else goto abort; spin_lock_init(&conf->device_lock); - seqcount_init(&conf->gen_lock); + seqcount_spinlock_init(&conf->gen_lock, &conf->device_lock); mutex_init(&conf->cache_size_mutex); init_waitqueue_head(&conf->wait_for_quiescent); init_waitqueue_head(&conf->wait_for_stripe); diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index f90e0704bed9..a2c9e9e9f5ac 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h @@ -589,7 +589,7 @@ struct r5conf { int prev_chunk_sectors; int prev_algo; short generation; /* increments with every reshape */ - seqcount_t gen_lock; /* lock against generation changes */ + seqcount_spinlock_t gen_lock; /* lock against generation changes */ unsigned long reshape_checkpoint; /* Time we last updated * metadata */ long long min_offset_diff; /* minimum difference between -- 2.20.1