[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xen: make keyhanler configurable


  • To: Baodong Chen <chenbaodong@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Juergen Gross <jgross@xxxxxxxx>
  • Date: Fri, 31 May 2019 12:53:41 +0200
  • Autocrypt: addr=jgross@xxxxxxxx; prefer-encrypt=mutual; keydata= mQENBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOB ycWxw3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJve dYm8Of8Zd621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJ NwQpd369y9bfIhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvx XP3FAp2pkW0xqG7/377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEB AAG0H0p1ZXJnZW4gR3Jvc3MgPGpncm9zc0BzdXNlLmNvbT6JATkEEwECACMFAlOMcK8CGwMH CwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRCw3p3WKL8TL8eZB/9G0juS/kDY9LhEXseh mE9U+iA1VsLhgDqVbsOtZ/S14LRFHczNd/Lqkn7souCSoyWsBs3/wO+OjPvxf7m+Ef+sMtr0 G5lCWEWa9wa0IXx5HRPW/ScL+e4AVUbL7rurYMfwCzco+7TfjhMEOkC+va5gzi1KrErgNRHH kg3PhlnRY0Udyqx++UYkAsN4TQuEhNN32MvN0Np3WlBJOgKcuXpIElmMM5f1BBzJSKBkW0Jc Wy3h2Wy912vHKpPV/Xv7ZwVJ27v7KcuZcErtptDevAljxJtE7aJG6WiBzm+v9EswyWxwMCIO RoVBYuiocc51872tRGywc03xaQydB+9R7BHPuQENBFOMcBYBCADLMfoA44Mw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kQVEWD4hs7iV 1KQHe2uwXbKlguKPhk5ubZxqwsg/uIHw0qZDk+d0vxjTtO2JD5Jv/CeDgaBX4Emgp0NYs8IC UIyKXBtnzwiNv4cX9qKlz2Gyq9b+GdcLYZqMlIBjdCz0yJvgeb3WPNsCOanvbjelDhskx9gd 6YUUFFqgsLtrKpCNyy203a58g2WosU9k9H+LcheS37Ph2vMVTISMszW9W8gyORSgmw==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wei.liu2@xxxxxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, Julien Grall <julien.grall@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Dario Faggioli <dfaggioli@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Fri, 31 May 2019 10:53:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Openpgp: preference=signencrypt

On 31/05/2019 03:58, Baodong Chen wrote:
> keyhandler mainly used for debug usage by developers which can dump
> xen module(eg. timer, scheduler) status at runtime by input
> character from console.
> 
> Signed-off-by: Baodong Chen <chenbaodong@xxxxxxxxxx>
> ---
>  xen/arch/arm/gic.c           |  2 ++
>  xen/arch/x86/apic.c          |  2 ++
>  xen/common/Kconfig           |  9 +++++++++
>  xen/common/Makefile          |  2 +-
>  xen/common/cpupool.c         |  2 ++
>  xen/common/schedule.c        |  2 ++
>  xen/include/xen/keyhandler.h | 14 ++++++++++++++
>  xen/include/xen/lib.h        |  2 ++
>  xen/include/xen/sched.h      |  2 ++
>  9 files changed, 36 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
> index 6cc7dec..fff88c5 100644
> --- a/xen/arch/arm/gic.c
> +++ b/xen/arch/arm/gic.c
> @@ -361,7 +361,9 @@ static void do_sgi(struct cpu_user_regs *regs, enum 
> gic_sgi sgi)
>          /* Nothing to do, will check for events on return path */
>          break;
>      case GIC_SGI_DUMP_STATE:
> +#ifdef CONFIG_HAS_KEYHANDLER
>          dump_execstate(regs);
> +#endif
>          break;
>      case GIC_SGI_CALL_FUNCTION:
>          smp_call_function_interrupt();
> diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
> index fafc0bd..e5f004a 100644
> --- a/xen/arch/x86/apic.c
> +++ b/xen/arch/x86/apic.c
> @@ -1410,7 +1410,9 @@ void spurious_interrupt(struct cpu_user_regs *regs)
>          ack_APIC_irq();
>          if (this_cpu(state_dump_pending)) {
>              this_cpu(state_dump_pending) = false;
> +#ifdef CONFIG_HAS_KEYHANDLER
>              dump_execstate(regs);
> +#endif
>              return;
>          }
>      }
> diff --git a/xen/common/Kconfig b/xen/common/Kconfig
> index c838506..450541c 100644
> --- a/xen/common/Kconfig
> +++ b/xen/common/Kconfig
> @@ -368,4 +368,13 @@ config DOM0_MEM
>  
>         Leave empty if you are not sure what to specify.
>  
> +config HAS_KEYHANDLER

AFAIK the HAS_* config options are meant to be selected by other options
and not be user selectable.

So I think you should drop the "HAS_" and maybe use the plural as Dario
already suggested ("KEYHANDLERS").

> +     bool "Enable/Disable keyhandler"
> +     default y
> +     ---help---
> +       Enable or disable keyhandler function.
> +       keyhandler mainly used for debug usage by developers which can dump
> +       xen module(eg. timer, scheduler) status at runtime by input character
> +       from console.

I'd drop the "by developers". In case of customer problems with Xen
hosts the output of keyhandlers is requested on a rather regular base.

> +
>  endmenu
> diff --git a/xen/common/Makefile b/xen/common/Makefile
> index bca48e6..c7bcd26 100644
> --- a/xen/common/Makefile
> +++ b/xen/common/Makefile
> @@ -16,7 +16,7 @@ obj-y += guestcopy.o
>  obj-bin-y += gunzip.init.o
>  obj-y += irq.o
>  obj-y += kernel.o
> -obj-y += keyhandler.o
> +obj-$(CONFIG_HAS_KEYHANDLER) += keyhandler.o
>  obj-$(CONFIG_KEXEC) += kexec.o
>  obj-$(CONFIG_KEXEC) += kimage.o
>  obj-y += lib.o
> diff --git a/xen/common/cpupool.c b/xen/common/cpupool.c
> index 31ac323..721a729 100644
> --- a/xen/common/cpupool.c
> +++ b/xen/common/cpupool.c
> @@ -699,6 +699,7 @@ int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op)
>      return ret;
>  }
>  
> +#ifdef CONFIG_HAS_KEYHANDLER
>  void dump_runq(unsigned char key)
>  {
>      unsigned long    flags;
> @@ -730,6 +731,7 @@ void dump_runq(unsigned char key)
>      local_irq_restore(flags);
>      spin_unlock(&cpupool_lock);
>  }
> +#endif
>  
>  static int cpu_callback(
>      struct notifier_block *nfb, unsigned long action, void *hcpu)
> diff --git a/xen/common/schedule.c b/xen/common/schedule.c
> index 66f1e26..617c444 100644
> --- a/xen/common/schedule.c
> +++ b/xen/common/schedule.c
> @@ -1913,6 +1913,7 @@ void scheduler_free(struct scheduler *sched)
>      xfree(sched);
>  }
>  
> +#ifdef CONFIG_HAS_KEYHANDLER
>  void schedule_dump(struct cpupool *c)
>  {
>      unsigned int      i;
> @@ -1941,6 +1942,7 @@ void schedule_dump(struct cpupool *c)
>              SCHED_OP(sched, dump_cpu_state, i);
>      }
>  }
> +#endif
>  
>  void sched_tick_suspend(void)
>  {
> diff --git a/xen/include/xen/keyhandler.h b/xen/include/xen/keyhandler.h
> index 5131e86..1050b80 100644
> --- a/xen/include/xen/keyhandler.h
> +++ b/xen/include/xen/keyhandler.h
> @@ -28,6 +28,7 @@ struct cpu_user_regs;
>  typedef void (irq_keyhandler_fn_t)(unsigned char key,
>                                     struct cpu_user_regs *regs);
>  
> +#ifdef CONFIG_HAS_KEYHANDLER
>  /* Initialize keytable with default handlers. */
>  void initialize_keytable(void);
>  
> @@ -48,4 +49,17 @@ void register_irq_keyhandler(unsigned char key,
>  /* Inject a keypress into the key-handling subsystem. */
>  extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs);
>  
> +#else
> +static inline void initialize_keytable(void) {}
> +static inline void register_keyhandler(unsigned char key, keyhandler_fn_t 
> *fn,
> +                                       const char *desc, bool_t diagnostic) 
> {}
> +static inline void register_irq_keyhandler(unsigned char key,
> +                                           irq_keyhandler_fn_t *fn,
> +                                           const char *desc,
> +                                           bool_t diagnostic) {}
> +
> +static inline void handle_keypress(unsigned char key,
> +                                   struct cpu_user_regs *regs) {}
> +#endif
> +
>  #endif /* __XEN_KEYHANDLER_H__ */
> diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
> index e0b7bcb..8710305 100644
> --- a/xen/include/xen/lib.h
> +++ b/xen/include/xen/lib.h
> @@ -171,8 +171,10 @@ extern unsigned int tainted;
>  extern char *print_tainted(char *str);
>  extern void add_taint(unsigned int taint);
>  
> +#ifdef CONFIG_HAS_KEYHANDLER
>  struct cpu_user_regs;
>  void dump_execstate(struct cpu_user_regs *);
> +#endif
>  
>  void init_constructors(void);
>  
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 748bb0f..b82cdee 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -994,8 +994,10 @@ int cpupool_add_domain(struct domain *d, int poolid);
>  void cpupool_rm_domain(struct domain *d);
>  int cpupool_move_domain(struct domain *d, struct cpupool *c);
>  int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op);
> +#ifdef CONFIG_HAS_KEYHANDLER
>  void schedule_dump(struct cpupool *c);
>  extern void dump_runq(unsigned char key);
> +#endif
>  
>  void arch_do_physinfo(struct xen_sysctl_physinfo *pi);

Why stopping halfway here? There are lots of other keyhandlers which can
be removed for the hypervisor in case there is no code calling them.


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.