frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Read_once(), Write_once(), but Not for Rust

https://lwn.net/SubscriberLink/1053142/8ec93e58d5d3cc06/
47•todsacerdoti•2h ago

Comments

gpderetta•1h ago
Very interesting. AFAIK the kernel explicitly gives consume semantics to read_once (and in fact it is not just a compiler barrier on alpha), so technically lowering it to a relaxed operation is wrong.

Does rust have or need the equivalent of std::memory_order_consume? Famously this was deemed unimplementable in C++.

steveklabnik•1h ago
It wasn’t implemented for the same reason. Rust uses C++20 ordering.
gpderetta•1h ago
right, so I would expect that the equivalent of READ_ONCE is converted to an acquire in rust, even if slightly pessimal.

But the article says that the suggestion is to convert them to relaxed loads. Is the expectation to YOLO it and hope that the compiler doesn't break control and data dependencies?

bonzini•1h ago
There is a yolo way that actually works, which would be to change it to a relaxed load followed by an acquire signal fence.
loeg•1h ago
Is that any better than just using an acquire load?
gpderetta•1h ago
It is cheaper on ARM and POWER. But I'm not sure it is always safe. The standard has very complex rules for consume to make sure that the compiler didn't break the dependencies.

edit: and those rules where so complex that compilers decided where not implementable or not worth it.

loeg•1h ago
Does anything care about Alpha? The platform hasn't been sold in 20 years.
gpderetta•1h ago
consume is trivial on alpha, it is the same as acquire (always needs a #LoadLoad). It is also the same as acquire (and relaxed) on x86 and SPARC (a plain load, #LoadLoad is always implied).

The only place where consume matters is on relaxed but not too relaxed architectures like ARM and POWER, where consume relies on the implicit #LoadLoad of controls and data dependencies.

bonzini•38m ago
Also on alpha there's only store-store and full memory barriers. Acquire is very expensive.
jcranmer•53m ago
It's a persistent misunderstanding that release-consume is about Alpha. It's not; in fact, Alpha is one of the few architectures where release-consume doesn't help.

In a TSO architecture like x86 or SPARC, every "regular" memory load/store is effectively a release/acquire by default. Using release/consume or relaxed provides no extra speedup on these architectures. In weak memory models, you need to add in acquire barriers to get release/acquire architectures. But also, most weak memory models have a basic rule that a data-dependent load has an implicit ordering dependency on the values that computed it (most notably, loading *p has an implicit dependency on p).

The goal of release/consume is to be able to avoid having an acquire fence if you have only those dependencies--to promote a hardware data dependency semantic rule to a language-level semantic rule. For Alpha's ultra-weak model, you still need the acquire fence in this mode, it doesn't help Alpha one whit. Unfortunately, for various reasons, no one has been able to work out a language-level semantics for consume that compilers are willing to implement (preserving data dependencies through optimizations is a lot more difficult than it appears), so all compilers have remapped consume to acquire, making it useless.

chrismsimpson•1h ago
> The truth of the matter, though, is that the Rust community seems to want to take a different approach to concurrent data access.

Not knowing anything about development of the kernel, does this kind of thing create a two tier Linux development experience?

zaphar•1h ago
Not sure if it introduces a tiered experience or not. But reading the article it appears that the Rust devs advocated for an api that is clearer in it's semantics with the tradeoff that now understanding how it interacts with C code requires understanding two APIs. How this shakes out in practice remains to be seen.
epolanski•1h ago
What is your take on their names instead of "atomic_read" and "atomic_write"?
gpm•38m ago
The problem with atomic_read and atomic_write is that some people will interpret that as "atomic with a sequentially consistent ordering" and some as "atomic with a relaxed ordering" and everything in between. It's a fine name for a function that takes an argument that specifies memory ordering [1]. It's not great for anything else.

Read_once and Write_once convey that there's more nuance than that, and tries to convey the nuance.

[1] E.g. in rust anything that takes https://doc.rust-lang.org/std/sync/atomic/enum.Ordering.html

bheadmaster•1h ago

    An understanding of READ_ONCE() and WRITE_ONCE() is important for kernel developers who will be dealing with any sort of concurrent access to data. So, naturally, they are almost entirely absent from the kernel's documentation.
Made me chuckle.
semiquaver•34m ago
More chuckles from the source:

   /*
    * Yes, this permits 64-bit accesses on 32-bit architectures. These will
    * actually be atomic in some cases (namely Armv7 + LPAE), but for others we
    * rely on the access being split into 2x32-bit accesses for a 32-bit quantity
    * (e.g. a virtual address) and a strong prevailing wind.
    */

Cloudflare acquires Astro

https://astro.build/blog/joining-cloudflare/
359•todotask2•3h ago•191 comments

6-Day and IP Address Certificates Are Generally Available

https://letsencrypt.org/2026/01/15/6day-and-ip-general-availability
116•jaas•1h ago•37 comments

Michelangelo's first painting, created when he was 12 or 13

https://www.openculture.com/2026/01/discover-michelangelos-first-painting.html
155•bookofjoe•3h ago•101 comments

Just the Browser

https://justthebrowser.com/
327•cl3misch•5h ago•173 comments

Launch HN: Indy (YC S21) – A support app designed for ADHD brains

https://www.shimmer.care/indy-redirect
26•christalwang•1h ago•19 comments

Canada slashes 100% tariffs on Chinese EVs to 6%

https://electrek.co/2026/01/16/canada-breaks-with-us-slashes-100-tariffs-chinese-evs/
74•1970-01-01•26m ago•32 comments

Zep AI (Agent Context Engineering, YC W24) Is Hiring Forward Deployed Engineers

https://www.ycombinator.com/companies/zep-ai/jobs/
1•roseway4•31m ago

Lock-Picking Robot

https://github.com/etinaude/Lock-Picking-Robot
110•p44v9n•4d ago•43 comments

Read_once(), Write_once(), but Not for Rust

https://lwn.net/SubscriberLink/1053142/8ec93e58d5d3cc06/
48•todsacerdoti•2h ago•16 comments

Can You Disable Spotlight and Siri in macOS Tahoe?

https://eclecticlight.co/2026/01/16/can-you-disable-spotlight-and-siri-in-macos-tahoe/
32•chmaynard•2h ago•11 comments

psc: The ps utility, with an eBPF twist and container context

https://github.com/loresuso/psc
45•tanelpoder•4h ago•16 comments

Training my smartwatch to track intelligence

https://dmvaldman.github.io/rooklift/
93•dmvaldman•1d ago•38 comments

OpenBSD-current now runs as guest under Apple Hypervisor

https://www.undeadly.org/cgi?action=article;sid=20260115203619
359•gpi•14h ago•46 comments

List of individual trees

https://en.wikipedia.org/wiki/List_of_individual_trees
280•wilson090•17h ago•99 comments

Interactive eBPF

https://ebpf.party/
149•samuel246•9h ago•6 comments

Cursor's latest "browser experiment" implied success without evidence

https://embedding-shapes.github.io/cursor-implied-success-without-evidence/
36•embedding-shape•2h ago•24 comments

Why DuckDB is my first choice for data processing

https://www.robinlinacre.com/recommend_duckdb/
65•tosh•6h ago•25 comments

Pocket TTS: A high quality TTS that gives your CPU a voice

https://kyutai.org/blog/2026-01-13-pocket-tts
570•pain_perdu•1d ago•129 comments

The spectrum of isolation: From bare metal to WebAssembly

https://buildsoftwaresystems.com/post/guide-to-execution-environments/
71•ThierryBuilds•8h ago•24 comments

Exasol Personal – Democratizing Big Data Analytics

https://www.exasol.com/blog/introducing-exasol-personal/
4•astigsen•4d ago•2 comments

Show HN: mdto.page – Turn Markdown into a shareable webpage instantly

https://mdto.page
23•hjinco•4h ago•14 comments

Briar keeps Iran connected via Bluetooth and Wi-Fi when the internet goes dark

https://briarproject.org/manual/fa/
513•us321•21h ago•321 comments

ICE takes back into custody man released for violation of rights

https://apnews.com/article/minnesota-immigration-crackdown-25e46910fcc62fbf5ab341905af9891c
7•willmarch•11m ago•4 comments

Boeing knew of flaw in part linked to UPS plane crash, NTSB report says

https://www.bbc.com/news/articles/cly56w0p9e1o
230•1659447091•13h ago•114 comments

Inside The Internet Archive's Infrastructure

https://hackernoon.com/the-long-now-of-the-web-inside-the-internet-archives-fight-against-forgetting
414•dvrp•2d ago•97 comments

Show HN: pgwire-replication - pure rust client for Postgres CDC

https://github.com/vnvo/pgwire-replication
34•sacs0ni•5d ago•6 comments

Ask HN: How can we solve the loneliness epidemic?

713•publicdebates•1d ago•1112 comments

Linux boxes via SSH: suspended when disconected

https://shellbox.dev/
271•messh•21h ago•141 comments

Bringing the Predators to Life in MAME

https://lysiwyg.mataroa.blog/blog/bringing-the-predators-to-life-in-mame/
55•msephton•2d ago•9 comments

Altaid 8800 (2024)

https://sunrise-ev.com/8080.htm
31•exvi•4d ago•5 comments