Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak? #163

Open
darkbasic opened this issue Nov 9, 2016 · 8 comments
Open

Memory leak? #163

darkbasic opened this issue Nov 9, 2016 · 8 comments

Comments

@darkbasic
Copy link

@darkbasic darkbasic commented Nov 9, 2016

Hi, I have 8GB of ram and 8GB of swap, I closed all other applications and I run duperemove this way:

sudo mount -o noatime,compress=lzo,autodefrag /dev/mapper/cryptroot /home/niko/nosnap/rootfs/

for snapshot in $(sudo btrfs subvolume list -p /home/niko/nosnap/rootfs | awk '{ print $11 }'); do
  ro=$(btrfs property get -ts /home/niko/nosnap/rootfs/${snapshot} | awk -F  "=" '{print $2}');
  if [ "${ro}" == "true" ]; then
    sudo btrfs property set -ts /home/niko/nosnap/rootfs/${snapshot} ro false;
  fi;
done

time sudo duperemove -drh --dedupe-options=nofiemap --hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

or

time sudo duperemove -drh --dedupe-options=noblock --hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

In both cases it dies because it goes out of memory:

[0x15df6a30] (01387/25171) Try to dedupe extents with id 3f6e153e
[0x15df6a30] Skipping - extents are already deduped.
[0x15df6a30] (01388/25171) Try to dedupe extents with id 3c80f818
[0x15df6a30] Dedupe 77 extents (id: 3c80f818) with target: (0.0, 128.8K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/icons/breeze-dark/applets/256/org.kde.plasma.showActivityManager.svg"
[0x15df69e0] (01389/25171) Try to dedupe extents with id 3d1eea9f
[0x15df6ad0] (01390/25171) Try to dedupe extents with id 74e7680a
[0x15df6ad0] Skipping - extents are already deduped.
[0x15df6ad0] (01391/25171) Try to dedupe extents with id 25e7852a
[0x15df69e0] Dedupe 77 extents (id: 3d1eea9f) with target: (0.0, 128.8K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/icons/breeze/applets/256/org.kde.plasma.showActivityManager.svg"
[0x15df6ad0] Dedupe 76 extents (id: 25e7852a) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/include/wine/windows/control.h"
[0x15df6a80] (01392/25171) Try to dedupe extents with id 75b4f283
[0x15df6a80] Dedupe 77 extents (id: 75b4f283) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/lib/libpangox-1.0.so.0.0.0"
[0x15df6a30] (01393/25171) Try to dedupe extents with id 67ab895a
[0x15df6a30] Skipping - extents are already deduped.
[0x15df6a30] (01394/25171) Try to dedupe extents with id 69223ad7
[0x15df6ad0] (01395/25171) Try to dedupe extents with id 3f39fa8c
[0x15df6a30] Dedupe 78 extents (id: 69223ad7) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/boot/grub/locale/hu.mo"
[0x15df6ad0] Dedupe 77 extents (id: 3f39fa8c) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/lib32/wine/ole2.dll16.so"
[0x15df69e0] (01396/25171) Try to dedupe extents with id a1918c40
[0x15df69e0] Skipping - extents are already deduped.
[0x15df69e0] (01397/25171) Try to dedupe extents with id 39e86212
[0x15df69e0] Dedupe 77 extents (id: 39e86212) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/locale/zh_TW/LC_MESSAGES/amule.mo"
Ucciso

real    132m30.231s
user    114m46.616s
sys     33m38.666s
[ 9877.594522] Purging GPU memory, 7689 pages freed, 13853 pages still pinned.
[ 9877.594528] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.594605] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.594606] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.594688] pool invoked oom-killer: gfp_mask=0x24042c0(GFP_KERNEL|__GFP_NOWARN|__GFP_COMP), order=2, oom_score_adj=0
[ 9877.594689] pool cpuset=/ mems_allowed=0
[ 9877.594693] CPU: 1 PID: 8291 Comm: pool Not tainted 4.8.6-1-ARCH #1
[ 9877.594694] Hardware name: Dell Inc. XPS 13 9343/0F5KF3, BIOS A08 08/17/2016
[ 9877.594695]  0000000000000286 0000000072a90ce1 ffff88002991f938 ffffffff812fe4f0
[ 9877.594698]  ffff88002991faf8 ffff880200c8b900 ffff88002991f9a8 ffffffff81206052
[ 9877.594701]  010188002991f940 0000000072a90ce1 00000000ffffffff 0000000000000000
[ 9877.594703] Call Trace:
[ 9877.594711]  [<ffffffff812fe4f0>] dump_stack+0x63/0x83
[ 9877.594714]  [<ffffffff81206052>] dump_header+0x5c/0x1ea
[ 9877.594716]  [<ffffffff8117caf5>] oom_kill_process+0x265/0x410
[ 9877.594718]  [<ffffffff810864c7>] ? has_capability_noaudit+0x17/0x20
[ 9877.594720]  [<ffffffff8117d070>] out_of_memory+0x380/0x420
[ 9877.594722]  [<ffffffff81313328>] ? find_next_bit+0x18/0x20
[ 9877.594724]  [<ffffffff811826d0>] __alloc_pages_nodemask+0xda0/0xde0
[ 9877.594727]  [<ffffffff811d66a5>] alloc_pages_current+0x95/0x140
[ 9877.594730]  [<ffffffff811a3f0e>] kmalloc_order_trace+0x2e/0xf0
[ 9877.594732]  [<ffffffff811e1fea>] __kmalloc+0x1ea/0x200
[ 9877.594749]  [<ffffffffa034c55c>] btrfs_clone+0x6c/0xc30 [btrfs]
[ 9877.594759]  [<ffffffffa034a19e>] ? lock_extent_range+0x11e/0x170 [btrfs]
[ 9877.594767]  [<ffffffffa034a272>] ? btrfs_double_extent_lock+0x82/0xd0 [btrfs]
[ 9877.594776]  [<ffffffffa0350d95>] btrfs_dedupe_file_range+0x585/0x690 [btrfs]
[ 9877.594779]  [<ffffffff81209060>] vfs_dedupe_file_range+0x260/0x2c0
[ 9877.594782]  [<ffffffff8121c5be>] do_vfs_ioctl+0x22e/0x5f0
[ 9877.594784]  [<ffffffff812276a7>] ? __fget+0x77/0xb0
[ 9877.594786]  [<ffffffff8121c9f9>] SyS_ioctl+0x79/0x90
[ 9877.594789]  [<ffffffff815f7cf2>] entry_SYSCALL_64_fastpath+0x1a/0xa4
[ 9877.594790] Mem-Info:
[ 9877.594793] active_anon:1561225 inactive_anon:223069 isolated_anon:0
                active_file:66566 inactive_file:66624 isolated_file:0
                unevictable:8 dirty:7900 writeback:11016 unstable:0
                slab_reclaimable:17538 slab_unreclaimable:14958
                mapped:20643 shmem:58187 pagetables:10749 bounce:0
                free:25212 free_pcp:91 free_cma:0
[ 9877.594796] Node 0 active_anon:6244900kB inactive_anon:892276kB active_file:266264kB inactive_file:266496kB unevictable:32kB isolated(anon):0kB isolated(file):0kB mapped:82572kB dirty:31600kB writeback:44064kB shmem:0kB shmem_thp: 0kB 
shmem_pmdmapped: 96256kB anon_thp: 232748kB writeback_tmp:0kB unstable:0kB pages_scanned:96 all_unreclaimable? no
[ 9877.594797] Node 0 DMA free:15692kB min:132kB low:164kB high:196kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15984kB managed:15896kB mlocked:0kB slab_reclaimable:0kB 
slab_unreclaimable:204kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 9877.594799] lowmem_reserve[]: 0 3397 7852 7852 7852
[ 9877.594802] Node 0 DMA32 free:46984kB min:29180kB low:36472kB high:43764kB active_anon:2796964kB inactive_anon:345920kB active_file:119812kB inactive_file:122552kB unevictable:0kB writepending:31376kB present:3564504kB managed:3488756kB 
mlocked:0kB slab_reclaimable:12948kB slab_unreclaimable:10444kB kernel_stack:352kB pagetables:7544kB bounce:0kB free_pcp:428kB local_pcp:0kB free_cma:0kB
[ 9877.594806] lowmem_reserve[]: 0 0 4454 4454 4454
[ 9877.594808] Node 0 Normal free:38172kB min:38264kB low:47828kB high:57392kB active_anon:3448060kB inactive_anon:546224kB active_file:146416kB inactive_file:144064kB unevictable:32kB writepending:44284kB present:4694016kB managed:4561616kB 
mlocked:32kB slab_reclaimable:57204kB slab_unreclaimable:49184kB kernel_stack:4848kB pagetables:35452kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 9877.594811] lowmem_reserve[]: 0 0 0 0 0
[ 9877.594814] Node 0 DMA: 1*4kB (U) 1*8kB (U) 0*16kB 0*32kB 1*64kB (U) 2*128kB (U) 0*256kB 0*512kB 1*1024kB (U) 1*2048kB (M) 3*4096kB (M) = 15692kB
[ 9877.594823] Node 0 DMA32: 3938*4kB (UMEH) 3721*8kB (UMH) 3*16kB (H) 3*32kB (H) 3*64kB (H) 3*128kB (H) 1*256kB (H) 2*512kB (H) 0*1024kB 0*2048kB 0*4096kB = 47520kB
[ 9877.594837] Node 0 Normal: 6838*4kB (UME) 1320*8kB (UME) 0*16kB 1*32kB (H) 0*64kB 1*128kB (H) 1*256kB (H) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 38328kB
[ 9877.594846] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
[ 9877.594847] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
[ 9877.594847] 243515 total pagecache pages
[ 9877.594848] 52211 pages in swap cache
[ 9877.594849] Swap cache stats: add 1148306, delete 1096095, find 347834/490206
[ 9877.594849] Free swap  = 6306284kB
[ 9877.594850] Total swap = 8387904kB
[ 9877.594850] 2068626 pages RAM
[ 9877.594851] 0 pages HighMem/MovableOnly
[ 9877.594851] 52059 pages reserved
[ 9877.594852] 0 pages hwpoisoned
[ 9877.594852] [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name
[ 9877.594858] [  297]     0   297    25472     1958      43       3       89             0 systemd-journal
[ 9877.594859] [  324]     0   324     9165       13      19       3      371         -1000 systemd-udevd
[ 9877.594861] [  631]   192   631    35700       13      40       3      145             0 systemd-timesyn
[ 9877.594863] [  637]    81   637     8591      290      21       3      130          -900 dbus-daemon
[ 9877.594865] [  638]     0   638   108719      338      75       3      505             0 NetworkManager
[ 9877.594866] [  639]     0   639     9630       53      22       3       92             0 systemd-logind
[ 9877.594868] [  640]    84   640    10328       27      24       3       75             0 avahi-daemon
[ 9877.594869] [  641]     0   641     9294        0      22       3      164             0 bluetoothd
[ 9877.594870] [  643]    84   643    10295        0      23       3       78             0 avahi-daemon
[ 9877.594872] [  645]     0   645     1841        7       9       3       21             0 gpm
[ 9877.594874] [  661]     0   661    10100        0      24       3      143         -1000 sshd
[ 9877.594876] [  662]     0   662   186032        1     141       4     1664             0 libvirtd
[ 9877.594877] [  663]     0   663    22125      144      47       3      409             0 cupsd
[ 9877.594879] [  667]     0   667    47157        0      46       3      347             0 sddm
[ 9877.594880] [  684]     0   684    79160    11664     155       3     1976             0 Xorg
[ 9877.594882] [  685]   124   685    78882        1      55       3     2487             0 colord
[ 9877.594884] [  697]     0   697    79428       54     150       3      619             0 smbd
[ 9877.594885] [  700]     0   700    78446        3     144       3      648             0 smbd-notifyd
[ 9877.594887] [  701]     0   701    78444        0     143       3      655             0 cleanupd
[ 9877.594888] [  735]     0   735    79428       79     146       3      593             0 lpqd
[ 9877.594891] [  738]     0   738    10855       13      24       3      113             0 wpa_supplicant
[ 9877.594893] [  740]   102   740   131699      551      53       4     2141             0 polkitd
[ 9877.594895] [  841]    99   841    11640        2      26       3      132             0 dnsmasq
[ 9877.594896] [  842]     0   842    11607        0      26       3       89             0 dnsmasq
[ 9877.594898] [  873]    99   873    11640       13      25       3      121             0 dnsmasq
[ 9877.594899] [  874]     0   874    11640        0      25       3      132             0 dnsmasq
[ 9877.594901] [  878]     0   878    93068      972      45       3      698             0 udisksd
[ 9877.594902] [  884]     0   884    75055      131      44       4      262             0 upowerd
[ 9877.594904] [  915]     0   915    40487        1      72       3      398             0 sddm-helper
[ 9877.594905] [  916]  1000   916    13691       56      31       3      203             0 systemd
[ 9877.594907] [  917]  1000   917    24713        0      48       3      441             0 (sd-pam)
[ 9877.594908] [  925]  1000   925     3407        1      11       3      107             0 startkde
[ 9877.594910] [  935]  1000   935     8350      616      20       3       99             0 dbus-daemon
[ 9877.594912] [  969]  1000   969     1526        0       7       3       21             0 start_kdeinit
[ 9877.594913] [  970]  1000   970    75329        0     127       3      796             0 kdeinit5
[ 9877.594915] [  971]  1000   971   129072       81     167       4      868             0 klauncher
[ 9877.594916] [  974]  1000   974   380085     1569     316       4     4690             0 kded5
[ 9877.594918] [  982]  1000   982   132225      296     166       3      948             0 kaccess
[ 9877.594920] [ 1000]  1000  1000    46251        1      27       3      136             0 dconf-service
[ 9877.594922] [ 1003]  1000  1003    21602        0      35       3      145             0 kwrapper5
[ 9877.594923] [ 1005]  1000  1005   159326      631     191       3     1089             0 ksmserver
[ 9877.594925] [ 1006]  1000  1006   129490      167     165       3     1128             0 kglobalaccel5
[ 9877.594926] [ 1008]  1000  1008   136115      234      61       3      382             0 mission-control
[ 9877.594927] [ 1019]  1000  1019   785392     1070     264       5     7330             0 kwin_x11
[ 9877.594929] [ 1020]  1000  1020 67195714     2073     140       4     1401             0 baloo_file
[ 9877.594930] [ 1021]  1000  1021   175069      311     221       4     2782             0 kdeconnectd
[ 9877.594932] [ 1022]  1000  1022   182347       85     227       4     4210             0 krunner
[ 9877.594933] [ 1024]  1000  1024   931495    14117     467       5    24825             0 plasmashell
[ 9877.594935] [ 1025]  1000  1025   180801      100     196       4     1837             0 polkit-kde-auth
[ 9877.594936] [ 1026]  1000  1026   129797      299     164       3      859             0 xembedsniproxy
[ 9877.594938] [ 1036]  1000  1036   125469        1      94       4      808             0 pulseaudio
[ 9877.594940] [ 1041]  1000  1041    89518       38      96       3      465             0 kscreen_backend
[ 9877.594941] [ 1045]   133  1045    44462        0      22       3       79             0 rtkit-daemon
[ 9877.594943] [ 1055]  1000  1055   249144       60     286       4     4464             0 korgac
[ 9877.594944] [ 1072]  1000  1072   226812       99     185       4     1098             0 kactivitymanage
[ 9877.594946] [ 1083]  1000  1083    21171        0      44       3      175             0 gconf-helper
[ 9877.594947] [ 1086]  1000  1086    16450       24      37       3      166             0 gconfd-2
[ 9877.594949] [ 1097]  1000  1097   127733      412     166       3      822             0 org_kde_powerde
[ 9877.594951] [ 1141]  1000  1141    10293        0      24       3      150             0 obexd
[ 9877.594952] [ 1181]  1000  1181   129342       44     164       3      890             0 kuiserver5
[ 9877.594954] [ 1259]  1000  1259   141236      155     193       4     1995             0 kwalletd5
[ 9877.594955] [ 4172]  1000  4172   169050     2118     226       3     2236             0 ksysguard
[ 9877.594957] [ 4176]  1000  4176     2457       64      10       4       39             0 ksysguardd
[ 9877.594958] [ 5877]  1000  5877   159945    14487     226       4     2512             0 konsole
[ 9877.594960] [ 5881]  1000  5881     3998        2      12       3      153             0 bash
[ 9877.594961] [ 5884]     0  5884    17563        0      37       3      249             0 sudo
[ 9877.594963] [ 5885]     0  5885  2100687  1684271    4005      11   355337             0 duperemove
[ 9877.594965] [ 5896]  1000  5896     3998        2      12       3      154             0 bash
[ 9877.594967] [ 5898]  1000  5898     1463        0       8       3       36             0 tail
[ 9877.594969] [ 8302]  1000  8302   100268     5885     132       3        0             0 baloo_file_extr
[ 9877.594970] Out of memory: Kill process 5885 (duperemove) score 481 or sacrifice child
[ 9877.594978] Killed process 5885 (duperemove) total-vm:8402748kB, anon-rss:6737084kB, file-rss:0kB, shmem-rss:0kB
[ 9877.595326] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.595327] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.595793] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.595794] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.996435] oom_reaper: reaped process 8292 (pool), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

What's even more interesting is that disk usage goes higher after the (partial) deduplication:
Before: $ btrfs filesystem df /
Data, single: total=149.35GiB, used=134.98GiB
System, single: total=3.00MiB, used=48.00KiB
Metadata, single: total=3.01GiB, used=1.80GiB
GlobalReserve, single: total=268.59MiB, used=0.00B

After: $ btrfs filesystem df /
Data, single: total=149.35GiB, used=137.16GiB
System, single: total=3.00MiB, used=48.00KiB
Metadata, single: total=3.01GiB, used=1.92GiB
GlobalReserve, single: total=283.55MiB, used=0.00B

Considering the hashfile is only 1.8GB the disk usage increased a little bit instead of decreasing:
$ ls -l rootfs.hash -rw-r--r-- 1 root root 1882632192 9 nov 00.50 rootfs.hash
$ ls -lh rootfs.hash -rw-r--r-- 1 root root 1,8G 9 nov 00.50 rootfs.hash

@Floyddotnet
Copy link

@Floyddotnet Floyddotnet commented Nov 9, 2016

Is the hash-file placed on the same btrfs volumn? Your code look like it is
not but you post "df /".

2016-11-09 11:39 GMT+01:00 Niccolò Belli notifications@github.com:

Hi, I run duperemove this way:

sudo mount -o noatime,compress=lzo,autodefrag /dev/mapper/cryptroot
/home/niko/nosnap/rootfs/

for snapshot in $(sudo btrfs subvolume list -p /home/niko/nosnap/rootfs |
awk '{ print $11 }'); do
ro=$(btrfs property get -ts /home/niko/nosnap/rootfs/${snapshot} | awk -F
"=" '{print $2}');
if [ "${ro}" == "true" ]; then
sudo btrfs property set -ts /home/niko/nosnap/rootfs/${snapshot} ro false;
fi;
done

time sudo duperemove -drh --dedupe-options=nofiemap
--hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

or

time sudo duperemove -drh --dedupe-options=noblock
--hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

In both cases it dies because it goes out of memory:

0x15df6a30 Try to dedupe extents with id 3f6e153e
[0x15df6a30] Skipping - extents are already deduped.
0x15df6a30 Try to dedupe extents with id 3c80f818
[0x15df6a30] Dedupe 77 extents (id: 3c80f818) with target: (0.0, 128.8K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/icons/breeze-dark/applets/256/org.kde.plasma.showActivityManager.svg"
0x15df69e0 Try to dedupe extents with id 3d1eea9f
0x15df6ad0 Try to dedupe extents with id 74e7680a
[0x15df6ad0] Skipping - extents are already deduped.
0x15df6ad0 Try to dedupe extents with id 25e7852a
[0x15df69e0] Dedupe 77 extents (id: 3d1eea9f) with target: (0.0, 128.8K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/icons/breeze/applets/256/org.kde.plasma.showActivityManager.svg"
[0x15df6ad0] Dedupe 76 extents (id: 25e7852a) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/include/wine/windows/control.h"
0x15df6a80 Try to dedupe extents with id 75b4f283
[0x15df6a80] Dedupe 77 extents (id: 75b4f283) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/lib/libpangox-1.0.so.0.0.0"
0x15df6a30 Try to dedupe extents with id 67ab895a
[0x15df6a30] Skipping - extents are already deduped.
0x15df6a30 Try to dedupe extents with id 69223ad7
0x15df6ad0 Try to dedupe extents with id 3f39fa8c
[0x15df6a30] Dedupe 78 extents (id: 69223ad7) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/boot/grub/locale/hu.mo"
[0x15df6ad0] Dedupe 77 extents (id: 3f39fa8c) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/lib32/wine/ole2.dll16.so"
0x15df69e0 Try to dedupe extents with id a1918c40
[0x15df69e0] Skipping - extents are already deduped.
0x15df69e0 Try to dedupe extents with id 39e86212
[0x15df69e0] Dedupe 77 extents (id: 39e86212) with target: (0.0, 128.9K), "/home/niko/nosnap/rootfs/@snapshots/4399/snapshot/usr/share/locale/zh_TW/LC_MESSAGES/amule.mo"
Ucciso

real 132m30.231s
user 114m46.616s
sys 33m38.666s

[ 9877.594522] Purging GPU memory, 7689 pages freed, 13853 pages still pinned.
[ 9877.594528] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.594605] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.594606] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.594688] pool invoked oom-killer: gfp_mask=0x24042c0(GFP_KERNEL|__GFP_NOWARN|__GFP_COMP), order=2, oom_score_adj=0
[ 9877.594689] pool cpuset=/ mems_allowed=0
[ 9877.594693] CPU: 1 PID: 8291 Comm: pool Not tainted 4.8.6-1-ARCH #1
[ 9877.594694] Hardware name: Dell Inc. XPS 13 9343/0F5KF3, BIOS A08 08/17/2016
[ 9877.594695] 0000000000000286 0000000072a90ce1 ffff88002991f938 ffffffff812fe4f0
[ 9877.594698] ffff88002991faf8 ffff880200c8b900 ffff88002991f9a8 ffffffff81206052
[ 9877.594701] 010188002991f940 0000000072a90ce1 00000000ffffffff 0000000000000000
[ 9877.594703] Call Trace:
[ 9877.594711] [] dump_stack+0x63/0x83
[ 9877.594714] [] dump_header+0x5c/0x1ea
[ 9877.594716] [] oom_kill_process+0x265/0x410
[ 9877.594718] [] ? has_capability_noaudit+0x17/0x20
[ 9877.594720] [] out_of_memory+0x380/0x420
[ 9877.594722] [] ? find_next_bit+0x18/0x20
[ 9877.594724] [] __alloc_pages_nodemask+0xda0/0xde0
[ 9877.594727] [] alloc_pages_current+0x95/0x140
[ 9877.594730] [] kmalloc_order_trace+0x2e/0xf0
[ 9877.594732] [] __kmalloc+0x1ea/0x200
[ 9877.594749] [] btrfs_clone+0x6c/0xc30 [btrfs]
[ 9877.594759] [] ? lock_extent_range+0x11e/0x170 [btrfs]
[ 9877.594767] [] ? btrfs_double_extent_lock+0x82/0xd0 [btrfs]
[ 9877.594776] [] btrfs_dedupe_file_range+0x585/0x690 [btrfs]
[ 9877.594779] [] vfs_dedupe_file_range+0x260/0x2c0
[ 9877.594782] [] do_vfs_ioctl+0x22e/0x5f0
[ 9877.594784] [] ? __fget+0x77/0xb0
[ 9877.594786] [] SyS_ioctl+0x79/0x90
[ 9877.594789] [] entry_SYSCALL_64_fastpath+0x1a/0xa4
[ 9877.594790] Mem-Info:
[ 9877.594793] active_anon:1561225 inactive_anon:223069 isolated_anon:0
active_file:66566 inactive_file:66624 isolated_file:0
unevictable:8 dirty:7900 writeback:11016 unstable:0
slab_reclaimable:17538 slab_unreclaimable:14958
mapped:20643 shmem:58187 pagetables:10749 bounce:0
free:25212 free_pcp:91 free_cma:0
[ 9877.594796] Node 0 active_anon:6244900kB inactive_anon:892276kB active_file:266264kB inactive_file:266496kB unevictable:32kB isolated(anon):0kB isolated(file):0kB mapped:82572kB dirty:31600kB writeback:44064kB shmem:0kB shmem_thp: 0kB
shmem_pmdmapped: 96256kB anon_thp: 232748kB writeback_tmp:0kB unstable:0kB pages_scanned:96 all_unreclaimable? no
[ 9877.594797] Node 0 DMA free:15692kB min:132kB low:164kB high:196kB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:15984kB managed:15896kB mlocked:0kB slab_reclaimable:0kB
slab_unreclaimable:204kB kernel_stack:0kB pagetables:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 9877.594799] lowmem_reserve[]: 0 3397 7852 7852 7852
[ 9877.594802] Node 0 DMA32 free:46984kB min:29180kB low:36472kB high:43764kB active_anon:2796964kB inactive_anon:345920kB active_file:119812kB inactive_file:122552kB unevictable:0kB writepending:31376kB present:3564504kB managed:3488756kB
mlocked:0kB slab_reclaimable:12948kB slab_unreclaimable:10444kB kernel_stack:352kB pagetables:7544kB bounce:0kB free_pcp:428kB local_pcp:0kB free_cma:0kB
[ 9877.594806] lowmem_reserve[]: 0 0 4454 4454 4454
[ 9877.594808] Node 0 Normal free:38172kB min:38264kB low:47828kB high:57392kB active_anon:3448060kB inactive_anon:546224kB active_file:146416kB inactive_file:144064kB unevictable:32kB writepending:44284kB present:4694016kB managed:4561616kB
mlocked:32kB slab_reclaimable:57204kB slab_unreclaimable:49184kB kernel_stack:4848kB pagetables:35452kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 9877.594811] lowmem_reserve[]: 0 0 0 0 0
[ 9877.594814] Node 0 DMA: 1_4kB (U) 1_8kB (U) 0_16kB 0_32kB 1_64kB (U) 2_128kB (U) 0_256kB 0_512kB 1_1024kB (U) 1_2048kB (M) 3_4096kB (M) = 15692kB
[ 9877.594823] Node 0 DMA32: 3938_4kB (UMEH) 3721_8kB (UMH) 3_16kB (H) 3_32kB (H) 3_64kB (H) 3_128kB (H) 1_256kB (H) 2_512kB (H) 0_1024kB 0_2048kB 0_4096kB = 47520kB
[ 9877.594837] Node 0 Normal: 6838_4kB (UME) 1320_8kB (UME) 0_16kB 1_32kB (H) 0_64kB 1_128kB (H) 1_256kB (H) 0_512kB 0_1024kB 0_2048kB 0*4096kB = 38328kB
[ 9877.594846] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
[ 9877.594847] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
[ 9877.594847] 243515 total pagecache pages
[ 9877.594848] 52211 pages in swap cache
[ 9877.594849] Swap cache stats: add 1148306, delete 1096095, find 347834/490206
[ 9877.594849] Free swap = 6306284kB
[ 9877.594850] Total swap = 8387904kB
[ 9877.594850] 2068626 pages RAM
[ 9877.594851] 0 pages HighMem/MovableOnly
[ 9877.594851] 52059 pages reserved
[ 9877.594852] 0 pages hwpoisoned
[ 9877.594852] [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
[ 9877.594858] [ 297] 0 297 25472 1958 43 3 89 0 systemd-journal
[ 9877.594859] [ 324] 0 324 9165 13 19 3 371 -1000 systemd-udevd
[ 9877.594861] [ 631] 192 631 35700 13 40 3 145 0 systemd-timesyn
[ 9877.594863] [ 637] 81 637 8591 290 21 3 130 -900 dbus-daemon
[ 9877.594865] [ 638] 0 638 108719 338 75 3 505 0 NetworkManager
[ 9877.594866] [ 639] 0 639 9630 53 22 3 92 0 systemd-logind
[ 9877.594868] [ 640] 84 640 10328 27 24 3 75 0 avahi-daemon
[ 9877.594869] [ 641] 0 641 9294 0 22 3 164 0 bluetoothd
[ 9877.594870] [ 643] 84 643 10295 0 23 3 78 0 avahi-daemon
[ 9877.594872] [ 645] 0 645 1841 7 9 3 21 0 gpm
[ 9877.594874] [ 661] 0 661 10100 0 24 3 143 -1000 sshd
[ 9877.594876] [ 662] 0 662 186032 1 141 4 1664 0 libvirtd
[ 9877.594877] [ 663] 0 663 22125 144 47 3 409 0 cupsd
[ 9877.594879] [ 667] 0 667 47157 0 46 3 347 0 sddm
[ 9877.594880] [ 684] 0 684 79160 11664 155 3 1976 0 Xorg
[ 9877.594882] [ 685] 124 685 78882 1 55 3 2487 0 colord
[ 9877.594884] [ 697] 0 697 79428 54 150 3 619 0 smbd
[ 9877.594885] [ 700] 0 700 78446 3 144 3 648 0 smbd-notifyd
[ 9877.594887] [ 701] 0 701 78444 0 143 3 655 0 cleanupd
[ 9877.594888] [ 735] 0 735 79428 79 146 3 593 0 lpqd
[ 9877.594891] [ 738] 0 738 10855 13 24 3 113 0 wpa_supplicant
[ 9877.594893] [ 740] 102 740 131699 551 53 4 2141 0 polkitd
[ 9877.594895] [ 841] 99 841 11640 2 26 3 132 0 dnsmasq
[ 9877.594896] [ 842] 0 842 11607 0 26 3 89 0 dnsmasq
[ 9877.594898] [ 873] 99 873 11640 13 25 3 121 0 dnsmasq
[ 9877.594899] [ 874] 0 874 11640 0 25 3 132 0 dnsmasq
[ 9877.594901] [ 878] 0 878 93068 972 45 3 698 0 udisksd
[ 9877.594902] [ 884] 0 884 75055 131 44 4 262 0 upowerd
[ 9877.594904] [ 915] 0 915 40487 1 72 3 398 0 sddm-helper
[ 9877.594905] [ 916] 1000 916 13691 56 31 3 203 0 systemd
[ 9877.594907] [ 917] 1000 917 24713 0 48 3 441 0 (sd-pam)
[ 9877.594908] [ 925] 1000 925 3407 1 11 3 107 0 startkde
[ 9877.594910] [ 935] 1000 935 8350 616 20 3 99 0 dbus-daemon
[ 9877.594912] [ 969] 1000 969 1526 0 7 3 21 0 start_kdeinit
[ 9877.594913] [ 970] 1000 970 75329 0 127 3 796 0 kdeinit5
[ 9877.594915] [ 971] 1000 971 129072 81 167 4 868 0 klauncher
[ 9877.594916] [ 974] 1000 974 380085 1569 316 4 4690 0 kded5
[ 9877.594918] [ 982] 1000 982 132225 296 166 3 948 0 kaccess
[ 9877.594920] [ 1000] 1000 1000 46251 1 27 3 136 0 dconf-service
[ 9877.594922] [ 1003] 1000 1003 21602 0 35 3 145 0 kwrapper5
[ 9877.594923] [ 1005] 1000 1005 159326 631 191 3 1089 0 ksmserver
[ 9877.594925] [ 1006] 1000 1006 129490 167 165 3 1128 0 kglobalaccel5
[ 9877.594926] [ 1008] 1000 1008 136115 234 61 3 382 0 mission-control
[ 9877.594927] [ 1019] 1000 1019 785392 1070 264 5 7330 0 kwin_x11
[ 9877.594929] [ 1020] 1000 1020 67195714 2073 140 4 1401 0 baloo_file
[ 9877.594930] [ 1021] 1000 1021 175069 311 221 4 2782 0 kdeconnectd
[ 9877.594932] [ 1022] 1000 1022 182347 85 227 4 4210 0 krunner
[ 9877.594933] [ 1024] 1000 1024 931495 14117 467 5 24825 0 plasmashell
[ 9877.594935] [ 1025] 1000 1025 180801 100 196 4 1837 0 polkit-kde-auth
[ 9877.594936] [ 1026] 1000 1026 129797 299 164 3 859 0 xembedsniproxy
[ 9877.594938] [ 1036] 1000 1036 125469 1 94 4 808 0 pulseaudio
[ 9877.594940] [ 1041] 1000 1041 89518 38 96 3 465 0 kscreen_backend
[ 9877.594941] [ 1045] 133 1045 44462 0 22 3 79 0 rtkit-daemon
[ 9877.594943] [ 1055] 1000 1055 249144 60 286 4 4464 0 korgac
[ 9877.594944] [ 1072] 1000 1072 226812 99 185 4 1098 0 kactivitymanage
[ 9877.594946] [ 1083] 1000 1083 21171 0 44 3 175 0 gconf-helper
[ 9877.594947] [ 1086] 1000 1086 16450 24 37 3 166 0 gconfd-2
[ 9877.594949] [ 1097] 1000 1097 127733 412 166 3 822 0 org_kde_powerde
[ 9877.594951] [ 1141] 1000 1141 10293 0 24 3 150 0 obexd
[ 9877.594952] [ 1181] 1000 1181 129342 44 164 3 890 0 kuiserver5
[ 9877.594954] [ 1259] 1000 1259 141236 155 193 4 1995 0 kwalletd5
[ 9877.594955] [ 4172] 1000 4172 169050 2118 226 3 2236 0 ksysguard
[ 9877.594957] [ 4176] 1000 4176 2457 64 10 4 39 0 ksysguardd
[ 9877.594958] [ 5877] 1000 5877 159945 14487 226 4 2512 0 konsole
[ 9877.594960] [ 5881] 1000 5881 3998 2 12 3 153 0 bash
[ 9877.594961] [ 5884] 0 5884 17563 0 37 3 249 0 sudo
[ 9877.594963] [ 5885] 0 5885 2100687 1684271 4005 11 355337 0 duperemove
[ 9877.594965] [ 5896] 1000 5896 3998 2 12 3 154 0 bash
[ 9877.594967] [ 5898] 1000 5898 1463 0 8 3 36 0 tail
[ 9877.594969] [ 8302] 1000 8302 100268 5885 132 3 0 0 baloo_file_extr
[ 9877.594970] Out of memory: Kill process 5885 (duperemove) score 481 or sacrifice child
[ 9877.594978] Killed process 5885 (duperemove) total-vm:8402748kB, anon-rss:6737084kB, file-rss:0kB, shmem-rss:0kB
[ 9877.595326] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.595327] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.595793] Purging GPU memory, 0 pages freed, 13853 pages still pinned.
[ 9877.595794] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 9877.996435] oom_reaper: reaped process 8292 (pool), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB

What's even more interesting is that disk usage goes higher after the
(partial) deduplication:
Before: $ btrfs filesystem df /
Data, single: total=149.35GiB, used=134.98GiB
System, single: total=3.00MiB, used=48.00KiB
Metadata, single: total=3.01GiB, used=1.80GiB
GlobalReserve, single: total=268.59MiB, used=0.00B

After: $ btrfs filesystem df /
Data, single: total=149.35GiB, used=137.16GiB
System, single: total=3.00MiB, used=48.00KiB
Metadata, single: total=3.01GiB, used=1.92GiB
GlobalReserve, single: total=283.55MiB, used=0.00B

Considering the hashfile is only 1.8GB the disk usage increased a little
bit instead of decreasing:
$ ls -l rootfs.hash -rw-r--r-- 1 root root 1882632192 9 nov 00.50
rootfs.hash
$ ls -lh rootfs.hash -rw-r--r-- 1 root root 1,8G 9 nov 00.50 rootfs.hash


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#163, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAec4mePH9Qz3U0VJ8k30M40ACDye0Ftks5q8aL0gaJpZM4KtY_m
.

@darkbasic
Copy link
Author

@darkbasic darkbasic commented Nov 9, 2016

Almost, on / I mounted the @ subvolume. I obviously wanted to do df of /home/niko/nosnap/rootfs, but I forgot to use the right path. Anyway even for / 134.98 GiB + 1.8 GiB (hash file) should be 136.78 GiB which is less than the reported free space after the (partial) deduplication (137.16 GiB). Somehow the used space increased instead of decreasing.

@Floyddotnet
Copy link

@Floyddotnet Floyddotnet commented Nov 9, 2016

Let us check the block usage.

Execute this script please and post the output

cd /tmp
wget
https://raw.githubusercontent.com/kdave/btrfs-progs/master/btrfs-debugfs
chmod +x btrfs-debugfs
stats=$(sudo ./btrfs-debugfs -b /)

echo "00-49: " $(echo "$stats" | grep "usage 0.[0-4]" -c)
echo "50-59: " $(echo "$stats" | grep "usage 0.5" -c)
echo "60-69: " $(echo "$stats" | grep "usage 0.6" -c)
echo "70-79: " $(echo "$stats" | grep "usage 0.7" -c)
echo "80-89: " $(echo "$stats" | grep "usage 0.8" -c)
echo "90-99: " $(echo "$stats" | grep "usage 0.9" -c)
echo "100: " $(echo "$stats" | grep "usage 1." -c)

The btrfs-debugfs script is from the btrfs progs source and report the
usage of each block group. The following script groups the result.

2016-11-09 18:20 GMT+01:00 Niccolò Belli notifications@github.com:

Almost, on / I mounted the @ subvolume. I obviously wanted to do df of
/home/niko/nosnap/rootfs, but I forgot to use the right path. Anyway even
for / 134.98 GiB + 1.8 GiB (hash file) should be 136.78 GiB which is less
than the reported free space after the (partial) deduplication (137.16
GiB). Somehow the used space increased instead of decreasing.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#163 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAec4rALEjHJZJ4MD1UbHGX_D8NJBbJ1ks5q8gD1gaJpZM4KtY_m
.

@darkbasic
Copy link
Author

@darkbasic darkbasic commented Nov 10, 2016

Here it is:

00-49:  0
50-59:  0
60-69:  0
70-79:  6
80-89:  43
90-99:  94
100:    11
@Floyddotnet
Copy link

@Floyddotnet Floyddotnet commented Nov 10, 2016

This tells us that 6,93 GB (best case) - 19,8 GB (worst case) are allocated but not used.

6 * 0.3 + 43 * 0.2 + 94 * 0.1 = 19,8
6 * 0.21 + 43 * 0.11 + 94 * 0.01 = 6,93

This is normal btrfs behaivier, most notably, if you have files who are written often.
A simply balance run should free up a big part of this space again.

btrfs balance start -dusage=99 -musage=99 / or do a full balance btrfs balance start /

This command should take less then a half hour. you can check the progress with

btrfs balance status /

After balance please check usage again

btrfs filesystem df /

and if possible report the usage and the new results from my script.

@darkbasic
Copy link
Author

@darkbasic darkbasic commented Nov 11, 2016

Ok here is the situation after running a full balance with sudo btrfs balance start /home/niko/nosnap/rootfs/ --full-balance, but before running duperemove:

$ sudo btrfs filesystem usage /home/niko/nosnap/rootfs/
Overall:
    Device size:                 152.36GiB
    Device allocated:            133.03GiB
    Device unallocated:           19.33GiB
    Device missing:                  0.00B
    Used:                        130.91GiB
    Free (estimated):             20.24GiB      (min: 20.24GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              238.95MiB      (used: 0.00B)

Data,single: Size:130.00GiB, Used:129.08GiB
   /dev/mapper/cryptroot         130.00GiB

Metadata,single: Size:3.00GiB, Used:1.82GiB
   /dev/mapper/cryptroot           3.00GiB

System,single: Size:32.00MiB, Used:16.00KiB                                                                                                                                                                                                                  
   /dev/mapper/cryptroot          32.00MiB                                                                                                                                                                                                                   

Unallocated:                                                                                                                                                                                                                                                 
   /dev/mapper/cryptroot          19.33GiB

Then I runned duperemove with time sudo duperemove -drh --dedupe-options=noblock --hashfile=/home/niko/nosnap/rootfs.hash /home/niko/nosnap/rootfs/

Despite running the whole system without even a graphical interface to save memory it still got killed by OOM killer:

[0x13cdb680] (02664/25338) Try to dedupe extents with id 8dd235a8
[0x13cdb6d0] (02665/25338) Try to dedupe extents with id ece983d5
[0x13cdb680] Dedupe 66 extents (id: 8dd235a8) with target: (0.0, 140.1K), "/home/niko/nosnap/rootfs/@snapshots/4412/snapshot/usr/lib/qt/plugins/kcm_bluedevildevices.so"
[0x13cdb6d0] Dedupe 1 extents (id: ece983d5) with target: (0.0, 140.1K), "/home/niko/nosnap/rootfs/@snapshots/4155/snapshot/usr/lib/qt/plugins/kcm_bluedevildevices.so"
[0x13cdb6d0] (02666/25338) Try to dedupe extents with id 0ded176a
[ 8948.074113] 48 and 0 pages still available in the bound and unbound GPU page lists.
[ 8948.081397] Out of memory: Kill process 1883 (duperemove) score 370 or sacrifice child
[ 8948.085595] Killed process 1883 (duperemove) total-vm:6518304kB, anon-rss:6270708kB, file-rss:1032kB, shmem-rss:0kB
Ucciso

real    120m40.109s
user    78m59.120s
sys     56m15.750s

dmesg: https://paste.pound-python.org/show/jKlCEg7ZlYGdZfiJXzRy/

After the (partial) duperemove the disk usage actually got worse:

$ sudo btrfs filesystem usage /home/niko/nosnap/rootfs/
Overall:                                                                                                                                                                                                                                                     
    Device size:                 152.36GiB                                                                                                                                                                                                                   
    Device allocated:            136.03GiB                                                                                                                                                                                                                   
    Device unallocated:           16.33GiB                                                                                                                                                                                                                   
    Device missing:                  0.00B                                                                                                                                                                                                                   
    Used:                        133.35GiB                                                                                                                                                                                                                   
    Free (estimated):             17.50GiB      (min: 17.50GiB)                                                                                                                                                                                              
    Data ratio:                       1.00                                                                                                                                                                                                                   
    Metadata ratio:                   1.00                                                                                                                                                                                                                   
    Global reserve:              303.22MiB      (used: 0.00B)                                                                                                                                                                                                

Data,single: Size:132.00GiB, Used:130.83GiB                                                                                                                                                                                                                  
   /dev/mapper/cryptroot         132.00GiB                                                                                                                                                                                                                   

Metadata,single: Size:4.00GiB, Used:2.53GiB                                                                                                                                                                                                                  
   /dev/mapper/cryptroot           4.00GiB                                                                                                                                                                                                                   

System,single: Size:32.00MiB, Used:16.00KiB                                                                                                                                                                                                                  
   /dev/mapper/cryptroot          32.00MiB                                                                                                                                                                                                                   

Unallocated:                                                                                                                                                                                                                                                 
   /dev/mapper/cryptroot          16.33GiB

So I decided to run a full balance once again with sudo btrfs balance start /home/niko/nosnap/rootfs/ --full-balance, but it didn't improve:

$ sudo btrfs filesystem usage /home/niko/nosnap/rootfs/
Overall:
    Device size:                 152.36GiB
    Device allocated:            136.03GiB
    Device unallocated:           16.33GiB
    Device missing:                  0.00B
    Used:                        133.38GiB
    Free (estimated):             17.49GiB      (min: 17.49GiB)
    Data ratio:                       1.00
    Metadata ratio:                   1.00
    Global reserve:              326.72MiB      (used: 0.00B)

Data,single: Size:132.00GiB, Used:130.83GiB
   /dev/mapper/cryptroot         132.00GiB

Metadata,single: Size:4.00GiB, Used:2.55GiB
   /dev/mapper/cryptroot           4.00GiB

System,single: Size:32.00MiB, Used:16.00KiB
   /dev/mapper/cryptroot          32.00MiB

Unallocated:
   /dev/mapper/cryptroot          16.33GiB

Edit: damn, I forgot to delete that damn 1.4GiB hashfile once again. Anyway if you will add 1.4GiB to the estimated free space it will still be less than the previously available free space.

@markfasheh
Copy link
Owner

@markfasheh markfasheh commented Nov 11, 2016

What kernel version are you running? There was a memory leak in the kernel side implementation which got fixed in Linux v4.2.

@darkbasic
Copy link
Author

@darkbasic darkbasic commented Nov 11, 2016

I'm running 4.8.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.