From patchwork Mon Dec 23 16:43:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 11308511 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C371B109A for ; Mon, 23 Dec 2019 16:45:39 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9EAD42073A for ; Mon, 23 Dec 2019 16:45:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="VkLNS03a" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9EAD42073A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo5-0006J1-B5; Mon, 23 Dec 2019 16:43:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo3-0006Id-VA for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:43 +0000 X-Inumbo-ID: 5bbafdb4-25a3-11ea-96fe-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5bbafdb4-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4LajtYjbMp6EySa6REpYUzL+FBkEHu6GtKsC0g+RZ1c=; b=VkLNS03auYBPUxa4z5ruzmcRWIi5To29A0hBDVoa4diQttgFcehaCh7d 86wFrN6/j0wYdnpXpSepG4qq3Wra4GTssSjirMxOtoDU7lW0AJ/S1WtVX E9STo4BjQXjokrAzUzgfisnlVYBvn2a+Ou4r18vuNpotEDsw6E25CcWmj k=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: AxsFZfHdjC5LEZb4P+WEb/mOM+GeGKy4uTMsLWWzIUTaafKoQS8ilxHcMLF+7CpZtU+6BTPe61 /vSJFaMh/xJdpaYiutyWAijRme/t+fq3S0XaE9DUs77KvFflBusgA/oDxIKtmKlh8doBfmYR31 aDkTUbyAKgUpELHrwMsAAM3/wWhWQAencHg60V6NbgkK5llQudM/9kqE11NBIWwThXrHzZnsqV 9X3TjNGIHtHmM11DJZdPd23AgG5zSsSY32GBFUbQ4KFdKLfqi+aL7gVxCm7hQXbrl1M38icCwn 36A= X-SBRS: 2.7 X-MesageID: 10229661 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229661" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:27 +0000 Message-ID: <20191223164329.3113378-3-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] xen: Add 'synthetic' preemption check parameter X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" In order to better test hypervisor preemption paths, add an option to artificially increase the number of preemptions. While modifying xen-command-line.pandoc, escape some underscores, and remove some trailing whitespace. Signed-off-by: George Dunlap --- CC: Andrew Cooper CC: Jan Beulich --- docs/misc/xen-command-line.pandoc | 20 ++++++++++++++++++-- xen/arch/x86/time.c | 11 +++++++++++ xen/include/xen/sched.h | 10 +++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc index 981a5e2381..1a9fda8627 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -636,13 +636,29 @@ Available alternatives, with their meaning, are: Specify the USB controller to use, either by instance number (when going over the PCI busses sequentially) or by PCI device (must be on segment 0). -### debug_stack_lines +### debug\_stack\_lines > `= ` > Default: `20` Limits the number lines printed in Xen stack traces. +### debug-synthetic-preemption +> `= ` + +> Default: `0` + +Artificially increases rate at which `hypercall_preempt_check()` +returns `true`, for debugging purposes, to a rate of one in `N`. (The +default, `0`, disables the feature.) + +When promoting pagetables, for instance, `hypercall_preempt_check()` +is called before processing each PTE. Since there are 512 PTEs per +page, a value of `1024` should result in pagetable promotion being +interrupted every other page on average. + +Only available in DEBUG builds. + ### debugtrace > `= [cpu:]` @@ -1690,7 +1706,7 @@ The following resources are available: CDP, one COS will corespond two CBMs other than one with CAT, due to the sum of CBMs is fixed, that means actual `cos_max` in use will automatically reduce to half when CDP is enabled. - + ### pv-linear-pt (x86) > `= ` diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 64e471a39b..34302f81e7 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -43,6 +43,17 @@ static char __initdata opt_clocksource[10]; string_param("clocksource", opt_clocksource); +#ifndef NDEBUG +int debug_synthetic_preemption = 0; +integer_param("debug-synthetic-preemption", debug_synthetic_preemption); + +bool synthetic_preemption_check(void) { + if ( debug_synthetic_preemption == 0 ) + return false; + return !(rdtsc() % debug_synthetic_preemption); +} +#endif + unsigned long __read_mostly cpu_khz; /* CPU clock frequency in kHz. */ DEFINE_SPINLOCK(rtc_lock); unsigned long pit0_ticks; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 9f7bc69293..c0071eee04 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -748,6 +748,13 @@ static inline void hypercall_cancel_continuation(struct vcpu *v) v->hcall_preempted = false; } +#ifndef NDEBUG +bool synthetic_preemption_check(void); +#define synthetic_preemption_check synthetic_preemption_check +#else +#define synthetic_preempiton_check() false +#endif + /* * For long-running operations that must be in hypercall context, check * if there is background work to be done that should interrupt this @@ -755,7 +762,8 @@ static inline void hypercall_cancel_continuation(struct vcpu *v) */ #define hypercall_preempt_check() (unlikely( \ softirq_pending(smp_processor_id()) | \ - local_events_need_delivery() \ + local_events_need_delivery() | \ + synthetic_preemption_check() \ )) /*