Find the answer to your Linux question:
Results 1 to 9 of 9
We are constantly writing images from a camera at 4MBytes/s to an SD card (SLC, ext4). After we start writing, the CPU usage jumps by 15-20 percent and stays there. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2014
    Posts
    4

    High CPU usage when writing to files


    We are constantly writing images from a camera at 4MBytes/s to an SD card (SLC, ext4). After we start writing, the CPU usage jumps by 15-20 percent and stays there.

    These writes are spread across up to 13 open file handles. I am using a Texas Instruments distro of kernel 3.2.0 on an embedded ARM platform.

    My understanding is that the writes should mostly be taken care of using DMA, so I am wondering why such high CPU utilization?

    Bryce

  2. #2
    Linux Guru
    Join Date
    Dec 2013
    Posts
    1,574
    DMA doesn't mean the CPU does nothing. It means that while the write is taking place it can do other things. It still initiates and completes the write. DMA makes it possible to write to 13 file descriptors seemingly at the same time.

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,425
    Also io can affect load.
    Imagine a process waiting for data from/to harddisc.
    Look at the iowait metric of e.g. iostat -x

    Sent from my GT-I9505 using Tapatalk
    You must always face the curtain with a bow.

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Apr 2014
    Posts
    4
    I appreciate the response. Yes, I agree that there would be some CPU usage (i.e. setup prior to each DMA block transfer), but I wouldn't think it would take +15-20% usage on an 800MHz processor.

  6. #5
    Just Joined!
    Join Date
    Apr 2014
    Posts
    4
    Thanks.

    I have checked iostat:
    Without writing:
    avg-cpu: %user %nice %system %iowait %steal %idle
    53.51 0.00 3.04 0.02 0.00 43.43

    Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
    mmcblk0 0.03 0.11 0.04 47 16
    mmcblk0p1 0.01 0.01 0.00 5 0
    mmcblk0p2 0.01 0.08 0.04 34 16

    With writing
    avg-cpu: %user %nice %system %iowait %steal %idle
    70.63 0.00 6.01 4.57 0.00 18.79

    Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
    mmcblk0 15.68 421.31 6031.97 824567 11805592
    mmcblk0p1 0.00 0.00 0.00 5 0
    mmcblk0p2 15.68 421.30 6031.97 824554 11805592

    Does this mean that the CPU does a busy wait while waiting for I/O (i.e. not blocking)?

    Also, this may account for 5%, but would the other 10-15% really be used for DMA block transfer setups? It seems high.

  7. #6
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,425
    Sorry, should have been more clear.
    Keep iostat updating with iostat -x 1 while testing.

    Sent from my GT-I9505 using Tapatalk
    You must always face the curtain with a bow.

  8. #7
    Just Joined!
    Join Date
    Apr 2014
    Posts
    4
    OK. Here is last of the "iostat 1 100" (run once per second 100 times) while we are writing images to the SD Card. My version of iostat doesn't have the -x option.

    avg-cpu: %user %nice %system %iowait %steal %idle
    80.04 0.00 6.05 10.24 0.00 3.67

  9. #8
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,425
    You should have 100 values.
    But the one sample kind of matches. 10% of the load is due to iowait.
    You must always face the curtain with a bow.

  10. #9
    Linux Engineer docbop's Avatar
    Join Date
    Nov 2009
    Location
    Woodshed, CA
    Posts
    949
    SD cards are not a fast interface so probably an IO bottleneck. Also CPU jumps are no big deal it's when they pin and stay pinned are they an issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •