3.14. sample_hbmem Usage Instructions
3.14.1. Function Overview
This document provides a detailed explanation of how to use sample_hbmem, including its main functions, source code structure, software architecture, and API flow. This example primarily focuses on the application of the hbmem API, especially the creation and usage of Com Buffer, Graphic Buffer, and Share Pool, as well as inter-process sharing mechanisms.
The main function of sample_hbmem is to provide examples of the hbmem API, covering the following content:
Com Buffer Creation and Management: Provides capabilities for creating, managing, and destroying shared communication buffers used for data exchange between multiple processes, effectively supporting inter-process collaboration.
Graphic Buffer Creation and Usage: Demonstrates how to create and manage graphic buffers, including configuration, manipulation, and transformation of graphic data, meeting the dynamic memory requirements in visual data processing.
Share Pool Usage: Implements allocation and release strategies for shared memory pools, optimizing resource utilization through shared memory pools, reducing the overhead of buffer creation and destruction, and improving the flexibility of memory management.
3.14.1.1. Software Architecture Description
This sample is implemented based on the libhbmem API. libhbmem is a memory management library built on ION, providing functionalities such as memory allocation, sharing, and recycling. It offers a unified API interface, enabling application developers to manage memory more conveniently, improve memory utilization, and achieve memory allocation for different buffer types and inter-process sharing. Refer to the software architecture diagram below for specific details.

3.14.1.2. Background Knowledge
Please refer to the ION System Debugging Guide section for more information.
3.14.1.3. API Flow Description
libhbmem provides a series of API interfaces, including: libhbmem library calling ION for buffer allocation.

The sample_hbmem example includes the use of hbmem APIs such as Alloc Com Buffer, Alloc Graph Buffer, and Share Pool, and illustrates the allocation and usage flowcharts of each API.

Alloc Com Buf: Allocates a shared communication buffer for data exchange between multiple processes, effectively supporting inter-process collaboration.
Alloc Com Buf With Heapmask: Allocates a shared communication buffer and specifies a heapmask to allocate the buffer to a specific heap.
Alloc Graph Buf: Allocates a graphic buffer, including configuration, manipulation, and transformation of graphic data, meeting the dynamic memory requirements in visual data processing.
Alloc Graph Buf With Heapmask: Allocates a graphic buffer and specifies a heapmask to allocate the buffer to a specific heap.

Share Com Buffer: Shares a communication buffer for data exchange between multiple processes, effectively supporting inter-process collaboration.
Share Graph Buffer: Shares a graphic buffer, including configuration, manipulation, and transformation of graphic data, meeting the dynamic memory requirements in visual data processing.
Share Pool: Shares a memory pool, implementing allocation and release strategies for shared memory pools, optimizing resource utilization through shared memory pools, reducing the overhead of buffer creation and destruction, and improving the flexibility of memory management.

Share Com Buffer Fork Process Scenario: Usage of shared communication buffers when creating child processes.
3.14.2. Compilation and Deployment
3.14.2.1. Source Code Structure
1. Code Path: /app/samples/platform_samples/sample_hbmem
2. Directory Structure:
sample_hbmem/
├── .gitignore
├── Makefile
├── sample_alloc.c
├── sample_common.c
├── sample_common.h
├── sample_pool.c
├── sample_queue.c
├── sample_share_pool.c
├── sample_share.c
└── sample.c
3.14.2.2. Compilation Instructions
This sample primarily depends on the header files provided by libhbmem:
#include <hb_mem_mgr.h>
#include <hb_mem_err.h>
Compilation dependencies include the following libraries:
LIBS += -lhbmem -lpthread -lalog -ldl -lstdc++
3.14.2.3. Compilation Environment
Enter the
app/samples/platform_samples/sample_hbmemdirectory and executemaketo compile.After successful compilation, the output executable file is
sample_hbmem.For detailed program compilation methods, please refer to the Compilation Methods section.
After uploading sample_hbmem to the development board, run the command chmod 777 sample_hbmem to grant the program executable permissions.
3.14.3. Running
After deploying sample_hbmem, directly execute the program ./sample_hbmem to obtain help information and the supported hbmem list:
# ./sample_hbmem
Options:
-m Specify sample use cases
-h Show this help message
Usage: ./sample_hbmem -m <index>
*************** Sample Mode Lists ***************
index: 1 sample_mode: Alloc Com Buf
index: 2 sample_mode: Alloc Com Buf With Cache
index: 3 sample_mode: Alloc Com Buf With Heapmask
index: 4 sample_mode: Alloc Graph Buf
index: 5 sample_mode: Alloc Graph Buf With Heapmask
index: 6 sample_mode: Share Com Buffer
index: 7 sample_mode: Share Com Buffer Fork Process Scenario
index: 8 sample_mode: Share Graph Buffer
index: 9 sample_mode: Share Graph Buffer Fork Process Scenario
index: 10 sample_mode: Share Pool Fork Process Scenario
index: 11 sample_mode: Share Pool
index: 12 sample_mode: Change Com Graph Buf
***************************************************
Select the desired Mode number according to the prompt to run the corresponding example. For instance, to run the Alloc Com Buf example, execute ./sample_hbmem -m 1, which will create the Alloc Com Buf example.
3.14.3.1. Command Explanation
-m: Specify the sample use case; see
Running Results Displayfor details.-h: Help information.
3.14.3.2. Test Result Description
If the log ends with
xxxx done, it indicates that the sample has executed successfully.
3.14.3.3. Running Results Display
Understanding the running commands requires some basic knowledge. Here is a brief explanation:
The /sys/kernel/debug/ion/clients/ directory displays the current system’s ION memory clients (excluding the BPU subsystem).
For example, if a process with ID 1114 requests and uses ION, a file node named 1114-0 will appear in this directory. Names such as cma_reserved,carveout, and ion_cma refer to different regions of ION. Readers are advised to first read the Background Knowledge section before continuing.
Creating Com Buf
# ./sample_hbmem -m 1
sample_mode = 1
=================================================
Ready to sample_alloc_com_buf
alloc com buf, share_id: 7
[1432:1432] Do system command cat /sys/kernel/debug/ion/clients/1432*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 400000 : 1 : 1 : d4b2ed6c : 3: 7 : 1
-------------------------------------------------------------------------
total 400000
-------------------------------------------------------------------------
[1432:1432] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1432 | grep -w sample_hbmem.
ion_cma sample_hbmem 1432 4194304
sample_hbmem 1432 other 4194304 0
[1432:1432] Result 0.
free com buf
[1432:1432] Do system command cat /sys/kernel/debug/ion/clients/1432*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
-------------------------------------------------------------------------
total 0
-------------------------------------------------------------------------
[1432:1432] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1432 | grep -w sample_hbmem.
[1432:1432] Result 256.
sample_alloc_com_buf done
=================================================
Creating Com Buf With Cache
# ./sample_hbmem -m 2
sample_mode = 2
=================================================
Ready to sample_alloc_com_buf_with_cache
memset uncached buf(size:4194304) use time: 691673
memset cached buf(size:4194304) use time: 457194
sample_alloc_com_buf_with_cache done
=================================================
Creating Com Buffer in Various Heaps
# ./sample_hbmem -m 3
sample_mode = 3
=================================================
Ready to sample_alloc_com_buf_with_heapmask
alloc com buf form ion_cma, size: 1048576
[1471:1471] Do system command cat /sys/kernel/debug/ion/clients/1471*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 100000 : 1 : 1 : 27d9b8ed : 3: 7 : 1
-------------------------------------------------------------------------
total 100000
-------------------------------------------------------------------------
[1471:1471] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1471 | grep -w sample_hbmem.
ion_cma sample_hbmem 1471 1048576
sample_hbmem 1471 other 1048576 0
[1471:1471] Result 0.
free com buf
alloc com buf form carveout, size: 1048576
[1471:1471] Do system command cat /sys/kernel/debug/ion/clients/1471*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
carveout: 100000 : 1 : 1 : 27d9b8ed : 3: 7 : 1
-------------------------------------------------------------------------
total 100000
-------------------------------------------------------------------------
[1471:1471] Do system command cat /sys/kernel/debug/ion/heaps/carveout | grep -w 1471 | grep -w sample_hbmem.
carveout sample_hbmem 1471 1048576
sample_hbmem 1471 other 1048576 0
[1471:1471] Result 0.
free com buf
alloc com buf form cma_reserved, size: 1048576
[1471:1471] Do system command cat /sys/kernel/debug/ion/clients/1471*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
cma_reserved: 100000 : 1 : 1 : 27d9b8ed : 3: 7 : 1
-------------------------------------------------------------------------
total 100000
-------------------------------------------------------------------------
[1471:1471] Do system command cat /sys/kernel/debug/ion/heaps/cma_reserved | grep -w 1471 | grep -w sample_hbmem.
cma_reserved sample_hbmem 1471 1048576
sample_hbmem 1471 other 1048576 0
[1471:1471] Result 0.
free com buf
sample_alloc_com_buf_with_heapmask done
=================================================
Creating Graph Buffer
# ./sample_hbmem -m 4
sample_mode = 4
=================================================
Ready to sample_alloc_graph_buf
graph_buf.plane_cnt: 2, graph_buf.format: 8, graph_buf.width: 1280, graph_buf.height: 720, graph_buf.stride: 0, graph_buf.vstride: 0, graph_buf.stride: 0, graph_buf.flags: 17
[1487:1487] Do system command cat /sys/kernel/debug/ion/clients/1487*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: e1000 : 1 : 1 : 27d9b8ed : 3: 7 : 1
ion_cma: 71000 : 1 : 1 : 1fe4048d : 3: 8 : 1
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1487:1487] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1487 | grep -w sample_hbmem.
ion_cma sample_hbmem 1487 1384448
sample_hbmem 1487 other 921600 0
sample_hbmem 1487 other 462848 0
[1487:1487] Result 0.
sample_alloc_graph_buf done
=================================================
Creating Graph Buffer in Various Heaps
# ./sample_hbmem -m 5
sample_mode = 5
=================================================
Ready to sample_alloc_graph_buf_with_heapmask
alloc graph buf form ion_cma
graph_buf.plane_cnt: 2, graph_buf.format: 8, graph_buf.width: 1280, graph_buf.height: 720, graph_buf.stride: 0, graph_buf.vstride: 0, graph_buf.stride: 0, graph_buf.flags: 17
[1493:1493] Do system command cat /sys/kernel/debug/ion/clients/1493*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 71000 : 1 : 1 : 27d9b8ed : 3: 8 : 1
ion_cma: e1000 : 1 : 1 : 1fe4048d : 3: 7 : 1
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1493:1493] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1493 | grep -w sample_hbmem.
ion_cma sample_hbmem 1493 1384448
sample_hbmem 1493 other 462848 0
sample_hbmem 1493 other 921600 0
[1493:1493] Result 0.
alloc graph buf form carveout
graph_buf.plane_cnt: 2, graph_buf.format: 8, graph_buf.width: 1280, graph_buf.height: 720, graph_buf.stride: 0, graph_buf.vstride: 0, graph_buf.stride: 0, graph_buf.flags: 4294967313
[1493:1493] Do system command cat /sys/kernel/debug/ion/clients/1493*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
carveout: e1000 : 1 : 1 : 27d9b8ed : 3: 7 : 1
carveout: 71000 : 1 : 1 : 1fe4048d : 3: 8 : 1
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1493:1493] Do system command cat /sys/kernel/debug/ion/heaps/carveout | grep -w 1493 | grep -w sample_hbmem.
carveout sample_hbmem 1493 1384448
sample_hbmem 1493 other 921600 0
sample_hbmem 1493 other 462848 0
[1493:1493] Result 0.
alloc graph buf form cma_reserved
graph_buf.plane_cnt: 2, graph_buf.format: 8, graph_buf.width: 1280, graph_buf.height: 720, graph_buf.stride: 0, graph_buf.vstride: 0, graph_buf.stride: 0, graph_buf.flags: 17179869201
[1493:1493] Do system command cat /sys/kernel/debug/ion/clients/1493*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
cma_reserved: 71000 : 1 : 1 : 27d9b8ed : 3: 8 : 1
cma_reserved: e1000 : 1 : 1 : 1fe4048d : 3: 7 : 1
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1493:1493] Do system command cat /sys/kernel/debug/ion/heaps/cma_reserved | grep -w 1493 | grep -w sample_hbmem.
cma_reserved sample_hbmem 1493 1384448
sample_hbmem 1493 other 462848 0
sample_hbmem 1493 other 921600 0
[1493:1493] Result 0.
sample_alloc_graph_buf_with_heapmask done
=================================================
Intra-process Common Buffer Sharing
# ./sample_hbmem -m 6
sample_mode = 6
=================================================
Ready to sample_share_com_buffer
alloc com buf, share_id: 7
import com buf, share_id: 7
[1510:1510] Do system command cat /sys/kernel/debug/ion/clients/1510*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 10000 : 2 : 2 : df1cdf5a : 4: 7 : 2
-------------------------------------------------------------------------
total 10000
-------------------------------------------------------------------------
[1510:1510] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1510 | grep -w sample_hbmem.
ion_cma sample_hbmem 1510 65536
sample_hbmem 1510 other 65536 0
[1510:1510] Result 0.
free com buf
[1510:1510] Do system command cat /sys/kernel/debug/ion/clients/1510*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 10000 : 1 : 1 : df1cdf5a : 3: 7 : 1
-------------------------------------------------------------------------
total 10000
-------------------------------------------------------------------------
[1510:1510] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1510 | grep -w sample_hbmem.
ion_cma sample_hbmem 1510 65536
sample_hbmem 1510 other 65536 0
[1510:1510] Result 0.
free import buf
[1510:1510] Do system command cat /sys/kernel/debug/ion/clients/1510*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
-------------------------------------------------------------------------
total 0
-------------------------------------------------------------------------
[1510:1510] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1510 | grep -w sample_hbmem.
[1510:1510] Result 256.
sample_share_com_buffer done
=================================================
Inter-process Common Buffer Sharing
# ./sample_hbmem -m 7
sample_mode = 7
=================================================
Ready to sample_share_com_buffer_fork_process_scenario
alloc graph buf form ion_cma
socketpair: 0
[1527:902] In parent process.
[1528:1527] In child process.
parent write share buf: parent test common buf share.
share_consume_cnt: 0
[1527:902] parent send msg 1
[1528:1527] child recv msg 1
child read share buf: parent test common buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1528:1527] child send msg 2
[1527:902] parent recv msg 2
parent read share buf: child test common buf share.
[1527:902] parent send msg 3
[1528:1527] child recv msg 3
share_consume_cnt: 0
[1527:902] parent quit
[1528:1527] child quit
alloc graph buf form carveout
socketpair: 0
[1527:902] In parent process.
parent write share buf: parent test common buf share.
share_consume_cnt: 0
[1529:1527] In child process.
[1527:902] parent send msg 1
[1529:1527] child recv msg 1
child read share buf: parent test common buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1529:1527] child send msg 2
[1527:902] parent recv msg 2
parent read share buf: child test common buf share.
[1527:902] parent send msg 3
[1529:1527] child recv msg 3
share_consume_cnt: 0
[1527:902] parent quit
[1529:1527] child quit
alloc graph buf form cma_reserved
socketpair: 0
[1527:902] In parent process.
parent write share buf: parent test common buf share.
share_consume_cnt: 0
[1530:1527] In child process.
[1527:902] parent send msg 1
[1530:1527] child recv msg 1
child read share buf: parent test common buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1530:1527] child send msg 2
[1527:902] parent recv msg 2
parent read share buf: child test common buf share.
[1527:902] parent send msg 3
[1530:1527] child recv msg 3
share_consume_cnt: 0
[1527:902] parent quit
[1530:1527] child quit
sample_share_com_buffer_fork_process_scenario done
=================================================
Intra-process Graphic Buffer Sharing
# ./sample_hbmem -m 8
sample_mode = 8
=================================================
Ready to sample_share_graph_buffer
alloc graph buf, share_id0: 7, share_id1: 8, share_id2: 8
import graph buf, share_id0: 7, share_id1: 8, share_id2: 8
[1531:1531] Do system command cat /sys/kernel/debug/ion/clients/1531*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: e1000 : 2 : 2 : b65c6afe : 4: 7 : 2
ion_cma: 71000 : 2 : 2 : d4b2ed6c : 4: 8 : 2
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1531:1531] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1531 | grep -w sample_hbmem.
ion_cma sample_hbmem 1531 1384448
sample_hbmem 1531 other 921600 0
sample_hbmem 1531 other 462848 0
[1531:1531] Result 0.
free graph buf
[1531:1531] Do system command cat /sys/kernel/debug/ion/clients/1531*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: e1000 : 1 : 1 : b65c6afe : 3: 7 : 1
ion_cma: 71000 : 1 : 1 : d4b2ed6c : 3: 8 : 1
-------------------------------------------------------------------------
total 152000
-------------------------------------------------------------------------
[1531:1531] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1531 | grep -w sample_hbmem.
ion_cma sample_hbmem 1531 1384448
sample_hbmem 1531 other 921600 0
sample_hbmem 1531 other 462848 0
[1531:1531] Result 0.
free import buf
[1531:1531] Do system command cat /sys/kernel/debug/ion/clients/1531*.
heap_name: size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
-------------------------------------------------------------------------
total 0
-------------------------------------------------------------------------
[1531:1531] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1531 | grep -w sample_hbmem.
[1531:1531] Result 256.
sample_share_graph_buffer done
=================================================
Inter-process Graphic Buffer Sharing
# ./sample_hbmem -m 9
sample_mode = 9
=================================================
Ready to sample_share_graph_buffer_fork_process_scenario
alloc graph buf form ion_cma
socketpair: 0
[1571:902] In parent process.
[1572:1571] In child process.
parent write share buf: parent test graph buf share.
share_consume_cnt: 0
[1571:902] parent send msg 1
[1572:1571] child recv msg 1
child read share buf: parent test graph buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1572:1571] child send msg 2
[1571:902] parent recv msg 2
```parent read share buf: child test common buf share.
[1571:902] parent send msg 3
[1572:1571] child recv msg 3
share_consume_cnt: 0
[1571:902] parent quit
[1572:1571] child quit
alloc graph buf form carveout
socketpair: 0
[1571:902] In parent process.
[1573:1571] In child process.
parent write share buf: parent test graph buf share.
share_consume_cnt: 0
[1571:902] parent send msg 1
[1573:1571] child recv msg 1
child read share buf: parent test graph buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1573:1571] child send msg 2
[1571:902] parent recv msg 2
parent read share buf: child test common buf share.
[1571:902] parent send msg 3
[1573:1571] child recv msg 3
share_consume_cnt: 0
[1571:902] parent quit
[1573:1571] child quit
alloc graph buf form cma_reserved
socketpair: 0
[1571:902] In parent process.
[1574:1571] In child process.
parent write share buf: parent test graph buf share.
share_consume_cnt: 0
[1571:902] parent send msg 1
[1574:1571] child recv msg 1
child read share buf: parent test graph buf share.
share_consume_cnt: 1
child write share buf: child test common buf share.
[1574:1571] child send msg 2
[1571:902] parent recv msg 2
parent read share buf: child test common buf share.
[1571:902] parent send msg 3
[1574:1571] child recv msg 3
share_consume_cnt: 0
[1571:902] parent quit
[1574:1571] child quit
sample_share_graph_buffer_fork_process_scenario done
=================================================
Inter-process Share Pool Sharing
# ./sample_hbmem -m 10
sample_mode = 10
=================================================
Ready to sample_share_pool_fork_process_scenario
[1576:902] In parent process.
[1577:1576] In child process.
[1576:1576] Do system command cat /sys/kernel/debug/ion/clients/1576*.
heap_name: [12121.854779] ion_share_pool_monitor_ref_cnt failed -512
size_in_bytes : handle refcount : handle import : buffer ptr : buffer refcount : buffer share id : buffer share count
ion_cma: 20000 : 1 : 1 : 4b5ef9a2 : 3: 7 : 1
ion_cma: 20000 : 1 : 1 : baf4062a : 3: 8 : 1
ion_cma: 20000 : 1 : 1 : c865393e : 3: 9 : 1
ion_cma: 20000 : 1 : 1 : 5db7853d : 3: 10 : 1
ion_cma: 20000 : 1 : 1 : d973ee69 : 3: 11 : 1
-------------------------------------------------------------------------
total a0000
-------------------------------------------------------------------------
[1576:1576] Do system command cat /sys/kernel/debug/ion/heaps/ion_cma | grep -w 1576 | grep -w sample_hbmem.
ion_cma sample_hbmem 1576 655360
sample_hbmem 1576 other 131072 0
sample_hbmem 1576 other 131072 0
sample_hbmem 1576 other 131072 0
sample_hbmem 1576 other 131072 0
sample_hbmem 1576 other 131072 0
[1576:1576] Result 0.
hb_mem_share_pool_alloc_buf 0 0xffffa12b0000
hb_mem_share_pool_alloc_buf 1 0xffffa12d0000
hb_mem_share_pool_alloc_buf 2 0xffffa12f0000
hb_mem_share_pool_alloc_buf 3 0xffffa1310000
hb_mem_share_pool_alloc_buf 4 0xffffa1330000
[1576:902] parent send msg 1
[1577:1576] child recv msg 1
[1577:1576] child send msg 2
[1576:902] parent recv msg 2
free 0 0xffffa12b0000
[1576:902] parent pool.avail_buf_cnt: 0
free 1 0xffffa12d0000
[1576:902] parent pool.avail_buf_cnt: 1
free 2 0xffffa12f0000
[1576:902] parent pool.avail_buf_cnt: 2
free 3 0xffffa1310000
[1576:902] parent pool.avail_buf_cnt: 3
free 4 0xffffa1330000
[1576:902] parent pool.avail_buf_cnt: 4
[1576:902] parent send msg 3
[1577:1576] child recv msg 3
[1577:1576] child send msg 4
[1576:902] parent recv msg 4
[1576:902] parent pool.avail_buf_cnt: 5
[1577:1576] child quit
[1576:902] parent quit
sample_share_pool_fork_process_scenario done
=================================================
Using Share Pool
# ./sample_hbmem -m 11
sample_mode = 11
=================================================
Ready to sample_share_pool
pool.avail_buf_cnt: 9
pool.avail_buf_cnt: 8
pool.avail_buf_cnt: 7
pool.avail_buf_cnt: 6
pool.avail_buf_cnt: 5
pool.avail_buf_cnt: 4
pool.avail_buf_cnt: 3
pool.avail_buf_cnt: 2
pool.avail_buf_cnt: 1
pool.avail_buf_cnt: 0
pool.avail_buf_cnt: 1
pool.avail_buf_cnt: 2
pool.avail_buf_cnt: 3
pool.avail_buf_cnt: 4
pool.avail_buf_cnt: 5
pool.avail_buf_cnt: 6
pool.avail_buf_cnt: 7
pool.avail_buf_cnt: 8
pool.avail_buf_cnt: 9
pool.avail_buf_cnt: 10
sample_share_pool done
=================================================
Buffer Conversion Between Graphic Buffer and Common Buffer
# ./sample_hbmem -m 12
sample_mode = 12
=================================================
Ready to sample_alloc_graph_buf_group_heapmask
----alloc graphic buffer done!----
the data in graphic buffer:
size: 0x1fa400
flags: 0x8000011
fd: 4
share id: 7
virt_addr: 0x0xffffae348000
paddr: 0xe1800000
----change graphic buffer to common buffer done!----
the data in new common buffer:
size: 0x1fa400
flags: 0x8000011
fd: 4
share id: 7
virt_addr: 0x0xffffae348000
paddr: 0xe1800000
----alloc common buffer done!----
the data in common buffer:
size: 0x10000
flags: 0x8000011
fd: 5
share id: 8
virt_addr: 0x0xffffaeb10000
paddr: 0xe1af8000
----change common buffer to graphic buffer done!----
the data in new graphic buffer:
size: 0x10000
flags: 0x8000011
fd: 5
share id: 8
virt_addr: 0x0xffffaeb10000
paddr: 0xe1af8000
sample_alloc_graph_buf_group_heapmask done
=================================================