Writing to disk (USB or sdcard) stalls other tasks

Open
#1,753 20 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
20/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
linux, raspberry-pi

Research direction

The report names no kernel files, tests, or entry points. Start by reproducing the stream-writing workload while comparing disk, tmpfs, USB networking, and Ethernet, then trace the kernel writeback and I/O path. Done would be a confirmed cause with a focused diagnostic or actionable kernel fix.

Written by the indexing model from the issue text.

Description

Waiting for external input

Have spent quite some time narrowing this down now, but don't know where to look further.

Background is, I'm using a system that receives a 500kbyte/s h264 video stream via wifi cards in monitor mode. This video stream is then displayed on the Pi and should also be written to an USB memory stick or the internal sd card.

However, the problem is, it's just not possible to record this videostream (about 500kbyte/s) without the video sometimes stuttering. This always happens when there is data being written to a disk (USB stick or internal sdcard doesn't matter).

Have tried now:

  • different Raspbian images, kernel versions, raspberry firmware versions

  • deadline i/o scheduler, cfq, noop, bfq, 1000Hz timer, different preemption options

  • niced/ioniced the tasks

  • different sdcards and usb sticks

  • different filesystems

  • verified that usb and sdcard write speed is good

  • made sure no other background tasks like log rotate or whatever are running

  • tried sync and async mounting options

  • tried all kinds of different vm_dirty_background etc. values to smooth out the writing

  • Some things I probably forgot right now

  • The system is not loaded much, cpu usage is around 10%, no high iowait values etc.

What works fine is: Displaying and writing the same data stream to:

  • A filesystem in RAM (/tmp tmpfs for example)
  • A smartphone connected via USB tethering (usb0 "virtual" network interface)
  • Another computer connected via ethernet (eth0 internal Pi ethernet interface)
  • Another Raspberry via another Ralink wifi card in monitor mode

This looks to me like pdflush (I think that's what it was called some years ago, sorry, my Linux knowledge may not be up-to-date) somehow has too high priority when writing and stalls things out? Or some other disk-access related stuff in the kernel? Or maybe something in the underlying Raspberry firmware?

How could I narrow this down further?

Dominant language
C
Stars
13.2k
Forks
5.5k
Avg merge
2d 21h
Merged PRs (30d)
21

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from raspberrypi/linux

All issues in raspberrypi/linux

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.