linux/Documentation
Linus Torvalds 105ff3cbf2 atomic: remove all traces of READ_ONCE_CTRL() and atomic*_read_ctrl()
This seems to be a mis-reading of how alpha memory ordering works, and
is not backed up by the alpha architecture manual.  The helper functions
don't do anything special on any other architectures, and the arguments
that support them being safe on other architectures also argue that they
are safe on alpha.

Basically, the "control dependency" is between a previous read and a
subsequent write that is dependent on the value read.  Even if the
subsequent write is actually done speculatively, there is no way that
such a speculative write could be made visible to other cpu's until it
has been committed, which requires validating the speculation.

Note that most weakely ordered architectures (very much including alpha)
do not guarantee any ordering relationship between two loads that depend
on each other on a control dependency:

    read A
    if (val == 1)
        read B

because the conditional may be predicted, and the "read B" may be
speculatively moved up to before reading the value A.  So we require the
user to insert a smp_rmb() between the two accesses to be correct:

    read A;
    if (A == 1)
        smp_rmb()
        read B

Alpha is further special in that it can break that ordering even if the
*address* of B depends on the read of A, because the cacheline that is
read later may be stale unless you have a memory barrier in between the
pointer read and the read of the value behind a pointer:

    read ptr
    read offset(ptr)

whereas all other weakly ordered architectures guarantee that the data
dependency (as opposed to just a control dependency) will order the two
accesses.  As a result, alpha needs a "smp_read_barrier_depends()" in
between those two reads for them to be ordered.

The coontrol dependency that "READ_ONCE_CTRL()" and "atomic_read_ctrl()"
had was a control dependency to a subsequent *write*, however, and
nobody can finalize such a subsequent write without having actually done
the read.  And were you to write such a value to a "stale" cacheline
(the way the unordered reads came to be), that would seem to lose the
write entirely.

So the things that make alpha able to re-order reads even more
aggressively than other weak architectures do not seem to be relevant
for a subsequent write.  Alpha memory ordering may be strange, but
there's no real indication that it is *that* strange.

Also, the alpha architecture reference manual very explicitly talks
about the definition of "Dependence Constraints" in section 5.6.1.7,
where a preceding read dominates a subsequent write.

Such a dependence constraint admittedly does not impose a BEFORE (alpha
architecture term for globally visible ordering), but it does guarantee
that there can be no "causal loop".  I don't see how you could avoid
such a loop if another cpu could see the stored value and then impact
the value of the first read.  Put another way: the read and the write
could not be seen as being out of order wrt other cpus.

So I do not see how these "x_ctrl()" functions can currently be necessary.

I may have to eat my words at some point, but in the absense of clear
proof that alpha actually needs this, or indeed even an explanation of
how alpha could _possibly_ need it, I do not believe these functions are
called for.

And if it turns out that alpha really _does_ need a barrier for this
case, that barrier still should not be "smp_read_barrier_depends()".
We'd have to make up some new speciality barrier just for alpha, along
with the documentation for why it really is necessary.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul E McKenney <paulmck@us.ibm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-03 17:22:17 -08:00
..
ABI xen: features and fixes for 4.3-rc0 2015-09-08 11:46:48 -07:00
DocBook pwm: Changes for v4.3-rc1 2015-09-09 10:55:32 -07:00
EDID
PCI
RCU Merge branches 'doc.2015.10.06a', 'percpu-rwsem.2015.10.06a' and 'torture.2015.10.06a' into HEAD 2015-10-07 16:06:25 -07:00
accounting
acpi ACPI / Documentation: Update method tracing documentation. 2015-08-07 02:42:22 +02:00
aoe
arm Merge branch 'core-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 15:05:52 -08:00
arm64 arm64: Update booting requirements for GICv3 in GICv2 mode 2015-10-09 22:16:57 +01:00
auxdisplay
backlight
blackfin
block Documentation: update notes in biovecs about arbitrarily sized bios 2015-08-13 12:32:07 -06:00
blockdev zsmalloc: account the number of compacted pages 2015-09-08 15:35:28 -07:00
bus-devices
cdrom
cgroups Merge branch 'for-4.3/blkcg' of git://git.kernel.dk/linux-block 2015-09-10 18:56:14 -07:00
cma
connector
console
cpu-freq cpufreq: remove redundant CPUFREQ_INCOMPATIBLE notifier event 2015-09-01 15:50:38 +02:00
cpuidle
cris
crypto
development-process
device-mapper dm snapshot: add new persistent store option to support overflow 2015-10-09 16:57:03 -04:00
devicetree Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 14:40:01 -08:00
dmaengine Documentation: dmaengine: Add DMA_CTRL_REUSE documentation 2015-08-17 13:46:22 +05:30
driver-model
dvb
early-userspace
extcon
fault-injection futex: Fault/error injection capabilities 2015-07-20 11:45:45 +02:00
fb Documentation/fb: add documentation for sm712fb 2015-08-07 15:05:01 -07:00
features Documentation/features/vm: THP now supported by ARC 2015-10-17 17:48:19 +05:30
filesystems fs/proc, core/debug: Don't expose absolute kernel addresses via wchan 2015-10-01 12:55:34 +02:00
firmware_class
fmc
frv
gpio gpio: add a real time compliance notes 2015-10-27 11:13:42 +01:00
hid
hwmon hwmon: (lm75) Add support for TMP75C 2015-10-14 07:57:14 -07:00
i2c i2c: support 10 bit and slave addresses in sysfs 'new_device' 2015-08-24 14:05:15 +02:00
ia64
ide
infiniband IB/hfi1: add driver files 2015-08-28 22:59:36 -04:00
input Input: fix typo in MT documentation 2015-09-19 11:39:02 -07:00
ioctl platform-drivers-x86 for 4.3-1 2015-09-08 16:26:18 -07:00
isdn
ja_JP
kbuild modsign: Allow password to be specified for signing key 2015-08-07 16:26:14 +01:00
kdump
ko_KR
laptops
leds Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds 2015-07-01 19:09:11 -07:00
locking Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 16:10:43 -08:00
m68k
memory-devices
metag
mic Char/Misc driver patches for 4.2-rc1 2015-06-26 14:51:15 -07:00
mips
misc-devices mei: add async event notification ioctls 2015-08-03 17:30:00 -07:00
mmc mmc: core: Remove MMC_CLKGATE 2015-10-26 16:00:09 +01:00
mn10300
mtd
namespaces
netlabel
networking net: Add documentation for VRF device 2015-09-17 16:06:43 -07:00
nfc
nios2
nvdimm libnvdimm: Non-Volatile Devices 2015-06-26 11:23:38 -04:00
nvmem Documentation: nvmem: add nvmem api level and how-to doc 2015-08-05 13:43:45 -07:00
parisc
pcmcia pcmcia: Fix typo in locking documentation 2015-08-07 14:34:58 +02:00
phy
platform
power PCI / PM: Update runtime PM documentation for PCI devices 2015-09-25 02:48:44 +02:00
powerpc SCSI misc on 20150901 2015-09-02 12:22:54 -07:00
pps Doc: pps: Fix file name in pps.txt 2015-07-14 12:35:42 -06:00
prctl
pti
ptp testptp: Silence compiler warnings on ppc64 2015-09-29 21:16:56 -07:00
rapidio
s390 KVM: s390: remove outdated documentation 2015-07-29 11:02:35 +02:00
scheduler
scsi Merge branch 'for-4.2/sg' of git://git.kernel.dk/linux-block 2015-06-25 15:22:36 -07:00
security Merge branch 'smack-for-4.3' of https://github.com/cschaufler/smack-next into next 2015-08-11 11:18:53 +10:00
serial
sh
sound
spi
sysctl net: qdisc: enhance default_qdisc documentation 2015-09-17 16:09:22 -07:00
target Documentation/target: Fix tcm_mod_builder.py build breakage 2015-07-24 17:48:55 -07:00
thermal thermal: power_allocator: relax the requirement of two passive trip points 2015-09-14 07:41:45 -07:00
timers
tpm
trace Mostly this is just clean ups and micro optimizations. 2015-09-08 14:04:14 -07:00
usb Revert "usb: interface authorization: Documentation part" 2015-08-18 09:57:15 -07:00
vDSO
video4linux
virtual Patch queue for ppc - 2015-08-22 2015-08-22 14:57:59 -07:00
vm proc: export idle flag via kpageflags 2015-09-10 13:29:01 -07:00
w1
watchdog Documentation/watchdog: add timeout and ping rate control to watchdog-test.c 2015-09-09 21:33:36 +02:00
wimax
x86 Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-09-01 10:07:40 -07:00
xtensa
zh_CN Documentation updates for 4.2 2015-06-24 20:01:36 -07:00
00-INDEX
BUG-HUNTING
Changes MODSIGN: Change from CMS to PKCS#7 signing if the openssl is too old 2015-09-25 16:31:46 +01:00
CodeOfConflict
CodingStyle Documentation: CodingStyle: remove broken links in the References section 2015-07-10 13:54:34 -06:00
DMA-API-HOWTO.txt Documentation updates for 4.2 2015-06-24 20:01:36 -07:00
DMA-API.txt mm: add dma_pool_zalloc() call to DMA API 2015-09-08 15:35:28 -07:00
DMA-ISA-LPC.txt
DMA-attributes.txt
HOWTO docs: update HOWTO for 3.x -> 4.x versioning 2015-08-24 11:28:17 -06:00
IPMI.txt
IRQ-affinity.txt
IRQ-domain.txt irqdomain: Documentation updates 2015-10-13 19:01:25 +02:00
IRQ.txt
Intel-IOMMU.txt x86/vt-d: Fix documentation of DRHD 2015-08-25 10:44:49 +02:00
Makefile
ManagementStyle
SAK.txt
SM501.txt
SecurityBugs
SubmitChecklist
SubmittingDrivers
SubmittingPatches Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2015-09-01 18:46:42 -07:00
VGA-softcursor.txt
adding-syscalls.txt Documentation: describe how to add a system call 2015-08-13 17:54:06 -06:00
applying-patches.txt
assoc_array.txt
atomic_ops.txt locking/atomics, cmpxchg: Privatize the inclusion of asm/cmpxchg.h 2015-09-13 10:35:46 +02:00
bad_memory.txt
basic_profiling.txt
bcache.txt
binfmt_misc.txt
braille-console.txt
bt8xxgpio.txt
btmrvl.txt
bus-virt-phys-mapping.txt
cachetlb.txt
circular-buffers.txt
clk.txt clk: change clk_ops' ->determine_rate() prototype 2015-07-27 18:12:01 -07:00
coccinelle.txt
cpu-hotplug.txt
cpu-load.txt
cputopology.txt
crc32.txt
dcdbas.txt
debugging-modules.txt
debugging-via-ohci1394.txt
dell_rbu.txt
devices.txt
digsig.txt
dma-buf-sharing.txt
dontdiff
dynamic-debug-howto.txt
edac.txt Documentation/EDAC: Add reference documents section for amd64_edac 2015-09-29 13:42:41 +02:00
efi-stub.txt
eisa.txt
email-clients.txt fix Evolution submenu name in email-clients.txt 2015-07-24 15:05:57 +02:00
flexible-arrays.txt
futex-requeue-pi.txt
gcov.txt
gdb-kernel-debugging.txt
highuid.txt
hsi.txt
hw_random.txt
hwspinlock.txt
init.txt
initrd.txt
intel_txt.txt
io-mapping.txt
io_ordering.txt
iostats.txt
irqflags-tracing.txt
isapnp.txt
java.txt
kasan.txt
kernel-doc-nano-HOWTO.txt Documenation: Update location of docproc.c 2015-07-14 12:36:39 -06:00
kernel-docs.txt
kernel-parameters.txt Merge branch 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 15:40:38 -08:00
kernel-per-CPU-kthreads.txt
kmemcheck.txt
kmemleak.txt
kobject.txt
kprobes.txt
kref.txt
kselftest.txt
ldm.txt
local_ops.txt
lockup-watchdogs.txt watchdog: add watchdog_cpumask sysctl to assist nohz 2015-06-24 17:49:40 -07:00
logo.gif
logo.txt
lzo.txt
magic-number.txt
mailbox.txt Documentation: minor typo fix in mailbox.txt 2015-08-13 18:03:18 -06:00
md-cluster.txt md-cluster: fix deadlock issue on message lock 2015-08-31 19:41:41 +02:00
md.txt
media-framework.txt
memory-barriers.txt atomic: remove all traces of READ_ONCE_CTRL() and atomic*_read_ctrl() 2015-11-03 17:22:17 -08:00
memory-hotplug.txt
men-chameleon-bus.txt Documentation: Minor changes to men-chameleon-bus.txt 2015-07-24 15:15:17 +02:00
module-signing.txt Move certificate handling to its own directory 2015-08-14 16:06:13 +01:00
mono.txt
nommu-mmap.txt
ntb.txt NTB: Rename Intel code names to platform names 2015-07-04 14:09:25 -04:00
numastat.txt
oops-tracing.txt
padata.txt
parport-lowlevel.txt
parport.txt
percpu-rw-semaphore.txt
phy.txt
pi-futex.txt
pinctrl.txt
pnp.txt
preempt-locking.txt
printk-formats.txt
pwm.txt
ramoops.txt
rbtree.txt
remoteproc.txt
rfkill.txt
robust-futex-ABI.txt
robust-futexes.txt
rpmsg.txt
rtc.txt
serial-console.txt
sgi-ioc4.txt
smsc_ece1099.txt
sparse.txt
stable_api_nonsense.txt
stable_kernel_rules.txt
static-keys.txt locking/static_keys: Fix up the static keys documentation 2015-09-15 07:12:06 +02:00
svga.txt
sysfs-rules.txt
sysrq.txt mm, oom: do not panic for oom kills triggered from sysrq 2015-09-08 15:35:28 -07:00
this_cpu_ops.txt
unaligned-memory-access.txt
unicode.txt
unshare.txt
vfio.txt
vgaarbiter.txt
video-output.txt
vme_api.txt
volatile-considered-harmful.txt
workqueue.txt
xillybus.txt
xz.txt
zorro.txt