plougher / squashfs-tools

tools to create and extract Squashfs filesystems
GNU General Public License v2.0
758 stars 193 forks source link

[Feature request] unsquashfs need a option like -mem in mksquashfs #139

Closed zhangguanzhang closed 2 years ago

zhangguanzhang commented 2 years ago
root@OpenWrt:~# unsquashfs -p 1 /root/sq/jike2.squashfs   
Parallel unsquashfs: Using 1 processor
8787 inodes (9142 blocks) to write

[====================================================-                                                                                                                                                                     ] 2211/9142  24%Killed
$ mksquashfs --help
-mem <size>     Use <size> physical memory.  Currently set to 247M
            Optionally a suffix of K, M or G can be given to specify
            Kbytes, Mbytes or Gbytes respectively

I hope unsquashfs also had this option in the futrue my version:

unsquashfs -v
unsquashfs version 4.5 (2021/07/22)
copyright (C) 2021 Phillip Lougher <phillip@squashfs.org.uk>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
zhangguanzhang commented 2 years ago

oom info

Sat Dec 11 12:39:08 2021 kern.info kernel: [ 2251.109298] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=/,mems_allowed=0,global_oom,task_memcg=/,task=unsquashfs,pid=15042,uid=0
Sat Dec 11 12:39:08 2021 kern.err kernel: [ 2251.110461] Out of memory: Killed process 15042 (unsquashfs) total-vm:310592kB, anon-rss:138112kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:644kB oom_score_adj:0
Sat Dec 11 12:39:08 2021 kern.info kernel: [ 2251.158060] oom_reaper: reaped process 15042 (unsquashfs), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.659913] unsquashfs invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.660778] CPU: 1 PID: 15688 Comm: unsquashfs Tainted: G         C        5.4.162 #0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.661458] Hardware name: FriendlyElec NanoPi R2S (DT)
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.661914] Call trace:
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.662136]  dump_backtrace+0x0/0x108
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.662458]  show_stack+0x14/0x20
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.662751]  dump_stack+0xc0/0x120
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.663049]  dump_header+0x40/0x1f4
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.663358]  oom_kill_process+0x1cc/0x1d0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.663709]  out_of_memory+0xd0/0x2d8
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.664031]  __alloc_pages_slowpath+0x890/0x9c0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.664427]  __alloc_pages_nodemask+0x1fc/0x280
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.664823]  __handle_mm_fault+0x5bc/0xc60
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.665181]  handle_mm_fault+0xdc/0x1a8
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.665521]  do_page_fault+0x11c/0x438
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.665853]  do_translation_fault+0x64/0x70
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.666222]  do_mem_abort+0x3c/0x98
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.666530]  el1_da+0x1c/0x90
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.666795]  __arch_copy_to_user+0x1c0/0x310
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.667173]  copy_page_to_iter+0xe4/0x358
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.667529]  generic_file_read_iter+0x3bc/0x9a0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.667927]  ext4_file_read_iter+0x3c/0x50
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.668291]  new_sync_read+0xe8/0x148
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.668615]  __vfs_read+0x2c/0x40
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.668909]  vfs_read+0xc8/0x158
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.669195]  ksys_read+0x4c/0xc8
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.669481]  __arm64_sys_read+0x18/0x20
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.669821]  el0_svc_common.constprop.2+0x7c/0x110
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.670242]  el0_svc_handler+0x20/0x80
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.670573]  el0_svc+0x8/0x200
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.672918] Mem-Info:
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142] active_anon:85553 inactive_anon:145624 isolated_anon:0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142]  active_file:59 inactive_file:8 isolated_file:0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142]  unevictable:0 dirty:25 writeback:7 unstable:0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142]  slab_reclaimable:2715 slab_unreclaimable:6766
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142]  mapped:52 shmem:185263 pagetables:419 bounce:0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.673142]  free:4078 free_pcp:0 free_cma:287
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.676017] Node 0 active_anon:342212kB inactive_anon:582496kB active_file:236kB inactive_file:32kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:208kB dirty:100kB writeback:28kB shmem:741052kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 10240kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.678441] DMA32 free:16312kB min:16384kB low:20480kB high:24576kB active_anon:341716kB inactive_anon:582496kB active_file:208kB inactive_file:704kB unevictable:0kB writepending:0kB present:1046528kB managed:1014380kB mlocked:0kB kernel_stack:2704kB pagetables:1676kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:1148kB
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.680903] lowmem_reserve[]: 0 0 0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.681217] DMA32: 1085*4kB (UMEC) 460*8kB (UMEC) 161*16kB (UMEC) 86*32kB (UEC) 28*64kB (UEC) 9*128kB (EC) 1*256kB (U) 1*512kB (C) 0*1024kB 0*2048kB 0*4096kB = 17060kB
Sat Dec 11 12:39:37 2021 kern.info kernel: [ 2279.682551] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
Sat Dec 11 12:39:37 2021 kern.info kernel: [ 2279.683311] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=32768kB
Sat Dec 11 12:39:37 2021 kern.info kernel: [ 2279.684057] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
Sat Dec 11 12:39:37 2021 kern.info kernel: [ 2279.684794] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=64kB
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.685565] 185346 total pagecache pages
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.685914] 0 pages in swap cache
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.686207] Swap cache stats: add 0, delete 0, find 0/0
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.686664] Free swap  = 0kB
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.686919] Total swap = 0kB
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.687173] 261632 pages RAM
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.687427] 0 pages HighMem/MovableOnly
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.687764] 8037 pages reserved
Sat Dec 11 12:39:37 2021 kern.warn kernel: [ 2279.688041] 2048 pages cma reserved
plougher commented 2 years ago

The -data-queue and -frag-queue options control how much memory Unsquashfs uses. Default is to use 512 Mbytes. So

unsquashfs -da 10 -fr 10 -p 1 /root/sq/jike2.squashfs

Will limit memory usage to about 20 Mbytes.

zhangguanzhang commented 2 years ago

I will try later

zhangguanzhang commented 2 years ago

Ths, It works