Process freeze when calling UNSAFE.freeMemory of large chunks.
Ivan Daschinsky
ivandasch at gmail.com
Thu Oct 18 13:02:50 UTC 2018
Hi! I've faced recently with strange issue with UNSAFE.freeMemory. When in
some thread(threads) we try to deallocate huge chunks of memory, all
process freezes completely.
I've wrote reproducer in C and Java with relatively same functionality.
In few words, java reproducer will create N threads, each of therm
allocated 2^M chunk
of memory, sleeps T, than wait for barrier's broke. So all N threads will
simultaneously deallocate N*2^M total bytes of memory.
When we run java code on machine with 1.5 Tb of RAM with params N=40, M=33,
T=30, we see strange freeze on memory deallocation, when I run strace -F
-p, I see freeze when on munmap calls,
main thread freezes and stop printing "Tick" messages. However, perf record
doesn't handle these events and complains about too low --proc-map-timeout.
Even encrease of this timeout doesn't help. -XX:+PerfDisableSharedMem also
doesn't help. I will attach some excerpts from perf top during freeze
PerfTop: 7898 irqs/sec kernel:97.2% exact: 0.0% [4000Hz cycles],
(all, 64 CPUs)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
18.84% [kernel] [k] osq_lock
16.53% [kernel] [k] down_read_trylock
8.23% [kernel] [k] up_read
7.41% [kernel] [k] handle_mm_fault
4.02% libjvm.so [.]
GenericTaskQueueSet<OverflowTaskQueue<StarTask, (MemoryType)5, 131072u>,
(MemoryType)5>::steal_best_of_2
3.90% [kernel] [k] page_add_new_anon_rmap
3.10% [kernel] [k] find_vma
2.80% libjvm.so [.] Copy::fill_to_memory_atomic
2.74% [kernel] [k] mem_cgroup_charge_common
2.39% [kernel] [k] clear_page_c_e
1.76% [kernel] [k] free_pcppages_bulk
1.53% [kernel] [k] page_fault
1.46% [kernel] [k] unmap_page_range
1.21% [kernel] [k] release_pages
1.18% [kernel] [k] __mem_cgroup_commit_charge
1.15% [kernel] [k] __do_page_fault
1.08% [kernel] [k] __mem_cgroup_uncharge_common
1.00% [kernel] [k] __list_del_entry
0.89% [kernel] [k] get_pageblock_flags_group
0.76% [kernel] [k] rwsem_spin_on_owner
0.61% libjvm.so [.] G1ParScanThreadState::trim_queue
0.58% [kernel] [k] mem_cgroup_page_lruvec
Java code was run on OpenJDK 1.8.0_131-b12 on RHEL 7.4. and also on Oracle
JDK 1.8.0_121-b13.
However, C reproducer works like a charm without any freezes, it does I
suppose simply the same as Java one.
Could you please explain why this happens? Is it expected behaviour?
Code of reproducers you can download from these gists.
https://gist.github.com/ivandasch/491227e74b6536a6ba67090844192300
https://gist.github.com/ivandasch/4647528b8b0dc8324c370b86b9799ece
https://gist.github.com/ivandasch/60a649e872089602461ac72fd17508b7
--
Sincerely yours, Ivan Daschinskiy
More information about the jdk8u-dev
mailing list