lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210618150020.689439d4@oasis.local.home>
Date:   Fri, 18 Jun 2021 15:00:20 -0400
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Daniel Bristot de Oliveira <bristot@...hat.com>
Cc:     Phil Auld <pauld@...hat.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Kate Carcia <kcarcia@...hat.com>,
        Jonathan Corbet <corbet@....net>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Alexandre Chartre <alexandre.chartre@...cle.com>,
        Clark Willaims <williams@...hat.com>,
        John Kacur <jkacur@...hat.com>,
        Juri Lelli <juri.lelli@...hat.com>,
        Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH V4 05/12] trace/hwlat: Support hotplug operations

On Fri, 18 Jun 2021 12:45:03 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:

> > +/*
> > + * hwlat_cpu_init - CPU hotplug online callback function
> > + */
> > +static int hwlat_cpu_init(unsigned int cpu)
> > +{
> > +	struct trace_array *tr = hwlat_trace;
> > +  
> 
> You need to take the trace_types_lock here, between testing the
> hwlat_busy and starting the threads. Otherwise, between the two, the
> hwlat tracer could be turned off while a CPU is coming on line, and
> then you just started a per cpu thread, while the hwlat tracer is not
> enabled.

And of course, because get_online_cpus() is called within
trace_types_lock, doing this check is going to cause a lock inversion.

The only thing I could think of is to wake up a worker thread to do the
work. That is, this just wakes the worker thread, then the worker grabs
the trace_types_lock, iterates through the cpu mask of expect running
threads, and then starts or kills them depending on the hwlat_busy
value.

-- Steve

> 
> > +	if (!hwlat_busy)
> > +		return 0;
> > +
> > +	if (!cpumask_test_cpu(cpu, tr->tracing_cpumask))
> > +		return 0;
> > +
> > +	return start_cpu_kthread(cpu);
> > +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ