linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: ananth@in.ibm.com, anil.s.keshavamurthy@intel.com,
	"Håvard Skinnemoen" <hskinnemoen@gmail.com>,
	"David Miller" <davem@davemloft.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Hans-Christian Egtvedt" <egtvedt@samfundet.no>,
	"yrl.pp-manager.tt@hitachi.com" <yrl.pp-manager.tt@hitachi.com>,
	"Ingo Molnar" <mingo@elte.hu>
Subject: Re: [PATCH] include/linux/kprobes.h: move all functions to their matched area
Date: Wed, 05 Feb 2014 16:51:09 +0900	[thread overview]
Message-ID: <52F1ED6D.6060503@hitachi.com> (raw)
In-Reply-To: <52F1CBAB.2070106@gmail.com>

(2014/02/05 14:27), Chen Gang wrote:
> For dummy functions, it is not a good idea to still use the input
> parameters (not a good idea to assume they are still effect).
> 
>  - let kprobe* static inline functions in CONFIG_KPROBES, dummy outside.
> 
>  - let (en/dis)able_jprobe() in CONFIG_KPROBES, dummy outside.
> 
>  - for kretprobe:
> 
>    - let kretprobe_assert() only in CONFIG_KRETPROBES (internal use).
> 
>    - remove kretprobe_inst_table_head() (cannot grep it in kernel wide).
> 
>    - for (en/dis)able_kretprobe():
> 
>        if CONFIG_KRETPROBES enabled, they use (en/dis)able_kprobe().
>        else if CONFIG_KPROBES enabled, return -EINVAL (not registered).
>        else, return -ENOSYS, just like (en/dis)able_kprobe() have done.

NAK. I don't increase complexity in this header file anymore,
unless we have any actual issue with sane usage.

Thank you,

> 
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
>  include/linux/kprobes.h | 136 ++++++++++++++++++++++++++++++++----------------
>  1 file changed, 92 insertions(+), 44 deletions(-)
> 
> diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
> index 925eaf2..860313d 100644
> --- a/include/linux/kprobes.h
> +++ b/include/linux/kprobes.h
> @@ -129,30 +129,6 @@ struct kprobe {
>  				   */
>  #define KPROBE_FLAG_FTRACE	8 /* probe is using ftrace */
>  
> -/* Has this kprobe gone ? */
> -static inline int kprobe_gone(struct kprobe *p)
> -{
> -	return p->flags & KPROBE_FLAG_GONE;
> -}
> -
> -/* Is this kprobe disabled ? */
> -static inline int kprobe_disabled(struct kprobe *p)
> -{
> -	return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE);
> -}
> -
> -/* Is this kprobe really running optimized path ? */
> -static inline int kprobe_optimized(struct kprobe *p)
> -{
> -	return p->flags & KPROBE_FLAG_OPTIMIZED;
> -}
> -
> -/* Is this kprobe uses ftrace ? */
> -static inline int kprobe_ftrace(struct kprobe *p)
> -{
> -	return p->flags & KPROBE_FLAG_FTRACE;
> -}
> -
>  /*
>   * Special probe type that uses setjmp-longjmp type tricks to resume
>   * execution at a specified entry with a matching prototype corresponding
> @@ -223,7 +199,42 @@ static inline int kprobes_built_in(void)
>  	return 1;
>  }
>  
> +/* Has this kprobe gone ? */
> +static inline int kprobe_gone(struct kprobe *p)
> +{
> +	return p->flags & KPROBE_FLAG_GONE;
> +}
> +
> +/* Is this kprobe disabled ? */
> +static inline int kprobe_disabled(struct kprobe *p)
> +{
> +	return p->flags & (KPROBE_FLAG_DISABLED | KPROBE_FLAG_GONE);
> +}
> +
> +/* Is this kprobe really running optimized path ? */
> +static inline int kprobe_optimized(struct kprobe *p)
> +{
> +	return p->flags & KPROBE_FLAG_OPTIMIZED;
> +}
> +
> +/* Is this kprobe uses ftrace ? */
> +static inline int kprobe_ftrace(struct kprobe *p)
> +{
> +	return p->flags & KPROBE_FLAG_FTRACE;
> +}
> +
>  #ifdef CONFIG_KRETPROBES
> +static inline void kretprobe_assert(struct kretprobe_instance *ri,
> +	unsigned long orig_ret_address, unsigned long trampoline_address)
> +{
> +	if (!orig_ret_address || (orig_ret_address == trampoline_address)) {
> +		printk(KERN_ERR
> +			"kretprobe BUG!: Processing kretprobe %p @ %p\n",
> +			ri->rp, ri->rp->kp.addr);
> +		BUG();
> +	}
> +}
> +
>  extern void arch_prepare_kretprobe(struct kretprobe_instance *ri,
>  				   struct pt_regs *regs);
>  extern int arch_trampoline_kprobe(struct kprobe *p);
> @@ -240,16 +251,6 @@ static inline int arch_trampoline_kprobe(struct kprobe *p)
>  
>  extern struct kretprobe_blackpoint kretprobe_blacklist[];
>  
> -static inline void kretprobe_assert(struct kretprobe_instance *ri,
> -	unsigned long orig_ret_address, unsigned long trampoline_address)
> -{
> -	if (!orig_ret_address || (orig_ret_address == trampoline_address)) {
> -		printk("kretprobe BUG!: Processing kretprobe %p @ %p\n",
> -				ri->rp, ri->rp->kp.addr);
> -		BUG();
> -	}
> -}
> -
>  #ifdef CONFIG_KPROBES_SANITY_TEST
>  extern int init_test_probes(void);
>  #else
> @@ -340,7 +341,6 @@ struct kprobe *get_kprobe(void *addr);
>  void kretprobe_hash_lock(struct task_struct *tsk,
>  			 struct hlist_head **head, unsigned long *flags);
>  void kretprobe_hash_unlock(struct task_struct *tsk, unsigned long *flags);
> -struct hlist_head * kretprobe_inst_table_head(struct task_struct *tsk);
>  
>  /* kprobe_running() will just return the current_kprobe on this CPU */
>  static inline struct kprobe *kprobe_running(void)
> @@ -384,12 +384,60 @@ int enable_kprobe(struct kprobe *kp);
>  
>  void dump_kprobe(struct kprobe *kp);
>  
> +static inline int disable_jprobe(struct jprobe *jp)
> +{
> +	return disable_kprobe(&jp->kp);
> +}
> +
> +static inline int enable_jprobe(struct jprobe *jp)
> +{
> +	return enable_kprobe(&jp->kp);
> +}
> +
> +#ifdef CONFIG_KRETPROBES
> +static inline int disable_kretprobe(struct kretprobe *rp)
> +{
> +	return disable_kprobe(&rp->kp);
> +}
> +
> +static inline int enable_kretprobe(struct kretprobe *rp)
> +{
> +	return enable_kprobe(&rp->kp);
> +}
> +
> +#else /* CONFIG_KRETPROBES */
> +static inline int disable_kretprobe(struct kretprobe *rp)
> +{
> +	return -EINVAL;
> +}
> +static inline int enable_kretprobe(struct kretprobe *rp)
> +{
> +	return -EINVAL;
> +}
> +#endif /* CONFIG_KRETPROBES */
> +
>  #else /* !CONFIG_KPROBES: */
>  
>  static inline int kprobes_built_in(void)
>  {
>  	return 0;
>  }
> +static inline int kprobe_gone(struct kprobe *p)
> +{
> +	return 1;
> +}
> +static inline int kprobe_disabled(struct kprobe *p)
> +{
> +	return 1;
> +}
> +static inline int kprobe_optimized(struct kprobe *p)
> +{
> +	return 0;
> +}
> +static inline int kprobe_ftrace(struct kprobe *p)
> +{
> +	return 0;
> +}
>  static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
>  {
>  	return 0;
> @@ -458,22 +506,22 @@ static inline int enable_kprobe(struct kprobe *kp)
>  {
>  	return -ENOSYS;
>  }
> -#endif /* CONFIG_KPROBES */
> -static inline int disable_kretprobe(struct kretprobe *rp)
> +static inline int disable_jprobe(struct jprobe *jp)
>  {
> -	return disable_kprobe(&rp->kp);
> +	return -ENOSYS;
>  }
> -static inline int enable_kretprobe(struct kretprobe *rp)
> +static inline int enable_jprobe(struct jprobe *jp)
>  {
> -	return enable_kprobe(&rp->kp);
> +	return -ENOSYS;
>  }
> -static inline int disable_jprobe(struct jprobe *jp)
> +static inline int disable_kretprobe(struct kretprobe *rp)
>  {
> -	return disable_kprobe(&jp->kp);
> +	return -ENOSYS;
>  }
> -static inline int enable_jprobe(struct jprobe *jp)
> +static inline int enable_kretprobe(struct kretprobe *rp)
>  {
> -	return enable_kprobe(&jp->kp);
> +	return -ENOSYS;
>  }
> +#endif /* CONFIG_KPROBES */
>  
>  #endif /* _LINUX_KPROBES_H */
> 


-- 
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



  reply	other threads:[~2014-02-05  7:51 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-01 12:17 [PATCH] kernel/kprobes.c: move cleanup_rp_inst() to where CONFIG_KRETPROBES enabled Chen Gang
2014-02-02  2:40 ` Masami Hiramatsu
2014-02-03 11:48   ` Chen Gang
2014-02-03 15:42     ` Masami Hiramatsu
2014-02-04  2:25       ` Chen Gang
2014-02-04  5:16         ` [PATCH] kernel: kprobe: move all *kretprobe* generic implementation to CONFIG_KRETPROBES enabled area Chen Gang
2014-02-04  7:17           ` Masami Hiramatsu
2014-02-04 11:58             ` Chen Gang
2014-02-04 12:07             ` Chen Gang
2014-02-04 13:29               ` Masami Hiramatsu
2014-02-04 13:53                 ` Chen Gang
2014-02-04 15:39                   ` Masami Hiramatsu
2014-02-05  0:18                     ` Chen Gang
2014-02-05  1:21                       ` Masami Hiramatsu
2014-02-05  3:08                         ` Chen Gang
2014-02-05  3:36                           ` [PATCH] kernel/kprobes.c: move kretprobe implementation to CONFIG_KRETPROBES area Chen Gang
2014-02-05  5:00                             ` Masami Hiramatsu
2014-02-05  5:08                               ` Chen Gang
2014-02-05  5:27                               ` [PATCH] include/linux/kprobes.h: move all functions to their matched area Chen Gang
2014-02-05  7:51                                 ` Masami Hiramatsu [this message]
2014-02-05 11:12                                   ` Chen Gang
2014-02-05  4:57                           ` [PATCH] kernel: kprobe: move all *kretprobe* generic implementation to CONFIG_KRETPROBES enabled area Masami Hiramatsu
2014-02-05  5:13                             ` Chen Gang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52F1ED6D.6060503@hitachi.com \
    --to=masami.hiramatsu.pt@hitachi.com \
    --cc=ananth@in.ibm.com \
    --cc=anil.s.keshavamurthy@intel.com \
    --cc=davem@davemloft.net \
    --cc=egtvedt@samfundet.no \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=hskinnemoen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=yrl.pp-manager.tt@hitachi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).