Re: [PATCH v2 11/27] ftrace: Allow subops filtering to be modified

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

 



On Mon, 3 Jun 2024 10:52:50 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> On Mon, 3 Jun 2024 11:37:23 +0900
> Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx> wrote:
> 
> > On Sat, 01 Jun 2024 23:37:55 -0400
> > Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > 
> > [...]
> > >  
> > > +static int ftrace_hash_move_and_update_subops(struct ftrace_ops *subops,
> > > +					      struct ftrace_hash **orig_subhash,
> > > +					      struct ftrace_hash *hash,
> > > +					      int enable)
> > > +{
> > > +	struct ftrace_ops *ops = subops->managed;
> > > +	struct ftrace_hash **orig_hash;
> > > +	struct ftrace_hash *save_hash;
> > > +	struct ftrace_hash *new_hash;
> > > +	int ret;
> > > +
> > > +	/* Manager ops can not be subops (yet) */
> > > +	if (WARN_ON_ONCE(!ops || ops->flags & FTRACE_OPS_FL_SUBOP))
> > > +		return -EINVAL;  
> > 
> > This does return if ops->flags & FTRACE_OPS_FL_SUBOP, but --> (1)
> 
> Yes, because what is passed in is "subops" and "ops" is subops->managed.

Ah, I missed that point. OK, I got it.


> 
> > 
> > > +
> > > +	/* Move the new hash over to the subops hash */
> > > +	save_hash = *orig_subhash;
> > > +	*orig_subhash = __ftrace_hash_move(hash);
> > > +	if (!*orig_subhash) {
> > > +		*orig_subhash = save_hash;
> > > +		return -ENOMEM;
> > > +	}
> > > +
> > > +	/* Create a new_hash to hold the ops new functions */
> > > +	if (enable) {
> > > +		orig_hash = &ops->func_hash->filter_hash;
> > > +		new_hash = append_hashes(ops);
> > > +	} else {
> > > +		orig_hash = &ops->func_hash->notrace_hash;
> > > +		new_hash = intersect_hashes(ops);
> > > +	}
> > > +
> > > +	/* Move the hash over to the new hash */
> > > +	ret = ftrace_hash_move_and_update_ops(ops, orig_hash, new_hash, enable);  

So this `ops` is managed ops of this subops.

> > 
> > This also a bit wired to me. maybe we need simple version like
> > 
> > `__ftrace_hash_move_and_update_ops()`
> > 
> > And call it from ftrace_hash_move_and_update_ops() and here?
> 
> We could do that. I almost did due to other issues but I reworked the code
> where I didn't need to.
> 
> > 
> > > +
> > > +	free_ftrace_hash(new_hash);
> > > +
> > > +	if (ret) {
> > > +		/* Put back the original hash */
> > > +		free_ftrace_hash_rcu(*orig_subhash);
> > > +		*orig_subhash = save_hash;
> > > +	} else {
> > > +		free_ftrace_hash_rcu(save_hash);
> > > +	}
> > > +	return ret;
> > > +}
> > > +
> > > +
> > >  static u64		ftrace_update_time;
> > >  unsigned long		ftrace_update_tot_cnt;
> > >  unsigned long		ftrace_number_of_pages;
> > > @@ -4770,8 +4823,33 @@ static int ftrace_hash_move_and_update_ops(struct ftrace_ops *ops,
> > >  {
> > >  	struct ftrace_ops_hash old_hash_ops;
> > >  	struct ftrace_hash *old_hash;
> > > +	struct ftrace_ops *op;
> > >  	int ret;
> > >  
> > > +	if (ops->flags & FTRACE_OPS_FL_SUBOP)
> > > +		return ftrace_hash_move_and_update_subops(ops, orig_hash, hash, enable);  
> > 
> > (1) This calls ftrace_hash_move_and_update_subops() if ops->flags & FTRACE_OPS_FL_SUBOP ?
> 
> Yes, because ops turns into subops, and the ops above it is its manager ops.

Ah, OK. This `ops` is a subops. 


Thank you,

> 
> -- Steve
> 


-- 
Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux