Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3314964ybt; Mon, 29 Jun 2020 22:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykEDAeVJGCE/KlGgw3+0Jbp3Now87tHcAV4y905w+sT39psUEUjSqwDEN12vfpwYBdl02a X-Received: by 2002:a17:906:3146:: with SMTP id e6mr8616210eje.2.1593496074797; Mon, 29 Jun 2020 22:47:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593496074; cv=none; d=google.com; s=arc-20160816; b=wNuUznh1qr/HKzOtqrev6MEb4gQhHBMtJJFXmA2KrM2TRBYYAe3g7uRL6eDK8yscSl KNQDr1S8afezxU0IqbJP2AKStxQH3K6i0FZau9M/2LQZ8GW1MbteatdAuDkNFq7ct/cx pqwzfEZtSvQMgSKMbtMQPqXMsFf61vqMwOxgCMLmsnvw2HZ+jTrixaqwdRPLYwaoq6zR GunxvdBf0ufu1mujUIWMzt6cfl6MnbCiIowAVa/rue+MQhmXPH9lt5ZpPNseh2lunZp+ PT8nXaRXT9zUzGOLJm0GNEm4E6E+e/eOTBpDPay+P/ppOkIlQt4b8r+cUjHWJl8P8sKa hc2g== 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=gjBiJEwyrXxSA52xQ4637SX/LhV+HHIgWPKRBeE4gMY=; b=F/rN9duEJLVwxRyjQYsz3b/80NdEnxFaVxkaq0Lnm5x+zGiWnoSFmVerCQMBZkM2r/ 29Y4Gy/rr0qUQ0tmKTDb/PZygTY+iz/P2jBKaTryfnBs0uxD4yJVkX6Cmsz2j20IvkT8 vY+9vS3zDeJ0oNjFpdfAOFrleNunM38WXaCgPTwPLc8FV6Yp73nqtqZvdgTZl+qZ/oQ8 9LTuKIPU85XX0HJxUIClFAiBBXEwSUbujC3FsCBsp2nAOXaSWI/w6rm3PKR2LMakdU6q 2gI/0Y5AL+uDiKX0RpbvxWQf2BFziRO+MbGbKREE+TADQmt1MDfcOiPx3H7h9szyX8WJ naLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=I+tmKUAq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=r6r5GCEm; 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 d23si1175455ejz.145.2020.06.29.22.47.32; Mon, 29 Jun 2020 22:47:54 -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=I+tmKUAq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=r6r5GCEm; 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 S1730014AbgF3FqY (ORCPT + 99 others); Tue, 30 Jun 2020 01:46:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730002AbgF3FqU (ORCPT ); Tue, 30 Jun 2020 01:46:20 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA80CC061755; Mon, 29 Jun 2020 22:46:20 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593495979; 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=gjBiJEwyrXxSA52xQ4637SX/LhV+HHIgWPKRBeE4gMY=; b=I+tmKUAq+Pvt5jsdEh47xaT4OPbIe99dTjhmu224FU1bpX+qmSUC8pU1qzsfASFh7maDSo Ja0hUJMoA+a1ft7YUBIKyOXkzA6HfkJ1/51oDaRUI8Pgc0rajNs15bujmgcKRg1jNcDCUB +VXtXLhE/DiVOqizW0iKlUl/HSZUa9SutKClRmIVV9oArPrZITgppcrUbo9KHrNRiBF2ss s9OkgRPGiK1r+Exy8sRK00AN8DZ3vPECOw4JAj9sbfSeYVswrc4jYdZysLW3VdFQsh3nJz oukdHSh4ml0ORhhzIKK+j5aUJtJsyvIrbY00YP8dzMIbfdEH0bbqIql3+7wcYw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593495979; 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=gjBiJEwyrXxSA52xQ4637SX/LhV+HHIgWPKRBeE4gMY=; b=r6r5GCEmfO0LFTWQOnHDPAfhuP7PFCEt73IQKSkULS9CIX3/frbNI9oIsGNwK6ZyaLrkFc fW0Rc32HysAQXyBg== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org Subject: [PATCH v3 17/20] NFSv4: Use sequence counter with associated spinlock Date: Tue, 30 Jun 2020 07:44:49 +0200 Message-Id: <20200630054452.3675847-18-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 --- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4state.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 2b7f6dcd2eb8..210e590e1f71 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -117,7 +117,7 @@ struct nfs4_state_owner { unsigned long so_flags; struct list_head so_states; struct nfs_seqid_counter so_seqid; - seqcount_t so_reclaim_seqcount; + seqcount_spinlock_t so_reclaim_seqcount; struct mutex so_delegreturn_mutex; }; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index a8dc25ce48bb..b1dba24918f8 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -509,7 +509,7 @@ nfs4_alloc_state_owner(struct nfs_server *server, nfs4_init_seqid_counter(&sp->so_seqid); atomic_set(&sp->so_count, 1); INIT_LIST_HEAD(&sp->so_lru); - seqcount_init(&sp->so_reclaim_seqcount); + seqcount_spinlock_init(&sp->so_reclaim_seqcount, &sp->so_lock); mutex_init(&sp->so_delegreturn_mutex); return sp; } -- 2.20.1