Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4357424ybg; Mon, 8 Jun 2020 06:01:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYzgsX8jpiCLUmV645Y5eNaG3zXuwVyx5dUfEV+qJs7U2A/NTM1lsPbAjnXy/b3N4ECiPI X-Received: by 2002:a17:906:1d56:: with SMTP id o22mr20359999ejh.406.1591621302323; Mon, 08 Jun 2020 06:01:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591621302; cv=none; d=google.com; s=arc-20160816; b=uDyLGblBNRJNu+JnO1t9P+43JMee61oZv5gKgYVb6J26F/zA9KxwZ5vzf9YjCQ5SgA lYlVI6/wkEqphtLgJlx9Lnlj0rlfxyhu2Yy6htFBgv8wMqgFyXspVARf4CkHt0x5izEl heZalozIwLL0R2uL7GDmduKx84pR4Tk33GGsrCU9AEv3yKTgyduHNQCJ7/1ya0WGlf3b w6+lDx01BflfoV2kevm5WPO/el9SbnLqEqC2wvpWpmt+KNkGMF5hEADx8d/fAMk6BORl qfB++sF5WNDj7fczmSawCzdTc1HTYVh6qI5J/dvd5WrUraIm9J48q6h3ufltf25myGWw bBIA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=cUm1Yo5Aid4TMrOqqlc50Lm+RhYPQ/fOeFf4c/GrH5w=; b=xP/7eut5vE3hnAID43EABnBUqIN6R3VSa7/Kz56KhWTTsBp2TOAdMbl5ck63rQsBhC 6M5Rem8UWLNLXgA79mOb9tOmscXCyKBSTmCcvSEEN/O0iuZiXEGiJ1dQB2z6DqfztgN6 uo8XMSheHhbfPYtd+Ejr2AD5diDKLJHo+ijMAqHGXCRpcVmWpCV5uJMoEt6OcwIRbMlC unS01YooF5oMcOKS+XHXNIVkhe6joyCagoh9gF3tIdXOTSZ9v9eXg4QXkIXVxT28+HBH 5m9Db4xSB0RSkdox/d+wOhYG7NW6fV74HXQBN6yb67iR0JbUG938uLx834P+2NjvKeZS 3xVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HHsy2c0J; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm15si10078493ejc.728.2020.06.08.06.01.17; Mon, 08 Jun 2020 06:01:42 -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=@redhat.com header.s=mimecast20190719 header.b=HHsy2c0J; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729744AbgFHM51 (ORCPT + 99 others); Mon, 8 Jun 2020 08:57:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:55892 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729562AbgFHM50 (ORCPT ); Mon, 8 Jun 2020 08:57:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1591621044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cUm1Yo5Aid4TMrOqqlc50Lm+RhYPQ/fOeFf4c/GrH5w=; b=HHsy2c0JyXdMIxRfW0LPwZ5i4daoT6/wwrXDJzQQVSpZdFjTTMte/dbctW0POx16zwdjMq szvXWbA4gXnD0qi9DfhnYh3bJ2AK+HYf/mbWQMfkwuk1mmmo+B1aP2y+aGr9zr/r+5hGmN GmhEgkilblYtEplfXhoLNGXBElnb/o4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-490-X5_LaDo0MmOPSb_gmUsdlQ-1; Mon, 08 Jun 2020 08:57:23 -0400 X-MC-Unique: X5_LaDo0MmOPSb_gmUsdlQ-1 Received: by mail-wr1-f70.google.com with SMTP id l1so7110129wrc.8 for ; Mon, 08 Jun 2020 05:57:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cUm1Yo5Aid4TMrOqqlc50Lm+RhYPQ/fOeFf4c/GrH5w=; b=ch1pHnIlXJ57ImKZhsHKKSrdvkapJpHWs/K/XtJRf1x4kmZl0noZvFpT2mDn4xWFY4 pf04o9wTprNN10njlg/1Nwif+vRerxx6DsSBtDy0TYWrMfm/XS+2UrptiENy1Q0IWxLv c4h4VqELsIEQ3qDq05MwAv8sbm8g/bcyo7z8aHJ4GmCJRrxV7a6d/cLvFLrP2hpbEvTP uEX0xxwhLw+pU/BMZAMJeQPWYt6yJYCf++MHRfBjumWJ5VLVI9V+7RXn2JUOu7YFMQzl 7jpzZ0XQ7EKvahVCwvGIRJIWuxTGCiGyWue+8n1Z8Uxj8msBA1wSXj7szKChYMaLh+Tn Q2gA== X-Gm-Message-State: AOAM530fvp+gBTJjQUGE0hP6+oEj6KUVDF2A9NN97FPee8ekvij56Hxb r66C1JWnwhpUvKpx3vAIyUDLR/zqha+lpUjD8aPanrIomAx6AUdLip9smKs1G03qNI4eo+yT/9f KVvbYncEdJC7t2Gja/JFBsXNW X-Received: by 2002:a05:6000:4c:: with SMTP id k12mr23045673wrx.215.1591621041758; Mon, 08 Jun 2020 05:57:21 -0700 (PDT) X-Received: by 2002:a05:6000:4c:: with SMTP id k12mr23045654wrx.215.1591621041544; Mon, 08 Jun 2020 05:57:21 -0700 (PDT) Received: from [192.168.178.58] ([151.30.87.23]) by smtp.gmail.com with ESMTPSA id s132sm23406546wmf.12.2020.06.08.05.57.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Jun 2020 05:57:21 -0700 (PDT) Subject: Re: [PATCH v2 17/18] kvm/eventfd: Use sequence counter with associated spinlock To: "Ahmed S. Darwish" , Peter Zijlstra , Ingo Molnar , Will Deacon Cc: Thomas Gleixner , "Paul E. McKenney" , "Sebastian A. Siewior" , Steven Rostedt , LKML , kvm@vger.kernel.org References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200608005729.1874024-1-a.darwish@linutronix.de> <20200608005729.1874024-18-a.darwish@linutronix.de> From: Paolo Bonzini Message-ID: Date: Mon, 8 Jun 2020 14:57:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200608005729.1874024-18-a.darwish@linutronix.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/06/20 02:57, Ahmed S. Darwish wrote: > 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 > --- > 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 67b6fc153e9c..8694a2920ea9 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) { > Acked-by: Paolo Bonzini