From patchwork Thu Sep 29 16:26:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 77136 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp444364qgf; Thu, 29 Sep 2016 09:27:40 -0700 (PDT) X-Received: by 10.98.46.198 with SMTP id u189mr3836888pfu.116.1475166460543; Thu, 29 Sep 2016 09:27:40 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id e8si14925914paw.129.2016.09.29.09.27.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Sep 2016 09:27:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bpeAA-0006FJ-Dl; Thu, 29 Sep 2016 16:26:22 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bpeA6-0006DT-0G for linux-arm-kernel@lists.infradead.org; Thu, 29 Sep 2016 16:26:19 +0000 Received: by mail-wm0-x22d.google.com with SMTP id w84so308442063wmg.1 for ; Thu, 29 Sep 2016 09:25:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=qqtJBch+0DpFj2oh2OsaZ81VNSudJuQpRGh9QThsB2c=; b=JjZgSMsfkew8Cs+6gTYZaTd71DzfGEsH64GqfHejFTpQuxJDwse9hb/ALx+xIexa5W z8eeqAKyAL5vX0QpXQm3bnTrVUNHV3MmXigw2sdBCal2N4wBgU1Hk0lIAHAF33AFDU3C st8ucsPMYr9fEnZiO5dEG+6q6fiKluusjU/u0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qqtJBch+0DpFj2oh2OsaZ81VNSudJuQpRGh9QThsB2c=; b=IOCbk9J1Igv4ZrerGbfn3Dp6Nr23NlY8uRXk7c028F2I9q7XKMJVH+bUWbopts6iFZ YuSWydt99cPesyel+87MNJxDXiPsHUejM/AvDmw2v5T0uAMCFyL4HAffv9xtBFW9cX/g YTTyO0Ju2WmD9Zliq2AYBoYzBm35mJ4XZE7FH5uaqKXwMRBO5kzrnxjJzIxZxj1hdg73 H3p6l5neWQn3eE9nNw6O7jW/RBAEvMpUvS9CffNXUqmsQmAQftIdf8MhoEpdK/mjrn70 6bAto7s41ZZuoIuwUCYBBNOZEG2ybZXackoYaoKweDvtOVJw1vNYsQDOt9ZJgt6WfGrx g7Pw== X-Gm-Message-State: AA6/9Rmnwd1QdF/3Gl2T9HxNjUydG9OU+Rhf0brdaea7CnTWM6Ztw+YzM/XDW/IVDDRBg3W4 X-Received: by 10.195.17.226 with SMTP id gh2mr2545409wjd.15.1475166355940; Thu, 29 Sep 2016 09:25:55 -0700 (PDT) Received: from localhost.localdomain ([94.18.191.146]) by smtp.gmail.com with ESMTPSA id 188sm29095939wmo.1.2016.09.29.09.25.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Sep 2016 09:25:55 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Subject: [PATCH] KVM: arm/arm64: Fix occasional warning from the timer work function Date: Thu, 29 Sep 2016 18:26:12 +0200 Message-Id: <20160929162612.23171-1-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.9.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160929_092618_219974_5E4BF0BF X-CRM114-Status: GOOD ( 15.71 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christoffer Dall , mbrugger@suse.com, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Alexander Graf MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org When a VCPU blocks (WFI) we arm (the verb, not the architecture) any timers scheduled to expire in the future to wake up the vcpu thread when appropriate. Because such as wake up involves a vcpu kick, and the timer expire function can get called from interrupt context, and the kick may sleep, we have to schedule the kick in the work function. The work function currently has a warning that gets raised if it turns out that the timer shouldn't fire when it's run, which was added because the idea was that then the work should never have been cancelled. However, the work function can run long after a vcpu thread gets scheduled again and the timer conditions can have changed as a result of running the vcpu, which would raise this warning. This can happen on a busy system, for example. The solution is to simply not raise this warning, because a kick is never harmful. Also, cancel any scheduled work when the vcpu thread is running anyway, since there is no need to run the work function anymore. Reported-by: Matthias Brugger Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.9.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 27a1f63..e136902 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -91,8 +91,6 @@ static void kvm_timer_inject_irq_work(struct work_struct *work) vcpu = container_of(work, struct kvm_vcpu, arch.timer_cpu.expired); vcpu->arch.timer_cpu.armed = false; - WARN_ON(!kvm_timer_should_fire(vcpu)); - /* * If the vcpu is blocked we want to wake it up so that it will see * the timer has expired when entering the guest. @@ -240,6 +238,9 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; timer_disarm(timer); + + /* No need for another thread to kick us if we're already running */ + cancel_work_sync(&timer->expired); } /**