Cache

3 Posts

Why Cache, Memory Barriers, and DMA Often Break Drivers

8 minute

Some driver bugs feel almost random.

The CPU has written a descriptor, but the device reads old contents. The DMA completion interrupt has fired, but the driver still reads stale buffer data. Adding one log line makes the bug disappear. Changing optimization brings it back. It worked on a single-core MCU, then fails occasionally on an SoC with cache.

These bugs are often not caused by “broken DMA” or “an aggressive compiler.” They happen because several different guarantees were mixed together.

Read More

Why DMA and Cache Can Make Data Inconsistent

8 minute

One of the most confusing driver bugs is “the data is clearly in memory, but the other side cannot see it.”

The CPU prepares a transmit buffer, but the network device sends old data. DMA has written received data into memory, but the driver or application still reads stale values. Adding logs makes the issue disappear; changing optimization brings it back.

These bugs are often not because DMA failed or the pointer is wrong. The problem is that CPU cache, DMA device, and memory visibility were not handled correctly.

Read More

CDN

9 minute

What is hard to understand about a CDN is not “it can cache files.” It is that it moves user access points, cache layers, and origin protection out to the network edge. As a result, the first-packet time for the same URL may differ a lot across regions, the origin may be healthy while some users still see old content, and when image or video traffic rises, the first thing to saturate is often not the CPU but the cross-region bandwidth and origin fetch path.

Read More