problem of SD and cache

Hi,

I've a program that is writing a big file in the SD periodically.

After a long time, I got this error:

why ? How can i fix this problem? Is it the cache ?

[24032.356007] edma 49000000.edma: edma_prep_slave_sg: Failed to
allocate a descriptor
[24032.364121] omap_hsmmc 48060000.mmc: prep_slave_sg() failed
[24032.368114] omap_hsmmc 48060000.mmc: MMC start dma failure
[24032.392355] mmcblk0: unknown error -1 sending read/write command,
card status 0x900
[24032.478884] mmc0: tried to reset card
[24032.479662] mmcqd/0: page allocation failure: order:2, mode:0x2204020
[24032.479678] CPU: 0 PID: 73 Comm: mmcqd/0 Not tainted 4.4.13-bone11 #153
[24032.479686] Hardware name: Generic AM33XX (Flattened Device Tree)
[24032.479738] [<c0014765>] (unwind_backtrace) from [<c0011eb9>]
(show_stack+0x11/0x14)
[24032.479762] [<c0011eb9>] (show_stack) from [<c00d011d>]
(warn_alloc_failed+0xb5/0xf0)
[24032.479780] [<c00d011d>] (warn_alloc_failed) from [<c00d2521>]
(__alloc_pages_nodemask+0x5d1/0x704)
[24032.479801] [<c00d2521>] (__alloc_pages_nodemask) from [<c00fcd57>]
(cache_alloc_refill+0x1eb/0x3ac)
[24032.479815] [<c00fcd57>] (cache_alloc_refill) from [<c00fd369>]
(__kmalloc+0x101/0x120)
[24032.479840] [<c00fd369>] (__kmalloc) from [<c03d6bf3>]
(edma_prep_slave_sg+0x77/0x224)
[24032.479864] [<c03d6bf3>] (edma_prep_slave_sg) from [<c0563afd>]
(omap_hsmmc_request+0x33d/0x3f4)
[24032.479888] [<c0563afd>] (omap_hsmmc_request) from [<c054e813>]
(mmc_start_request+0xcb/0x1ac)
[24032.479904] [<c054e813>] (mmc_start_request) from [<c054f7e3>]
(mmc_start_req+0x1f3/0x2c4)
[24032.479919] [<c054f7e3>] (mmc_start_req) from [<c055ad07>]
(mmc_blk_issue_rw_rq+0x273/0x7ac)
[24032.479932] [<c055ad07>] (mmc_blk_issue_rw_rq) from [<c055b3e3>]
(mmc_blk_issue_rq+0x1a3/0x368)
[24032.479943] [<c055b3e3>] (mmc_blk_issue_rq) from [<c055c79b>]
(mmc_queue_thread+0x77/0x114)
[24032.479966] [<c055c79b>] (mmc_queue_thread) from [<c0040fc3>]
(kthread+0xa3/0xb8)
[24032.479982] [<c0040fc3>] (kthread) from [<c000ea95>]
(ret_from_fork+0x11/0x1c)
[24032.479989] Mem-Info:
[24032.480009] active_anon:35548 inactive_anon:7471 isolated_anon:0
active_file:32682 inactive_file:35639 isolated_file:0
unevictable:0 dirty:9070 writeback:4648 unstable:0
slab_reclaimable:4384 slab_unreclaimable:1977
mapped:19167 shmem:24293 pagetables:345 bounce:0
free:1490 free_pcp:125 free_cma:0
[24032.480049] Normal free:5960kB min:2752kB low:3440kB high:4128kB
active_anon:142192kB inactive_anon:29884kB active_file:130728kB
inactive_file:142556kB unevictable:0kB isolated(anon):0kB
isolated(file):0kB present:524288kB managed:506492kB mlocked:0kB
dirty:36280kB writeback:18592kB mapped:76668kB shmem:97172kB
slab_reclaimable:17536kB slab_unreclaimable:7908kB kernel_stack:1104kB
pagetables:1380kB unstable:0kB bounce:0kB free_pcp:500kB
local_pcp:500kB free_cma:0kB writeback_tmp:0kB pages_scanned:0
all_unreclaimable? no
[24032.480058] lowmem_reserve[]: 0 0 0
[24032.480069] Normal: 576*4kB (UME) 457*8kB (U) 0*16kB 0*32kB 0*64kB
0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 5960kB
[24032.480101] 92614 total pagecache pages
[24032.480113] 0 pages in swap cache
[24032.480119] Swap cache stats: add 0, delete 0, find 0/0
[24032.480124] Free swap = 0kB
[24032.480129] Total swap = 0kB
[24032.480134] 131072 pages RAM
[24032.480138] 0 pages HighMem/MovableOnly
[24032.480144] 4449 pages reserved
[24032.480148] 6144 pages cma reserved
[24032.480165] edma 49000000.edma: edma_prep_slave_sg: Failed to
allocate a descriptor
[24032.488265] omap_hsmmc 48060000.mmc: prep_slave_sg() failed
[24032.492250] omap_hsmmc 48060000.mmc: MMC start dma failure
[24032.533988] mmcblk0: unknown error -1 sending read/write command,
card status 0x900
[24032.544849] EXT4-fs warning (device mmcblk0p1): ext4_end_bio:329:
I/O error -5 writing to inode 3696 (offset 8388608 size 8388608
starting block 2369280)
[24032.556785] mmcqd/0: page allocation failure: order:2, mode:0x2204020
[24032.556814] CPU: 0 PID: 73 Comm: mmcqd/0 Not tainted 4.4.13-bone11 #153
[24032.556821] Hardware name: Generic AM33XX (Flattened Device Tree)
[24032.556874] [<c0014765>] (unwind_backtrace) from [<c0011eb9>]
(show_stack+0x11/0x14)
[24032.556898] [<c0011eb9>] (show_stack) from [<c00d011d>]
(warn_alloc_failed+0xb5/0xf0)
[24032.556917] [<c00d011d>] (warn_alloc_failed) from [<c00d2521>]
(__alloc_pages_nodemask+0x5d1/0x704)
[24032.556938] [<c00d2521>] (__alloc_pages_nodemask) from [<c00fcd57>]
(cache_alloc_refill+0x1eb/0x3ac)
[24032.556952] [<c00fcd57>] (cache_alloc_refill) from [<c00fd369>]
(__kmalloc+0x101/0x120)
[24032.556978] [<c00fd369>] (__kmalloc) from [<c03d6bf3>]
(edma_prep_slave_sg+0x77/0x224)
[24032.557002] [<c03d6bf3>] (edma_prep_slave_sg) from [<c0563afd>]
(omap_hsmmc_request+0x33d/0x3f4)
[24032.557028] [<c0563afd>] (omap_hsmmc_request) from [<c054e813>]
(mmc_start_request+0xcb/0x1ac)
[24032.557043] [<c054e813>] (mmc_start_request) from [<c054f7e3>]
(mmc_start_req+0x1f3/0x2c4)
[24032.557057] [<c054f7e3>] (mmc_start_req) from [<c055ac49>]
(mmc_blk_issue_rw_rq+0x1b5/0x7ac)
[24032.557070] [<c055ac49>] (mmc_blk_issue_rw_rq) from [<c055b3e3>]
(mmc_blk_issue_rq+0x1a3/0x368)
[24032.557081] [<c055b3e3>] (mmc_blk_issue_rq) from [<c055c79b>]
(mmc_queue_thread+0x77/0x114)
[24032.557105] [<c055c79b>] (mmc_queue_thread) from [<c0040fc3>]
(kthread+0xa3/0xb8)
[24032.557121] [<c0040fc3>] (kthread) from [<c000ea95>]
(ret_from_fork+0x11/0x1c)
[24032.557129] Mem-Info:
[24032.557148] active_anon:35548 inactive_anon:7471 isolated_anon:0
active_file:32685 inactive_file:35730 isolated_file:0
unevictable:0 dirty:9083 writeback:4481 unstable:0
slab_reclaimable:4385 slab_unreclaimable:1977
mapped:19169 shmem:24293 pagetables:345 bounce:0
free:1523 free_pcp:166 free_cma:0
[24032.557188] Normal free:6092kB min:2752kB low:3440kB high:4128kB
active_anon:142192kB inactive_anon:29884kB active_file:130740kB
inactive_file:142920kB unevictable:0kB isolated(anon):0kB
isolated(file):0kB present:524288kB managed:506492kB mlocked:0kB
dirty:36332kB writeback:17924kB mapped:76676kB shmem:97172kB
slab_reclaimable:17540kB slab_unreclaimable:7908kB kernel_stack:1096kB
pagetables:1380kB unstable:0kB bounce:0kB free_pcp:664kB
local_pcp:664kB free_cma:0kB writeback_tmp:0kB pages_scanned:0
all_unreclaimable? no
[24032.557196] lowmem_reserve[]: 0 0 0
[24032.557207] Normal: 615*4kB (UE) 454*8kB (UM) 0*16kB 0*32kB 0*64kB
0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 6092kB
[24032.557240] 92708 total pagecache pages
[24032.557252] 0 pages in swap cache
[24032.557259] Swap cache stats: add 0, delete 0, find 0/0
[24032.557264] Free swap = 0kB
[24032.557268] Total swap = 0kB
[24032.557274] 131072 pages RAM
[24032.557278] 0 pages HighMem/MovableOnly
[24032.557283] 4449 pages reserved
[24032.557287] 6144 pages cma reserved
[24032.557305] edma 49000000.edma: edma_prep_slave_sg: Failed to
allocate a descriptor
[24032.565406] omap_hsmmc 48060000.mmc: prep_slave_sg() failed
[24032.569387] omap_hsmmc 48060000.mmc: MMC start dma failure
[24032.611034] mmcblk0: unknown error -1 sending read/write command,
card status 0x900
[24032.621839] EXT4-fs warning (device mmcblk0p1): ext4_end_bio:329:
I/O error -5 writing to inode 3696 (offset 8388608 size 8388608
starting block 2369536)
[24032.653548] mmcqd/0: page allocation failure: order:2, mode:0x2204020
[24032.653577] CPU: 0 PID: 73 Comm: mmcqd/0 Not tainted 4.4.13-bone11 #153
[24032.653585] Hardware name: Generic AM33XX (Flattened Device Tree)
[24032.653639] [<c0014765>] (unwind_backtrace) from [<c0011eb9>]
(show_stack+0x11/0x14)
[24032.653663] [<c0011eb9>] (show_stack) from [<c00d011d>]
(warn_alloc_failed+0xb5/0xf0)
[24032.653681] [<c00d011d>] (warn_alloc_failed) from [<c00d2521>]
(__alloc_pages_nodemask+0x5d1/0x704)
[24032.653702] [<c00d2521>] (__alloc_pages_nodemask) from [<c00fcd57>]
(cache_alloc_refill+0x1eb/0x3ac)
[24032.653716] [<c00fcd57>] (cache_alloc_refill) from [<c00fd369>]
(__kmalloc+0x101/0x120)
[24032.653741] [<c00fd369>] (__kmalloc) from [<c03d6bf3>]
(edma_prep_slave_sg+0x77/0x224)
[24032.653765] [<c03d6bf3>] (edma_prep_slave_sg) from [<c0563afd>]
(omap_hsmmc_request+0x33d/0x3f4)
[24032.653791] [<c0563afd>] (omap_hsmmc_request) from [<c054e813>]
(mmc_start_request+0xcb/0x1ac)
[24032.653807] [<c054e813>] (mmc_start_request) from [<c054f7e3>]
(mmc_start_req+0x1f3/0x2c4)
[24032.653821] [<c054f7e3>] (mmc_start_req) from [<c055ac49>]
(mmc_blk_issue_rw_rq+0x1b5/0x7ac)
[24032.653834] [<c055ac49>] (mmc_blk_issue_rw_rq) from [<c055b3e3>]
(mmc_blk_issue_rq+0x1a3/0x368)
[24032.653845] [<c055b3e3>] (mmc_blk_issue_rq) from [<c055c79b>]
(mmc_queue_thread+0x77/0x114)
[24032.653870] [<c055c79b>] (mmc_queue_thread) from [<c0040fc3>]
(kthread+0xa3/0xb8)
[24032.653885] [<c0040fc3>] (kthread) from [<c000ea95>]
(ret_from_fork+0x11/0x1c)
[24032.653892] Mem-Info:
[24032.653913] active_anon:35578 inactive_anon:7471 isolated_anon:0
active_file:32689 inactive_file:35849 isolated_file:0
unevictable:0 dirty:9080 writeback:4359 unstable:0
slab_reclaimable:4385 slab_unreclaimable:1977
mapped:19172 shmem:24293 pagetables:347 bounce:0
free:1523 free_pcp:133 free_cma:0
[24032.653953] Normal free:6092kB min:2752kB low:3440kB high:4128kB
active_anon:142312kB inactive_anon:29884kB active_file:130756kB
inactive_file:143396kB unevictable:0kB isolated(anon):0kB
isolated(file):0kB present:524288kB managed:506492kB mlocked:0kB
dirty:36320kB writeback:17436kB mapped:76688kB shmem:97172kB
slab_reclaimable:17540kB slab_unreclaimable:7908kB kernel_stack:1096kB
pagetables:1388kB unstable:0kB bounce:0kB free_pcp:532kB
local_pcp:532kB free_cma:0kB writeback_tmp:0kB pages_scanned:0
all_unreclaimable? no
[24032.653961] lowmem_reserve[]: 0 0 0
[24032.653972] Normal: 625*4kB (UME) 449*8kB (U) 0*16kB 0*32kB 0*64kB
0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB 0*8192kB = 6092kB
[24032.654004] 92831 total pagecache pages
[24032.654016] 0 pages in swap cache
[24032.654023] Swap cache stats: add 0, delete 0, find 0/0
[24032.654028] Free swap = 0kB
[24032.654032] Total swap = 0kB
[24032.654037] 131072 pages RAM
[24032.654042] 0 pages HighMem/MovableOnly
[24032.654047] 4449 pages reserved
[24032.654052] 6144 pages cma reserved
[24032.654068] edma 49000000.edma: edma_prep_slave_sg: Failed to
allocate a descriptor
[24032.662225] omap_hsmmc 48060000.mmc: prep_slave_sg() failed
[24032.666290] omap_hsmmc 48060000.mmc: MMC start dma failure
[24032.696222] mmcblk0: unknown error -1 sending read/write command,
card status 0x900
[24032.707044] EXT4-fs warning (device mmcblk0p1): ext4_end_bio:329:
I/O error -5 writing to inode 3696 (offset 8388608 size 8388608
starting block 2369792)

I found some anwer on the internet about setting :

"vm.min_free_kbytes = 8192" to /etc/sysctl.conf?

How do you calculate this value ?

Thanks,