From patchwork Thu Oct 13 10:06:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lan,Tianyu" X-Patchwork-Id: 9374141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45D8560487 for ; Thu, 13 Oct 2016 02:15:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35ED729804 for ; Thu, 13 Oct 2016 02:15:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 288E729809; Thu, 13 Oct 2016 02:15:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=2.0 tests=BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5C9129804 for ; Thu, 13 Oct 2016 02:15:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buVW8-0002tY-Tt; Thu, 13 Oct 2016 02:13:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1buVW7-0002tQ-Hh for xen-devel@lists.xen.org; Thu, 13 Oct 2016 02:13:07 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id 61/84-11175-2BDEEF75; Thu, 13 Oct 2016 02:13:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRWlGSWpSXmKPExsVywNykQnfT23/ hBqcbuCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozrxxayFhyWqbg0qZOtgXGqeBcjJ4eQQKXE 3i3vWEBsCQFeiSPLZrBC2H4Sfb8XsXUxcgDV1Ejs+6UDEmYTUJc4sXgiI4gtIiAtce3zZSCbi 4NZ4DqjRNO102wgCWEBd4m2h0uZQGwWAVWJ7dN/soPYvAKWEt1n5zBCzJeTuLTtC/MERu4FjA yrGNWLU4vKUot0jfWSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQJ9ywAEOxg7/jk dYpTkYFIS5b1291+4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneojdAOcGi1PTUirTMHGCQwaQl OHiURHjLQdK8xQWJucWZ6RCpU4yKUuK8NSAJAZBERmkeXBsssC8xykoJ8zICHSLEU5BalJtZg ir/ilGcg1FJmLcRZApPZl4J3PRXQIuZgBbbTPoDsrgkESEl1cDY1bqsrYZ9mfqBCJb9P6U5z3 9vOjXb98hhBaXo24yHu+8+T45YEbj2mXFXltZzDpNVAk0b1t/XXB19ZWVI/GOHBrM4HynhkIs rzQ3VV7TM+6LXFLP3W7pqGu8G/n6bBde1G3K/OP9YbSGSZ3qh5Y9i43pdfhNTsWMdDx+KLrL8 d6jsWcz/vNdKLMUZiYZazEXFiQA1Mb2JZwIAAA== X-Env-Sender: tianyu.lan@intel.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1476324783!52498320!1 X-Originating-IP: [192.55.52.120] X-SpamReason: No, hits=2.2 required=7.0 tests=BODY_RANDOM_LONG, DATE_IN_FUTURE_06_12 X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 5144 invoked from network); 13 Oct 2016 02:13:05 -0000 Received: from mga04.intel.com (HELO mga04.intel.com) (192.55.52.120) by server-14.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 13 Oct 2016 02:13:05 -0000 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP; 12 Oct 2016 19:13:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,338,1473145200"; d="scan'208";a="19023758" Received: from unknown (HELO localhost) ([10.239.48.115]) by fmsmga006.fm.intel.com with ESMTP; 12 Oct 2016 19:13:01 -0700 From: Lan Tianyu To: xen-devel@lists.xen.org Date: Thu, 13 Oct 2016 18:06:01 +0800 Message-Id: <20161013100601.15608-1-tianyu.lan@intel.com> X-Mailer: git-send-email 2.9.3 Cc: Lan Tianyu , sstabellini@kernel.org, wei.liu2@citrix.com, George.Dunlap@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, jbeulich@suse.com Subject: [Xen-devel] [PATCH V3] Xen/Keyhandler: Rework process of nonirq keyhandler X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Keyhandler may run for a long time in serial port driver's timer handler on the large machine with a lot of physical cpus(e,g dump_timerq()) when serial port driver works in the poll mode(via the exception mechanism). If a timer handler runs a long time, it will block nmi_timer_fn() to feed NMI watchdog and cause Xen hypervisor panic. Inserting process_pending_softirqs() in timer handler will not help. when timer interrupt arrives, timer subsystem calls all expired timer handlers before programming next timer interrupt. There is no timer interrupt arriving to trigger timer softirq during run a timer handler. This patch is to fix the issue to make nonirq keyhandler run in tasklet when receive debug key from serial port. Signed-off-by: Lan Tianyu Reviewed-by: Jan Beulich --- xen/common/keyhandler.c | 8 +++++--- xen/common/sysctl.c | 2 +- xen/drivers/char/console.c | 2 +- xen/include/xen/keyhandler.h | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 16de6e8..005ef99 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -75,19 +75,21 @@ static struct keyhandler { static void keypress_action(unsigned long unused) { - handle_keypress(keypress_key, NULL); + console_start_log_everything(); + key_table[keypress_key].fn(keypress_key); + console_end_log_everything(); } static DECLARE_TASKLET(keypress_tasklet, keypress_action, 0); -void handle_keypress(unsigned char key, struct cpu_user_regs *regs) +void handle_keypress(unsigned char key, struct cpu_user_regs *regs, bool force_tasklet) { struct keyhandler *h; if ( key >= ARRAY_SIZE(key_table) || !(h = &key_table[key])->fn ) return; - if ( !in_irq() || h->irq_callback ) + if ( h->irq_callback || !force_tasklet ) { console_start_log_everything(); h->irq_callback ? h->irq_fn(key, regs) : h->fn(key); diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c index 8aea6ef..1eb7bad 100644 --- a/xen/common/sysctl.c +++ b/xen/common/sysctl.c @@ -136,7 +136,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) { if ( copy_from_guest_offset(&c, op->u.debug_keys.keys, i, 1) ) goto out; - handle_keypress(c, guest_cpu_user_regs()); + handle_keypress(c, guest_cpu_user_regs(), false); } ret = 0; copyback = 0; diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 55ae31a..b0f74ce 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -347,7 +347,7 @@ static void switch_serial_input(void) static void __serial_rx(char c, struct cpu_user_regs *regs) { if ( xen_rx ) - return handle_keypress(c, regs); + return handle_keypress(c, regs, !in_irq()); /* Deliver input to guest buffer, unless it is already full. */ if ( (serial_rx_prod-serial_rx_cons) != SERIAL_RX_SIZE ) diff --git a/xen/include/xen/keyhandler.h b/xen/include/xen/keyhandler.h index 06c05c8..e9595bd 100644 --- a/xen/include/xen/keyhandler.h +++ b/xen/include/xen/keyhandler.h @@ -46,7 +46,9 @@ void register_irq_keyhandler(unsigned char key, bool_t diagnostic); /* Inject a keypress into the key-handling subsystem. */ -extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs); +extern void handle_keypress(unsigned char key, + struct cpu_user_regs *regs, + bool async); /* Scratch space is available for use of any keyhandler. */ extern char keyhandler_scratch[1024];