From patchwork Tue Oct 27 13:55:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 11860501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84DE2C55178 for ; Tue, 27 Oct 2020 13:55:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4AB8F21655 for ; Tue, 27 Oct 2020 13:55:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="u3BI0eTH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2900855AbgJ0Nza (ORCPT ); Tue, 27 Oct 2020 09:55:30 -0400 Received: from casper.infradead.org ([90.155.50.34]:41550 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438386AbgJ0Nza (ORCPT ); Tue, 27 Oct 2020 09:55:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=RaIfHC7BLM4SW2hHIHWeJJ18AZKbmgeAZRKzDoH2DFk=; b=u3BI0eTHwiqt8yMwHim8BcwRqs wT0SyhzyBONY5MrN1aN/NK3iJctEBVEGEFbkfp/6LCLoKV/Q0Zw7vYHdM8I3q7s0iM3UTzuX+HrwX kzOjvWsf7KWwrO09ZUBl3C/HCyUiExt1ZCQl0gZ6GdAG71//8fdzZS/I31RnRXJSApavJ6v6tru1C VZ9n/BiVBkt2Y4so2ZttBOStebLJDz2uOZa0sqapoQGHONWmRYaBbL4n4/f1vunw2sdrJV5jkuLUe bIIFYXxDk2KlGDISrlhD9XZPq9/veawNUfY/2ZriN7BQR2+QooEA5T7zfumUS5+lLaRuSxQ4gGk3t 8maXGEWA==; Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kXPRe-00009V-3P; Tue, 27 Oct 2020 13:55:26 +0000 Received: from dwoodhou by i7.infradead.org with local (Exim 4.93 #3 (Red Hat Linux)) id 1kXPRd-002iLl-La; Tue, 27 Oct 2020 13:55:25 +0000 From: David Woodhouse To: bonzini@redhat.com Cc: Alex Williamson , Cornelia Huck , Alexander Viro , Jens Axboe , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 3/3] kvm/eventfd: Drain events from eventfd in irqfd_wakeup() Date: Tue, 27 Oct 2020 13:55:23 +0000 Message-Id: <20201027135523.646811-4-dwmw2@infradead.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201027135523.646811-1-dwmw2@infradead.org> References: <1faa5405-3640-f4ad-5cd9-89a9e5e834e9@redhat.com> <20201027135523.646811-1-dwmw2@infradead.org> MIME-Version: 1.0 Sender: David Woodhouse X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: David Woodhouse Don't allow the events to accumulate in the eventfd counter, drain them as they are handled. Signed-off-by: David Woodhouse Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: kernel test robot --- virt/kvm/eventfd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index d6408bb497dc..98b5cfa1d69f 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -193,6 +193,9 @@ irqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void *key) int idx; if (flags & EPOLLIN) { + u64 cnt; + eventfd_ctx_do_read(&irqfd->eventfd, &cnt); + idx = srcu_read_lock(&kvm->irq_srcu); do { seq = read_seqcount_begin(&irqfd->irq_entry_sc);