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] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.11.1407160944280.19597@gentwo.org>
Date:	Wed, 16 Jul 2014 09:49:06 -0500 (CDT)
From:	Christoph Lameter <cl@...two.org>
To:	Pranith Kumar <bobby.prani@...il.com>
cc:	Randy Dunlap <rdunlap@...radead.org>,
	"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
	open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] doc: Add remote CPU access details to
 this_cpu_ops.txt

On Tue, 15 Jul 2014, Pranith Kumar wrote:

> +The following this_cpu() operations with implied preemption protection
> +are defined. These operations can be used without worrying about
> +preemption.  Note that interrupts may still occur while an operation is

preemption and interrupts.

> +in progress and if the interrupt too modifies the variable, then RMW
> +actions may not be atomic.

These are guaranteed to be atomic vs interrupts too. The __this_cpu ops
do not have that guarantee.

>  Operations on a field of a per cpu structure
> @@ -178,10 +207,26 @@ replaced by code that disables interrupts, then does the operations
>  that are guaranteed to be atomic and then reenable interrupts. Doing
>  so is expensive. If there are other reasons why the scheduler cannot
>  change the processor we are executing on then there is no reason to
> -disable interrupts. For that purpose the __this_cpu operations are
> -provided. For example.
> +disable interrupts. For that purpose the following __this_cpu operations
> +are provided.

These operations have no guarantee against concurrent interrupts or
preemption. If a per cpu variable is not used in an interrupt context and
the scheduler cannot preempt then they are safe.

> +Remote access to per-CPU data
> +------------------------------
> +
> +Per cpu data structures are for the use of one cpu exclusively. If you
> +use the variables as intended, this_cpu_ops() are guaranteed to be
> +atomic as no other CPU has access to these data structures. But there are

atomic is a strong term here. Maybe put in ""?

> +special cases where you might need to access per cpu data structures
> +remotely. One such case is to perform maintenance tasks of idle CPUs
> +without having to wake them up using IPIs for power saving purposes.

It is usually safe to do read access and that is frequenly done to
summarize counters. Write access is problematic.

> +To access per-cpu data structure remotely, you need to convert the
> +per-cpu offset to a pointer using this_cpu_ptr().
> +
> +	DEFINE_PER_CPU(struct data, datap);
> +	struct data *p = this_cpu_ptr(&datap);
> +
> +p can now be passed to another CPU to be updated remotely.

That is not the way its usually done. You would use\

p = per_cpu(&datap, cpu);

This makes it explicit that we are getting ready to access a foreing
percpu area.

Passing of pointers calculated via this_cpu_ptr to other cpus is unusual
and should be avoided.


> +Such remote accesses to per CPU data are not guaranteed to be atomic
> +anymore. You will have to use atomic_t and rely on the standard atomic
> +operations for these remote accesses to be atomic.
> +
>  Christoph Lameter, April 3rd, 2013

Add your name here too?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ