Linux Trace Kernel
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Crystal Wood <crwood@redhat.com>
Cc: Tomas Glozar <tglozar@redhat.com>, John Kacur <jkacur@redhat.com>,
	linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v7 05/10] tracing/osnoise: Per-cpu mutexes and fd detachment
Date: Wed, 25 Nov 2026 09:16:12 -0500	[thread overview]
Message-ID: <20261125091612.5458e933@gandalf.local.home> (raw)
In-Reply-To: <20261125090122.22fdb88d@gandalf.local.home>

On Wed, 25 Nov 2026 09:01:22 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

Hi Crystal,

> >  static int timerlat_fd_open(struct inode *inode, struct file *file)
> >  {
> > +	struct fd_data *fdd;
> >  	struct osnoise_variables *osn_var;
> >  	struct timerlat_variables *tlat;
> >  	long cpu = (long) inode->i_cdev;
> > +	int ret = 0;
> >  
> >  	mutex_lock(&interface_lock);  
> 
> Hmm, if we switch this to:
> 
> 	guard(mutex)(&interface_lock);


I see now that patch 8 does this.

Can you make the guard conversions first, and then do updates. I rather not
have patches that add gotos just to be removed later in the series.

Thanks,

-- Steve

> 	
> >  
> > @@ -2437,16 +2495,16 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
> >  	migrate_disable();  
> 
> and this to:
> 
> 	guard(migrate)();
> 
> >  
> >  	osn_var = this_cpu_osn_var();
> > +	tlat = this_cpu_tmr_var();
> > +	mutex_lock(&osn_var->lock);  
> 
> and use:
> 
> 	guard(mutex)(&osn_var->lock);
> 
> >  
> > -	/*
> > -	 * The osn_var->pid holds the single access to this file.
> > -	 */
> > -	if (osn_var->pid) {
> > -		mutex_unlock(&interface_lock);
> > -		migrate_enable();
> > -		return -EBUSY;
> > +	if (osn_var->fdd) {
> > +		ret = -EBUSY;
> > +		goto err;  
> 
> 	this could simply be:
> 
> 	if (osn_var->fdd)
> 		return -EBUSY;
> 
> 
> >  	}
> >  
> > +	WARN_ON_ONCE(osn_var->kthread);
> > +
> >  	/*
> >  	 * timerlat tracer is a per-cpu tracer. Check if the user-space too
> >  	 * is pinned to a single CPU. The tracer laters monitor if the task
> > @@ -2455,33 +2513,47 @@ static int timerlat_fd_open(struct inode *inode, struct file *file)
> >  	 * setup.
> >  	 */
> >  	if (current->nr_cpus_allowed > 1 ||  cpu != smp_processor_id()) {  
> 
> 		return -EPERM;
> 
> > -		mutex_unlock(&interface_lock);
> > -		migrate_enable();
> > -		return -EPERM;
> > +		ret = -EPERM;
> > +		goto err;
> > +	}
> > +
> > +	fdd = kmalloc(sizeof(*fdd), GFP_KERNEL);
> > +	if (!fdd) {  
> 
> 		return -ENOMEM;
> 
> > +		ret = -ENOMEM;
> > +		goto err;
> >  	}
> >  
> >  	/*
> >  	 * From now on, it is good to go.
> >  	 */
> > -	file->private_data = inode->i_cdev;
> > +	fdd->thread = current;
> > +	fdd->detach = timerlat_fd_detach;
> > +	fdd->cpu = cpu;
> > +	file->private_data = fdd;
> >  
> > +	tlat->tracing_thread = false;
> > +	tlat->thread = current;
> >  	get_task_struct(current);
> >  
> > -	osn_var->kthread = current;
> >  	osn_var->pid = current->pid;
> > +	osn_var->fdd = fdd;
> > +
> > +	hrtimer_setup(&tlat->timer, timerlat_irq, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_PINNED_HARD);
> >    
> 
> 

  reply	other threads:[~2026-11-25 14:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  6:40 [PATCH v7 00/10] tracing/osnoise: Synchronization fixes Crystal Wood
2026-11-13  6:40 ` [PATCH v7 01/10] tracing/osnoise: Variable cleanup Crystal Wood
2026-11-25 14:06   ` Steven Rostedt
2026-11-13  6:40 ` [PATCH v7 02/10] tracing/osnoise: start_kthread: Always check OSN_WORKLOAD Crystal Wood
2026-11-25 13:49   ` Steven Rostedt
2026-11-13  6:40 ` [PATCH v7 03/10] tracing/osnoise: Start all eligible cpus from hotplug workfn Crystal Wood
2026-11-13  6:51   ` sashiko-bot
2026-11-13  6:40 ` [PATCH v7 04/10] tracing/osnoise: Hold a ref on osn->kthread Crystal Wood
2026-11-13  6:40 ` [PATCH v7 05/10] tracing/osnoise: Per-cpu mutexes and fd detachment Crystal Wood
2026-11-13  7:14   ` sashiko-bot
2026-11-13 20:23     ` Crystal Wood
2026-11-25 14:01   ` Steven Rostedt
2026-11-25 14:16     ` Steven Rostedt [this message]
2026-11-13  6:40 ` [PATCH v7 06/10] tracing/osnoise: Reset cleanup Crystal Wood
2026-11-13  7:20   ` sashiko-bot
2026-11-13 20:38     ` Crystal Wood
2026-11-13  6:41 ` [PATCH v7 07/10] tracing/osnoise: kthreads: Verify CPU after migrate_disable() Crystal Wood
2026-11-13  6:41 ` [PATCH v7 08/10] tracing/osnoise: Take trace_types_lock in timerlat_fd_open Crystal Wood
2026-11-25 14:14   ` Steven Rostedt
2026-11-13  6:41 ` [PATCH v7 09/10] tracing/osnoise: Print taint message for timerlat Crystal Wood
2026-11-13  6:41 ` [PATCH v7 10/10] tracing/osnoise: Refuse timerlat fd open if tracer inactive Crystal Wood
2026-11-13  6:55   ` sashiko-bot

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=20261125091612.5458e933@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=crwood@redhat.com \
    --cc=jkacur@redhat.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=tglozar@redhat.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