Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3315058ybt; Mon, 29 Jun 2020 22:48:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBNCSCGAgXunSGz8xCGY9WJRnhOlaP6PH8Zk6n5pGhne6gNKZQAO5dOiKE5I2mwdb6t1ss X-Received: by 2002:a50:ee07:: with SMTP id g7mr5551096eds.320.1593496085269; Mon, 29 Jun 2020 22:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593496085; cv=none; d=google.com; s=arc-20160816; b=BGsiXauZe8U/wBMaGUn6mSi3dAp1KLtVvbxccxJ/gOepQ0A9zn1/i0WLzubcQjhtwI 40Q/dHZpSTBlNgkpS9x2eMRtdovGC3HKAUfwCYUS8QdXnymK1t6F9F5tnD7fQ1sQQ6R7 fpegerA5MGCvD8H7M+D6G7EpAlwS4WJAjzB5cYeaz5YmBtQLWXh4CuKT5O3ZWo6BvTi2 Y/3DSqWPxbX9eRXU/+UVaLn2WQ56pSWkbPvlnTclRvJym8J8J8pf10ZAbpZo52R35rFR ekDGiaAijwDOr+ZJdaD+R4IWdePiTtkDBfaDEVuQVIc2tUST7Tlk27JRuM6mtVEnD+cJ 7avQ== 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=0pgkphRaGEy8Yhqq7odaGRHYOVQX84dVuNSHLC82kuU=; b=VOGjejxCg27FwJeiq13R9p3CZZ84xOuP8QrYbjRAn/tJbYT6WRQyK9WPKixofygNZF NS4jhzeHzbxLiZR7LY/u7svY3XR1Se6jmioh7sxQw6EsxKyxbLIx4zSJp4nEqxbbrFvI tonI3AyKJ8aOkyFbIYJr7kdirMvx8grvomJB3D9gjq2CZ56Q9YNBTkZLwmRMRVqYmlhT 5p3zh4jXDJmAh7GEcaEYtQeVTzYdTschiQ00D0B+YzsMgNtu+hf0PAzk57CuqBpx0XpC skY0vnuG0uAdMe8fOQwtzig5O81L1s0fHgq+qquo/Mv0BvbCD1u1ttNeVuMFemUFQtIj BRzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=E9otwvbs; dkim=neutral (no key) header.i=@linutronix.de header.b=Xwgu3AOu; 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 yh22si1236924ejb.62.2020.06.29.22.47.42; Mon, 29 Jun 2020 22:48:05 -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=E9otwvbs; dkim=neutral (no key) header.i=@linutronix.de header.b=Xwgu3AOu; 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 S1730052AbgF3Fqd (ORCPT + 99 others); Tue, 30 Jun 2020 01:46:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730039AbgF3Fqc (ORCPT ); Tue, 30 Jun 2020 01:46:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED699C061755; Mon, 29 Jun 2020 22:46:31 -0700 (PDT) From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1593495988; 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=0pgkphRaGEy8Yhqq7odaGRHYOVQX84dVuNSHLC82kuU=; b=E9otwvbsP6fkQIQEzrCLtoiSgGeFf4td6kMkZ8W7QaDr3/zwuxbE36rk6GMf+IhaSpz0Km 8N0+y2u+4FGwt7XZgIvxFlBrYY1rmNeWUlaPxiAdQw0is+7Q5ONMFRg4qvt0u0xbIoPsaZ k/Smy86qXZVyaa9F7wj5oEAdfphHd6WpujuJh/S+XKmsZ1YNULvHCnt/XEpacTrjCOZg6m HRTxT2hGtSfcZHD3+HdElggf7j6BTDwzDpR1lPfPuTlThTYRbHFQep8zjU4lV4urLp1YmH QqKOvkX7NO/LbeAxhPB9kAtvkdzb2w3Dbsj6Fcx/ACRc2ydnkE2Xu5cw841+lw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1593495988; 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=0pgkphRaGEy8Yhqq7odaGRHYOVQX84dVuNSHLC82kuU=; b=Xwgu3AOumeCzro6vBPT+CXbrO72V/FxDvk0GJo8E3RKV5/d3jWPZxXaVH9cPcuW8jYMeTp qxjJYZnEuMDaNwCw== To: Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , "Ahmed S. Darwish" , Paolo Bonzini , kvm@vger.kernel.org Subject: [PATCH v3 19/20] kvm/eventfd: Use sequence counter with associated spinlock Date: Tue, 30 Jun 2020 07:44:51 +0200 Message-Id: <20200630054452.3675847-20-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 Acked-by: Paolo Bonzini --- include/linux/kvm_irqfd.h | 2 +- virt/kvm/eventfd.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h index dc1da020305b..dac047abdba7 100644 --- a/include/linux/kvm_irqfd.h +++ b/include/linux/kvm_irqfd.h @@ -42,7 +42,7 @@ struct kvm_kernel_irqfd { wait_queue_entry_t wait; /* Update side is protected by irqfds.lock */ struct kvm_kernel_irq_routing_entry irq_entry; - seqcount_t irq_entry_sc; + seqcount_spinlock_t irq_entry_sc; /* Used for level IRQ fast-path */ int gsi; struct work_struct inject; diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index ef7ed916ad4a..d6408bb497dc 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -303,7 +303,7 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) INIT_LIST_HEAD(&irqfd->list); INIT_WORK(&irqfd->inject, irqfd_inject); INIT_WORK(&irqfd->shutdown, irqfd_shutdown); - seqcount_init(&irqfd->irq_entry_sc); + seqcount_spinlock_init(&irqfd->irq_entry_sc, &kvm->irqfds.lock); f = fdget(args->fd); if (!f.file) { -- 2.20.1