From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 042EDC742A2 for ; Thu, 11 Jul 2019 23:34:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6E792084B for ; Thu, 11 Jul 2019 23:34:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728851AbfGKXe2 (ORCPT ); Thu, 11 Jul 2019 19:34:28 -0400 Received: from mga03.intel.com ([134.134.136.65]:3463 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbfGKXe1 (ORCPT ); Thu, 11 Jul 2019 19:34:27 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2019 16:34:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,480,1557212400"; d="scan'208";a="160223732" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.165]) by orsmga008.jf.intel.com with ESMTP; 11 Jul 2019 16:34:26 -0700 Date: Thu, 11 Jul 2019 16:34:26 -0700 From: Sean Christopherson To: Peter Xu Cc: kvm@vger.kernel.org, Marcelo Tosatti , Luiz Capitulino , Radim =?utf-8?B?S3LEjW3DocWZ?= , Paolo Bonzini Subject: Re: [kvm-unit-tests PATCH] tscdeadline_latency: Check condition first before loop Message-ID: <20190711233426.GS15067@linux.intel.com> References: <20190711071756.2784-1-peterx@redhat.com> <20190711073335.GC7847@xz-x1> <20190711140553.GB7645@linux.intel.com> <20190711232736.GD7847@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190711232736.GD7847@xz-x1> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, Jul 12, 2019 at 07:27:36AM +0800, Peter Xu wrote: > On Thu, Jul 11, 2019 at 07:05:53AM -0700, Sean Christopherson wrote: > > Ensuring the first hlt lands in an interrupt shadow should prevent getting > > into a halted state after the timer has been disabled, e.g.: > > > > irq_disable(); > > test_tsc_deadline_timer(); > > > > do { > > safe_halt(); > > } while (!hitmax && table_idx < size); > > Yes seems better, thanks for the suggestion (though I'll probably also > need to remove the hidden sti in start_tsc_deadline_timer). > > Is safe_halt() really safe? I mean, IRQ handler could still run > before HLT right after STI right? Though no matter what I think it's > fine for this test case because we'll skip the first IRQ after all. > Just curious. It's safe, at least on modern hardware. Everything since P6, and I think all AMD CPUs?, have an interrupt shadow where interrupts are blocked for one additional instruction after being enabled by STI.