SlideShare a Scribd company logo
1 of 68
Download to read offline
Memory Management in Tizen
SW Platform Team,
SW R&D Center
tizen.org2
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
• Memory Size Optimization
tizen.org3
Tizen Kernel Overview
tizen.org4
Tizen Kernel Overview
Kernel
Kernel
OAL (OEM Adaptation Layer)
Telephony
Plug-ins
GStreamer
Plug-ins
Sensor
Plug-ins
System
Plug-ins
OpenGL ES/EGL
Graphics Driver
Graphics
Memory
Management
IOMMU
DMA
BUF
Multimedia Power Management
CPUfre
q
Devf
req
Ther
mal
…
DRM
Link1 Link2
V4L2
Storage
Block Layer
MMC/Flash
Input, Sensor,
…
Peripheral
CMA
OpenGL ES
1.0/2.0
X11 GStreamerEFL . . .
Multimedia
FW
Telephony
FW
. . .Sensor FW System FW
. . .
More at http://source.tizen.org/documentation/porting-guide
Core
DRM Link1: http:// elinux.org/images/7/71/Elce11_dae.pdf
DRM Link2: http://download.tizen.org/misc/media/conference2012/wednesday/ballroom-c/2012-05-09-1330-1410-
the_drm_(direct_rendering_manager)_of_tizen_kernel.pdf
tizen.org5
Tizen Kernel Overview
Kernel
Kernel
OAL (OEM Adaptation Layer)
Telephony
Plug-ins
GStreamer
Plug-ins
Sensor
Plug-ins
System
Plug-ins
OpenGL ES/EGL
Graphics Driver
Graphics
Memory
Management
IOMM
U
DMA
BUF
Multimedia Power Management
CPUfre
q
Devf
req
Ther
mal
…DRM
Link1 Link2
V4L2
Storage
Block Layer
MMC/Flash
Input, Sensor,
…
Peripheral
CM
A
OpenGL ES
1.0/2.0
X11 GStreamerEFL . . .
Multimedia
FW
Telephony
FW
. . .Sensor FW System FW
. . .
More at http://source.tizen.org/documentation/porting-guide
Core Service Layer
DRM Link1: http:// elinux.org/images/7/71/Elce11_dae.pdf
DRM Link2: http://download.tizen.org/misc/media/conference2012/wednesday/ballroom-c/2012-05-09-1330-1410-
the_drm_(direct_rendering_manager)_of_tizen_kernel.pdf
• Memory Management in Tizen
– Coupled with Graphics & Multimedia devices.
• Graphics & Multimedia devices = DMA devices with HUGE buffers
tizen.org6
Tizen Kernel Overview
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
tizen.org7
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
– To Run Tizen OS.
• Basic Memory Management Components
• Buffer Sharing (UMM/DMABUF)
• Buffer Allocation (UMM/DMAAPI)
• Buffer Synchronization
• Memory Size Optimization
tizen.org8
Tizen Kernel MM, Graphics (DRM)
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
tizen.org9
Graphics:
DRM/GEM (Graphics Execution Manager)
drm_fb_helperdrm_mode_config
Linux
DRM Common Framework
GEM
drm_framebuffer fb_infoCrtc
Connector
Encoder
GEM
Allocator
Plane
Common
Specific
drm_framebufferCrtc
Connector
Encoder
Plane
tizen.org10
Graphics:
DRM/GEM (Graphics Execution Manager)
drm_fb_helperdrm_mode_config
Linux
DRM Common Framework
GEM
drm_framebuffer fb_infoCrtc
Connector
Encoder
GEM
Allocator
Plane
Common
Specific
drm_framebufferCrtc
Connector
Encoder
Plane
Graphics Execution Manager
• Framework developed by Intel
• To manage graphics memory
• Framework for buffer management.
• Allocation and sharing.
tizen.org11
Graphics: DRM/GEM Allocation
• GEM Allocation steps @ Tizen (Generic)
1. DRM_IOCTL_MODE_CREATE_DUMB
• Create GEM object(global) & user GEM handle(per process)
• dumb_create() of struct drm_driver
• No physical memory allocated.
2. DRM_IOCTL_MODE_MAP_DUMB
• Create fake mmap offset of a gem object and relay the object to user
• A hash key of the gem object.
• dumb_map_offset() of struct drm_driver
3. MMAP
• Request mmap based on the hash key as the offset
• Create user address space
• Setup cache attribute.
• Not mapped to physical memory, yet
tizen.org12
Graphics: DRM/GEM Allocation
• GEM Allocation steps @ Tizen (Generic)
4. On-demand Paging
– Implement & Register a fault handler that
• With a page fault, allocate a page and map the page.
– vma->vm_ops->fault = xxx_drm_gem_fault
5. Use!
6. DRM_IOCTL_MODE_DESTROY_DUMB
– Remove GEM handle & object
– Free memory
– Implement dumb_destroy() of struct drm_driver
tizen.org13
Graphics: DRM/GEM Allocation
• GEM Allocation steps @ Tizen (Exynos Only)
1. DRM_IOCTL_EXYNOS_GEM_CREATE
• Only use user-desired size and buffer types.
• Create gem object(global) & user gem handle(per process)
• physical memory allocated.
2. DRM_IOCTL_EXYNOS_GEM_MMAP
• Create user address space
• Map the user address space to physical memory
• LIBDRM of Exynos uses these APIs, not the generic.
tizen.org14
Graphics: DRM/GEM Sharing
• GEM Sharing @ Tizen
• DRM_IOCTL_GEM_FLINK
– “I will share this GEM to others.”
– Create GEM object name for the given GEM handle
• Global key vaue for sharing
• DRM_IOCTL_GEM_OPEN
– “I want to use the shared GEM.”
– Create GEM handle based on the given GEM object name
• DRM_IOCTL_GEM_CLOSE
• You don’t need to implement. It’s already there with DRM.
GEM
Create
GEM
FLINK
GEM
OPEN
gem handle gem object name gem handle
Process 1 Process 2
tizen.org15
Tizen Kernel MM, Multimedia (V4L2/VB2)
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
tizen.org16
Multimedia: V4L2/VB2
• Tizen recommends to use V4L2 at Tizen kernel for Multimedia
devices
• Video input (codec & camera) & Radio
• However, as long as the kernel has:
– Gstreamer/OpenMAX plugins
– A method to share with other F/W via DMABUF of UMM,
• Tizen multimedia works.
• If V4L2/VB2 is used, things get easier.
tizen.org17
Tizen Kernel MM, OpenGL/G3D-GPU
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
tizen.org18
OpenGL / G3D-GPU
• Most ARM SoC GPUs (MALI, SGX, …) use their own memory
manager
• E.g., Exynos4412/4210 Tizen Reference Kernel has Mali w/ UMP.
– Mali DDK modified to be compatible with UMM-DMABUF.
• If GPU drivers use DRM, it would be great.
• (and make them GPL)
tizen.org19
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
– To Run Tizen OS.
• Basic Memory Management Components
• Buffer Sharing (UMM/DMABUF)
• Buffer Allocation (UMM/DMAAPI)
• Buffer Synchronization
• Memory Size Optimization
tizen.org20
NEED FOR SOMETHING, A Scenario
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
Camera fetches a video stream
This scenario is simplified for presentation.
Not an actual example of Tizen
tizen.org21
NEED FOR SOMETHING, A Scenario
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
Camera fetches a video stream
Draws its own images
This scenario is simplified for presentation.
Not an actual example of Tizen
tizen.org22
NEED FOR SOMETHING, A Scenario
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
Camera fetches a video stream
Draws its own images
GPU Merges the two
/ Puts the merged image
This scenario is simplified for presentation.
Not an actual example of Tizen
tizen.org23
NEED FOR SOMETHING, A Scenario
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
Camera fetches a video stream
Draws its own images
DRM-FIMD(display) Output
This scenario is simplified for presentation.
Not an actual example of Tizen
GPU Merges the two
/ Puts the merged image
tizen.org24
NEED FOR SOMETHING, A Scenario
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
Camera fetches a video stream
Draws its own images
DRM-FIMD(display) Output
At a VB2 buffer
At a GEM buffer
GEM buffer
This scenario is simplified for presentation.
Not an actual example of Tizen
GPU Merges the two
/ Puts the merged image
From GEM + VB2 into its own (e.g., UMP)
tizen.org25
Tizen Kernel MM, UMM
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
A mechanism to share between
DRM, V4L2, and others
w/o memcpy
tizen.org26
Tizen Kernel MM, UMM
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
Requirement from Tizen platform and hardware
• Different Memory Managers: GEM, VB2, GPU-adhoc, …
• Share buffers
• w/o memcpy
• From and to users
• Never expose directly to users (e.g., physical address)
 UMM DMABUF!
tizen.org27
Tizen Kernel Memory Management
Unified Memory Management (UMM)
• Introduced by Jesse Barker, 2011
• Includes
– DMABUF (sharing buffer)
– DMA Mapping API for Allocation.
– CMA (Contiguous Memory Allocator)
IOMMU (MMU for I/O devs)
tizen.org28
Tizen Kernel MM, UMM
DMA Buffer Sharing: DMABUF
• Export
– GEM/VB2/… object  DMABUF
• Import
– DMABUF  GEM/VB2/… object
• Userspace sees DMABUF as a File Descriptor
tizen.org29
DMA Buffer Sharing: DMABUF, Example
Camera  Display
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM KMS
GEM Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org30
DMA Buffer Sharing: DMABUF, Example
Conceptual Data Flow
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM KMS
GEM Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org31
DMABUF Usage Example 1/4
Camera App
1) Request V4L2 camera buffer (U)
2) Allocate CMA buffer (K)
3) Request a camera frame at the
V4L2 buffer (U)
4) Store the camera frame &
Notify user (K)
5) Request DMABUF export for the
V4L2 camera buffer (U)
6) dma_buf_exporter() (K)
- Create DMABUF from V4L2 buffer
7) dma_buf_fd() (K)
- Provide FD of the DMABUF to
user
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org32
DMABUF Usage Example 1/4
Camera App
1) Request V4L2 camera buffer (U)
2) Allocate CMA buffer (K)
3) Request a camera frame at the
V4L2 buffer (U)
4) Store the camera frame &
Notify user (K)
5) Request DMABUF export for the
V4L2 camera buffer (U)
6) dma_buf_exporter() (K)
- Create DMABUF from V4L2 buffer
7) dma_buf_fd() (K)
- Provide FD of the DMABUF to
user
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org33
DMABUF Usage Example 1/4
Camera App
1) Request V4L2 camera buffer (U)
2) Allocate CMA buffer (K)
3) Request a camera frame at the
V4L2 buffer (U)
4) Store the camera frame &
Notify user (K)
5) Request DMABUF export for the
V4L2 camera buffer (U)
6) dma_buf_exporter() (K)
- Create DMABUF from V4L2 buffer
7) dma_buf_fd() (K)
- Provide FD of the DMABUF to
user
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org34
DMABUF Usage Example 2/4
Camera App
8) Request FD->GEM conversion (U)
9) dma_buf_get(fd) (K)
- Get DMABUF from FD
10)dma_buf_attach(dma-buf) /
dma_buf_map_attachment() (K)
- Get Buffer from DMABUF
11) Import as GEM, send user (K)
12) Request GEM object name (U)
13) Return GEM object name (K)
14) Send GEM object name to X (U)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org35
DMABUF Usage Example 2/4
Camera App
8) Request FD->GEM conversion (U)
9) dma_buf_get(fd) (K)
- Get DMABUF from FD
10) dma_buf_attach(dma-buf) /
dma_buf_map_attachment() (K)
- Get Buffer from DMABUF
11) Import as GEM, send user (K)
12) Request GEM object name (U)
13) Return GEM object name (K)
14) Send GEM object name to X (U)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org36
DMABUF Usage Example 3/4
X server
15) Convert given GEM object name
to GEM. Display its content.
(U & K)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org37
DMABUF Usage Example 3/4
X server
15) Convert given GEM object name
to GEM. Display its content.
(U & K)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org38
DMABUF Usage Example 4/4
Close after usage
1) “Free” the GEM object (U)
2) Remove reference from the
DMABUF (K)
3) Close(DMABUF-FD) at cam app (U)
4) (No more reference to DMABUF)
Release callback executed (K)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org39
DMABUF Usage Example 4/4
Close after usage
1) “Free” the GEM object (U)
2) Remove reference from the
DMABUF
3) Close(DMABUF-FD) at cam app (U)
4) (No more reference to DMABUF)
Release callback executed (K)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org40
DMABUF Usage Example 4/4
Close after usage
1) “Free” the GEM object (U)
2) Remove reference from the
DMABUF
3) Close(DMABUF-FD) at cam app (U)
4) (No more reference to DMABUF)
Release callback executed (K)
X server
Video encoder
Xvsink
Camera src
User space
Kernel space DRM
KMS
GEM
Codec CameraV4L2 V4L2
struct dma_buf
Display Codec Camera
Memory
Camera App
FD
HW
tizen.org41
Sorry, Back to DRM/GEM…
• DMABUF Import / Export needs to be added
• DRM_IOCTL_PRIME_HANDLE_TO_FD
• Export gem handle into dmabuf fd
• DRM_IOCTL_PRIME_FD_TO_HANDLE
• Import dmabuf fd into gem handle
tizen.org42
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
– To Run Tizen OS.
• Basic Memory Management Components
• Buffer Sharing (UMM/DMABUF)
• Buffer Allocation (UMM/DMAAPI)
• Buffer Synchronization
• Memory Size Optimization
tizen.org43
Tizen Kernel Memory Management
Unified Memory Management (UMM)
• Introduced by Jesse Barker, 2011
• Includes
– DMABUF (sharing buffer)
– DMA Mapping API for Allocation.
– CMA (Contiguous Memory Allocator)
IOMMU (MMU for I/O devs)
tizen.org44
Tizen Kernel MM, UMM
DMA Mapping API @ Tizen Reference
DRM / GEM
DMA Mapping Framework
IOMMUBuddyCMA
IOMMU
Common
Driver
System Memory
V4L2 / VB2
1 2
1: “Exynos-DRM” provides unified device address space for all DRM devices
2: Each V4L2 device has its own device address space
2 2
tizen.org45
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
– To Run Tizen OS.
• Basic Memory Management Components
• Buffer Sharing (UMM/DMABUF)
• Buffer Allocation (UMM/DMAAPI)
• Buffer Synchronization
• Memory Size Optimization
tizen.org46
Tizen Kernel Memory Management
We Still Have A HUGE Problem!
tizen.org47
Tizen Kernel MM, Buffer Sync.
Kernel / Device Drivers (BSP)
Kernel / Core & Subsystem
X Server
DRM Framework
GEM
Display HDMI
Virtual
Display
Post
Processor
G2D
EFL
Evas
2D GPU
backend
X Video Drivers
Userptr
NEON
2D GPU
backend
PIXMAN
EXA
V4L2
VB2
Codec Camera
GStreamer
OpenMAX
Libdrm
XV Extension
UMM
Open
GL
Multimedia FW
XvImageSink
Core External
Library
Core
Framework
OEM
Adaptation
Kernel
Kernel
GPU
DDK
(G3D)
Radio
* Images from MS Office clipart and Samsung
Gstreamer-
CameraSrc
DMABUF
Synchronization?
tizen.org48
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU GPU
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
tizen.org49
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU GPU
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
tizen.org50
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU GPU
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
tizen.org51
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU GPU
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
tizen.org52
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU GPU
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
tizen.org53
Tizen Kernel MM, Buffer Sync.
What’s the problem?
Simple Usage Scenario
1. CPU writes to buffer1.
2. CPU tells GPU to do something on buffer1.
3. GPU does something on buffer1.
4. GPU finishes.
5. CPU reads the buffer1
How to ensure CPU won’t use buffer 1 until step 4?
(esp., a user process)
tizen.org54
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU,
Thread1
GPU
• What if there are two threads using GPU?
– And if the two look at the same buffer?
• Not even aware of it?
CPU,
Thread2
tizen.org55
Tizen Kernel MM, Buffer Sync.
What’s the problem?
BUS
DRAMDRAMDRAM
CPU,
Thread1
GPU
• What if the two DMA devices (GPU, FIMC) share buffer?
– But hard to know it at drivers or user threads.
– FIMC never knows when GPU finishes
– FIMC never knows when Threads1 stops using “buffer1”
– Threads2 never know when GPU stops using “buffer1”
CPU,
Thread2
FIMC-IPP
(Image Post Processing)
tizen.org56
Tizen Kernel Memory Management
Buffer Synchronization
• TGL (Tizen Global Lock) @ Tizen 2.0
– … Let userspace handle the issue …
– Kernel patch required.
• Sync Framework (Google)
– Jun, 2012. Resources w/o DMABUF (similar with TGL)
• KDS (Kernel Dependency System, ARM)
– May 2012 / DMABUF-compatible
• DMA Fence Framework (Canonical/TI)
– Aug 2012 / DMABUF-compatible
– Work-In-Progress
tizen.org57
Contents
• Tizen Kernel Overview
• Memory Management in Tizen Kernel
• Memory Size Optimization
– To Run w/ More Devices
tizen.org58
Memory Size Optimization: Challenge
• A device with 512MB RAM
• Graphics/Multimedia devices want 400MB reserved
– No IOMMU.
• The userspace wants to run a web browser and HTML5 app!
•REALLY POSSIBLE?
tizen.org59
Memory Size Optimization: Challenge
• A device with 512MB RAM
• Graphics/Multimedia devices want 400MB reserved
– No IOMMU
• The userspace wants to run a web browser and HTML5 app!
•REALLY POSSIBLE?
•WHY NOT?
tizen.org60
Minimize H/W Reserved Memory
CMA (Contiguous Memory Allocator)
• Camera wants to reserve 400MB.
– No IOMMU: too primitive to use paging.
• You don’t use cameras while web browsing.
– Free the 400MB reserved to camera, let userspace use it.
• CMA can do.
tizen.org61
Minimize H/W Reserved Memory
• (Obsolete/Low-cost) ARM SoC’s DMA devices
– No IOMMU
– Use physically continuous memory chunk.
• No paging
• Potentially, a lot of memory is wasted.
BUS
CPU
MMU
L2 Cache
DRAM Controller
DRAMDRAMDRAM
CPUCPU
GPU
tizen.org62
Minimize H/W Reserved Memory
IOMMU
• (Modern/Mid-High-cost) ARM SoC’s DMA devices
– IOMMU for DMA devices!
– Use paging!
• Dynamically allocate & free
BUS
CPU
MMU
L2 Cache
DRAM Controller
DRAMDRAMDRAM
CPUCPU
GPU
IOMMU
tizen.org63
Minimize H/W Reserved Memory
IOMMU
• Exynos4210/4412-based Tizen mobile device
– Achieved near-zero reserved memory.
– At the “menuscreen”, only around ~40MB allocated for display
and GPU.
– Unfortunately, not included in the Tizen reference kernel.
• But easily supported by Vanilla kernel for Tizen reference boards
tizen.org64
Minimize H/W Reserved Memory
Results with 1GB RAM Device
-sh-4.1# free
total used free shared buffers cached
Mem: 1029428 302020 727408 0 16164 133084
-/+ buffers/cache: 152772 876656
Swap: 0 0 0
-sh-4.1# uname -a
Linux localhost 3.8.3-00841-gc1981b1 #34 SMP PREEMPT Wed Apr 10 10:24:04 KST 2013 armv7l GNU/Linux
Mostly available to kernel (1005.3 of 1024MB)
Even with Tizen loaded, mostly free to users (856MB of 1GB)
tizen.org65
Memory Size Optimization:
Still Hungry?
• Further optimization required for low-budget devices
– Running full features with 512MB?
– Or even < 512MB?
• What about multi-tasking or “background apps”?
tizen.org66
Memory Size Optimization: SWAP
• Swap
– zRAM
• Used in some Samsung mobile devices successfully
– Or even swap-to-flash?
tizen.org67
Memory Size Optimization:
Multitasking / Background Apps
• Limit multitasking & background-app support
• Pseudo multitasking by freezing background apps
Thank you!

More Related Content

What's hot

"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
 
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...MIPI Alliance
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT Mia Chang
 
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化NVIDIA Japan
 
NEDIA_SNIA_CXL_講演資料.pdf
NEDIA_SNIA_CXL_講演資料.pdfNEDIA_SNIA_CXL_講演資料.pdf
NEDIA_SNIA_CXL_講演資料.pdfYasunori Goto
 
Tensor flow usergroup 2016 (公開版)
Tensor flow usergroup 2016 (公開版)Tensor flow usergroup 2016 (公開版)
Tensor flow usergroup 2016 (公開版)Hiroki Nakahara
 
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System mentoresd
 
Introduction of android treble
Introduction of android trebleIntroduction of android treble
Introduction of android trebleBin Yang
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGLSuhan Lee
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALOpersys inc.
 
Broadcom PCIe & CXL Switches OCP Final.pptx
Broadcom PCIe & CXL Switches OCP Final.pptxBroadcom PCIe & CXL Switches OCP Final.pptx
Broadcom PCIe & CXL Switches OCP Final.pptxMemory Fabric Forum
 
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...The Linux Foundation
 
Microchip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling EcosystemMicrochip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling EcosystemMemory Fabric Forum
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
 
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」PC Cluster Consortium
 
IPMI is dead, Long live Redfish
IPMI is dead, Long live RedfishIPMI is dead, Long live Redfish
IPMI is dead, Long live RedfishBruno Cornec
 
LCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLinaro
 
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUs
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUsAMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUs
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUsAMD
 

What's hot (20)

"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
 
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...
MIPI DevCon Taipei 2019: Addressing 5G RFFE Control Challenges with MIPI RFFE...
 
TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT   TensorFlow Lite for mobile & IoT
TensorFlow Lite for mobile & IoT
 
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化
NVIDIA cuQuantum SDK による量子回路シミュレーターの高速化
 
NEDIA_SNIA_CXL_講演資料.pdf
NEDIA_SNIA_CXL_講演資料.pdfNEDIA_SNIA_CXL_講演資料.pdf
NEDIA_SNIA_CXL_講演資料.pdf
 
Tensor flow usergroup 2016 (公開版)
Tensor flow usergroup 2016 (公開版)Tensor flow usergroup 2016 (公開版)
Tensor flow usergroup 2016 (公開版)
 
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System
Simultaneously Leveraging Linux and Android in a GENIVI compliant IVI System
 
Introduction of android treble
Introduction of android trebleIntroduction of android treble
Introduction of android treble
 
Sigtran Workshop
Sigtran WorkshopSigtran Workshop
Sigtran Workshop
 
Understaing Android EGL
Understaing Android EGLUnderstaing Android EGL
Understaing Android EGL
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Broadcom PCIe & CXL Switches OCP Final.pptx
Broadcom PCIe & CXL Switches OCP Final.pptxBroadcom PCIe & CXL Switches OCP Final.pptx
Broadcom PCIe & CXL Switches OCP Final.pptx
 
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
XPDDS18: Design and Implementation of Automotive: Virtualization Based on Xen...
 
Microchip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling EcosystemMicrochip: CXL Use Cases and Enabling Ecosystem
Microchip: CXL Use Cases and Enabling Ecosystem
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」
PCCC22:インテル株式会社 テーマ1「インテル® Agilex™ FPGA デバイス 最新情報」
 
IPMI is dead, Long live Redfish
IPMI is dead, Long live RedfishIPMI is dead, Long live Redfish
IPMI is dead, Long live Redfish
 
LCE13: Android Graphics Upstreaming
LCE13: Android Graphics UpstreamingLCE13: Android Graphics Upstreaming
LCE13: Android Graphics Upstreaming
 
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUs
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUsAMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUs
AMD Radeon™ RX 5700 Series 7nm Energy-Efficient High-Performance GPUs
 
Virtual Chassis Fabric for Cloud Builder
Virtual Chassis Fabric for Cloud BuilderVirtual Chassis Fabric for Cloud Builder
Virtual Chassis Fabric for Cloud Builder
 

Similar to Memory Management in TIZEN - Samsung SW Platform Team

Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driverKernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driverAnne Nicolas
 
Add sale davinci
Add sale davinciAdd sale davinci
Add sale davinciAkash Sahoo
 
0xdroid osdc-2010-100426084937-phpapp02
0xdroid osdc-2010-100426084937-phpapp020xdroid osdc-2010-100426084937-phpapp02
0xdroid osdc-2010-100426084937-phpapp02chon2010
 
Porting Android
Porting AndroidPorting Android
Porting AndroidOpersys inc.
 
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Joone Hur
 
Porting Tizen-IVI 3.0 to an ARM based SoC Platform
Porting Tizen-IVI 3.0 to an ARM based SoC PlatformPorting Tizen-IVI 3.0 to an ARM based SoC Platform
Porting Tizen-IVI 3.0 to an ARM based SoC PlatformRyo Jin
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateLinaro
 
Android Development Tools
Android Development ToolsAndroid Development Tools
Android Development ToolsDominik Helleberg
 
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) Winning
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) WinningKernel Recipes 2016 - Upstream Kernel Graphics is (Finally) Winning
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) WinningAnne Nicolas
 
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...The Linux Foundation
 
Porting Android
Porting AndroidPorting Android
Porting AndroidOpersys inc.
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011Opersys inc.
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMDEdge AI and Vision Alliance
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in AndroidOpersys inc.
 
Android Internals
Android InternalsAndroid Internals
Android InternalsOpersys inc.
 
The abcs of gpu
The abcs of gpuThe abcs of gpu
The abcs of gpuLiang Yan
 

Similar to Memory Management in TIZEN - Samsung SW Platform Team (20)

Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driverKernel Recipes 2014 - The Linux graphics stack and Nouveau driver
Kernel Recipes 2014 - The Linux graphics stack and Nouveau driver
 
Add sale davinci
Add sale davinciAdd sale davinci
Add sale davinci
 
0xdroid osdc-2010-100426084937-phpapp02
0xdroid osdc-2010-100426084937-phpapp020xdroid osdc-2010-100426084937-phpapp02
0xdroid osdc-2010-100426084937-phpapp02
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
Accelerate graphics performance with ozone-gbm on Intel based Linux desktop s...
 
Porting Tizen-IVI 3.0 to an ARM based SoC Platform
Porting Tizen-IVI 3.0 to an ARM based SoC PlatformPorting Tizen-IVI 3.0 to an ARM based SoC Platform
Porting Tizen-IVI 3.0 to an ARM based SoC Platform
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
There is more to C
There is more to CThere is more to C
There is more to C
 
BKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack UpdateBKK16-315 Graphics Stack Update
BKK16-315 Graphics Stack Update
 
Android Development Tools
Android Development ToolsAndroid Development Tools
Android Development Tools
 
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) Winning
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) WinningKernel Recipes 2016 - Upstream Kernel Graphics is (Finally) Winning
Kernel Recipes 2016 - Upstream Kernel Graphics is (Finally) Winning
 
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...
XPDDS17: Keynote: Shared Coprocessor Framework on ARM - Oleksandr Andrushchen...
 
Flowframes
FlowframesFlowframes
Flowframes
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD
“Programming Vision Pipelines on AMD’s AI Engines,” a Presentation from AMD
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
The abcs of gpu
The abcs of gpuThe abcs of gpu
The abcs of gpu
 

More from Ryo Jin

Why is EFL used on Tizen?
Why is EFL used on Tizen?Why is EFL used on Tizen?
Why is EFL used on Tizen?Ryo Jin
 
Samsung Z4 User Manual
Samsung Z4 User ManualSamsung Z4 User Manual
Samsung Z4 User ManualRyo Jin
 
Samsung ARTIK 050 (ARTIK ZERO) Modules Data Sheet
Samsung ARTIK 050 (ARTIK ZERO) Modules Data SheetSamsung ARTIK 050 (ARTIK ZERO) Modules Data Sheet
Samsung ARTIK 050 (ARTIK ZERO) Modules Data SheetRyo Jin
 
Introduction to Watch Face Development with Tizen Studio
Introduction to Watch Face Development with Tizen StudioIntroduction to Watch Face Development with Tizen Studio
Introduction to Watch Face Development with Tizen StudioRyo Jin
 
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan Driver
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan DriverTizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan Driver
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan DriverRyo Jin
 
Panduan Penggunaan Perangkat Wearable Tizen
Panduan Penggunaan Perangkat Wearable TizenPanduan Penggunaan Perangkat Wearable Tizen
Panduan Penggunaan Perangkat Wearable TizenRyo Jin
 
Cara Menggunakan Smartphone Tizen
Cara Menggunakan Smartphone TizenCara Menggunakan Smartphone Tizen
Cara Menggunakan Smartphone TizenRyo Jin
 
Gear Fit2 Watchface Design Guide
Gear Fit2 Watchface Design GuideGear Fit2 Watchface Design Guide
Gear Fit2 Watchface Design GuideRyo Jin
 
Samsung Indonesia: Tizen Store
Samsung Indonesia: Tizen StoreSamsung Indonesia: Tizen Store
Samsung Indonesia: Tizen StoreRyo Jin
 
Samsung Indonesia: Tizen Wearables
Samsung Indonesia: Tizen WearablesSamsung Indonesia: Tizen Wearables
Samsung Indonesia: Tizen WearablesRyo Jin
 
Samsung Indonesia: Tizen Web Apps
Samsung Indonesia: Tizen Web AppsSamsung Indonesia: Tizen Web Apps
Samsung Indonesia: Tizen Web AppsRyo Jin
 
Samsung Indonesia: Tizen Native App
Samsung Indonesia: Tizen Native AppSamsung Indonesia: Tizen Native App
Samsung Indonesia: Tizen Native AppRyo Jin
 
Samsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTSamsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTRyo Jin
 
Russian Tizen Project
Russian Tizen ProjectRussian Tizen Project
Russian Tizen ProjectRyo Jin
 
Samsung SM-R360 Tizen User Manual
Samsung SM-R360 Tizen User ManualSamsung SM-R360 Tizen User Manual
Samsung SM-R360 Tizen User ManualRyo Jin
 
Tizen Micro Profile for IoT device
Tizen Micro Profile for IoT deviceTizen Micro Profile for IoT device
Tizen Micro Profile for IoT deviceRyo Jin
 
Panduan Dasar Pemrograman Tizen
Panduan Dasar Pemrograman TizenPanduan Dasar Pemrograman Tizen
Panduan Dasar Pemrograman TizenRyo Jin
 
The Story of Enlightenment, EFL, Tizen and Wayland
The Story of Enlightenment, EFL, Tizen and WaylandThe Story of Enlightenment, EFL, Tizen and Wayland
The Story of Enlightenment, EFL, Tizen and WaylandRyo Jin
 
Tizen PASS
Tizen PASSTizen PASS
Tizen PASSRyo Jin
 
Tizen PASS
Tizen PASSTizen PASS
Tizen PASSRyo Jin
 

More from Ryo Jin (20)

Why is EFL used on Tizen?
Why is EFL used on Tizen?Why is EFL used on Tizen?
Why is EFL used on Tizen?
 
Samsung Z4 User Manual
Samsung Z4 User ManualSamsung Z4 User Manual
Samsung Z4 User Manual
 
Samsung ARTIK 050 (ARTIK ZERO) Modules Data Sheet
Samsung ARTIK 050 (ARTIK ZERO) Modules Data SheetSamsung ARTIK 050 (ARTIK ZERO) Modules Data Sheet
Samsung ARTIK 050 (ARTIK ZERO) Modules Data Sheet
 
Introduction to Watch Face Development with Tizen Studio
Introduction to Watch Face Development with Tizen StudioIntroduction to Watch Face Development with Tizen Studio
Introduction to Watch Face Development with Tizen Studio
 
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan Driver
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan DriverTizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan Driver
Tizen 3.0's Window System Integration Layer of OpenGLES/EGL & Vulkan Driver
 
Panduan Penggunaan Perangkat Wearable Tizen
Panduan Penggunaan Perangkat Wearable TizenPanduan Penggunaan Perangkat Wearable Tizen
Panduan Penggunaan Perangkat Wearable Tizen
 
Cara Menggunakan Smartphone Tizen
Cara Menggunakan Smartphone TizenCara Menggunakan Smartphone Tizen
Cara Menggunakan Smartphone Tizen
 
Gear Fit2 Watchface Design Guide
Gear Fit2 Watchface Design GuideGear Fit2 Watchface Design Guide
Gear Fit2 Watchface Design Guide
 
Samsung Indonesia: Tizen Store
Samsung Indonesia: Tizen StoreSamsung Indonesia: Tizen Store
Samsung Indonesia: Tizen Store
 
Samsung Indonesia: Tizen Wearables
Samsung Indonesia: Tizen WearablesSamsung Indonesia: Tizen Wearables
Samsung Indonesia: Tizen Wearables
 
Samsung Indonesia: Tizen Web Apps
Samsung Indonesia: Tizen Web AppsSamsung Indonesia: Tizen Web Apps
Samsung Indonesia: Tizen Web Apps
 
Samsung Indonesia: Tizen Native App
Samsung Indonesia: Tizen Native AppSamsung Indonesia: Tizen Native App
Samsung Indonesia: Tizen Native App
 
Samsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoTSamsung Indonesia: Tizen Platform Overview and IoT
Samsung Indonesia: Tizen Platform Overview and IoT
 
Russian Tizen Project
Russian Tizen ProjectRussian Tizen Project
Russian Tizen Project
 
Samsung SM-R360 Tizen User Manual
Samsung SM-R360 Tizen User ManualSamsung SM-R360 Tizen User Manual
Samsung SM-R360 Tizen User Manual
 
Tizen Micro Profile for IoT device
Tizen Micro Profile for IoT deviceTizen Micro Profile for IoT device
Tizen Micro Profile for IoT device
 
Panduan Dasar Pemrograman Tizen
Panduan Dasar Pemrograman TizenPanduan Dasar Pemrograman Tizen
Panduan Dasar Pemrograman Tizen
 
The Story of Enlightenment, EFL, Tizen and Wayland
The Story of Enlightenment, EFL, Tizen and WaylandThe Story of Enlightenment, EFL, Tizen and Wayland
The Story of Enlightenment, EFL, Tizen and Wayland
 
Tizen PASS
Tizen PASSTizen PASS
Tizen PASS
 
Tizen PASS
Tizen PASSTizen PASS
Tizen PASS
 

Recently uploaded

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Memory Management in TIZEN - Samsung SW Platform Team

  • 1. Memory Management in Tizen SW Platform Team, SW R&D Center
  • 2. tizen.org2 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel • Memory Size Optimization
  • 4. tizen.org4 Tizen Kernel Overview Kernel Kernel OAL (OEM Adaptation Layer) Telephony Plug-ins GStreamer Plug-ins Sensor Plug-ins System Plug-ins OpenGL ES/EGL Graphics Driver Graphics Memory Management IOMMU DMA BUF Multimedia Power Management CPUfre q Devf req Ther mal … DRM Link1 Link2 V4L2 Storage Block Layer MMC/Flash Input, Sensor, … Peripheral CMA OpenGL ES 1.0/2.0 X11 GStreamerEFL . . . Multimedia FW Telephony FW . . .Sensor FW System FW . . . More at http://source.tizen.org/documentation/porting-guide Core DRM Link1: http:// elinux.org/images/7/71/Elce11_dae.pdf DRM Link2: http://download.tizen.org/misc/media/conference2012/wednesday/ballroom-c/2012-05-09-1330-1410- the_drm_(direct_rendering_manager)_of_tizen_kernel.pdf
  • 5. tizen.org5 Tizen Kernel Overview Kernel Kernel OAL (OEM Adaptation Layer) Telephony Plug-ins GStreamer Plug-ins Sensor Plug-ins System Plug-ins OpenGL ES/EGL Graphics Driver Graphics Memory Management IOMM U DMA BUF Multimedia Power Management CPUfre q Devf req Ther mal …DRM Link1 Link2 V4L2 Storage Block Layer MMC/Flash Input, Sensor, … Peripheral CM A OpenGL ES 1.0/2.0 X11 GStreamerEFL . . . Multimedia FW Telephony FW . . .Sensor FW System FW . . . More at http://source.tizen.org/documentation/porting-guide Core Service Layer DRM Link1: http:// elinux.org/images/7/71/Elce11_dae.pdf DRM Link2: http://download.tizen.org/misc/media/conference2012/wednesday/ballroom-c/2012-05-09-1330-1410- the_drm_(direct_rendering_manager)_of_tizen_kernel.pdf • Memory Management in Tizen – Coupled with Graphics & Multimedia devices. • Graphics & Multimedia devices = DMA devices with HUGE buffers
  • 6. tizen.org6 Tizen Kernel Overview Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF
  • 7. tizen.org7 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel – To Run Tizen OS. • Basic Memory Management Components • Buffer Sharing (UMM/DMABUF) • Buffer Allocation (UMM/DMAAPI) • Buffer Synchronization • Memory Size Optimization
  • 8. tizen.org8 Tizen Kernel MM, Graphics (DRM) Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF
  • 9. tizen.org9 Graphics: DRM/GEM (Graphics Execution Manager) drm_fb_helperdrm_mode_config Linux DRM Common Framework GEM drm_framebuffer fb_infoCrtc Connector Encoder GEM Allocator Plane Common Specific drm_framebufferCrtc Connector Encoder Plane
  • 10. tizen.org10 Graphics: DRM/GEM (Graphics Execution Manager) drm_fb_helperdrm_mode_config Linux DRM Common Framework GEM drm_framebuffer fb_infoCrtc Connector Encoder GEM Allocator Plane Common Specific drm_framebufferCrtc Connector Encoder Plane Graphics Execution Manager • Framework developed by Intel • To manage graphics memory • Framework for buffer management. • Allocation and sharing.
  • 11. tizen.org11 Graphics: DRM/GEM Allocation • GEM Allocation steps @ Tizen (Generic) 1. DRM_IOCTL_MODE_CREATE_DUMB • Create GEM object(global) & user GEM handle(per process) • dumb_create() of struct drm_driver • No physical memory allocated. 2. DRM_IOCTL_MODE_MAP_DUMB • Create fake mmap offset of a gem object and relay the object to user • A hash key of the gem object. • dumb_map_offset() of struct drm_driver 3. MMAP • Request mmap based on the hash key as the offset • Create user address space • Setup cache attribute. • Not mapped to physical memory, yet
  • 12. tizen.org12 Graphics: DRM/GEM Allocation • GEM Allocation steps @ Tizen (Generic) 4. On-demand Paging – Implement & Register a fault handler that • With a page fault, allocate a page and map the page. – vma->vm_ops->fault = xxx_drm_gem_fault 5. Use! 6. DRM_IOCTL_MODE_DESTROY_DUMB – Remove GEM handle & object – Free memory – Implement dumb_destroy() of struct drm_driver
  • 13. tizen.org13 Graphics: DRM/GEM Allocation • GEM Allocation steps @ Tizen (Exynos Only) 1. DRM_IOCTL_EXYNOS_GEM_CREATE • Only use user-desired size and buffer types. • Create gem object(global) & user gem handle(per process) • physical memory allocated. 2. DRM_IOCTL_EXYNOS_GEM_MMAP • Create user address space • Map the user address space to physical memory • LIBDRM of Exynos uses these APIs, not the generic.
  • 14. tizen.org14 Graphics: DRM/GEM Sharing • GEM Sharing @ Tizen • DRM_IOCTL_GEM_FLINK – “I will share this GEM to others.” – Create GEM object name for the given GEM handle • Global key vaue for sharing • DRM_IOCTL_GEM_OPEN – “I want to use the shared GEM.” – Create GEM handle based on the given GEM object name • DRM_IOCTL_GEM_CLOSE • You don’t need to implement. It’s already there with DRM. GEM Create GEM FLINK GEM OPEN gem handle gem object name gem handle Process 1 Process 2
  • 15. tizen.org15 Tizen Kernel MM, Multimedia (V4L2/VB2) Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF
  • 16. tizen.org16 Multimedia: V4L2/VB2 • Tizen recommends to use V4L2 at Tizen kernel for Multimedia devices • Video input (codec & camera) & Radio • However, as long as the kernel has: – Gstreamer/OpenMAX plugins – A method to share with other F/W via DMABUF of UMM, • Tizen multimedia works. • If V4L2/VB2 is used, things get easier.
  • 17. tizen.org17 Tizen Kernel MM, OpenGL/G3D-GPU Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF
  • 18. tizen.org18 OpenGL / G3D-GPU • Most ARM SoC GPUs (MALI, SGX, …) use their own memory manager • E.g., Exynos4412/4210 Tizen Reference Kernel has Mali w/ UMP. – Mali DDK modified to be compatible with UMM-DMABUF. • If GPU drivers use DRM, it would be great. • (and make them GPL)
  • 19. tizen.org19 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel – To Run Tizen OS. • Basic Memory Management Components • Buffer Sharing (UMM/DMABUF) • Buffer Allocation (UMM/DMAAPI) • Buffer Synchronization • Memory Size Optimization
  • 20. tizen.org20 NEED FOR SOMETHING, A Scenario Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc Camera fetches a video stream This scenario is simplified for presentation. Not an actual example of Tizen
  • 21. tizen.org21 NEED FOR SOMETHING, A Scenario Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc Camera fetches a video stream Draws its own images This scenario is simplified for presentation. Not an actual example of Tizen
  • 22. tizen.org22 NEED FOR SOMETHING, A Scenario Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc Camera fetches a video stream Draws its own images GPU Merges the two / Puts the merged image This scenario is simplified for presentation. Not an actual example of Tizen
  • 23. tizen.org23 NEED FOR SOMETHING, A Scenario Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc Camera fetches a video stream Draws its own images DRM-FIMD(display) Output This scenario is simplified for presentation. Not an actual example of Tizen GPU Merges the two / Puts the merged image
  • 24. tizen.org24 NEED FOR SOMETHING, A Scenario Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc Camera fetches a video stream Draws its own images DRM-FIMD(display) Output At a VB2 buffer At a GEM buffer GEM buffer This scenario is simplified for presentation. Not an actual example of Tizen GPU Merges the two / Puts the merged image From GEM + VB2 into its own (e.g., UMP)
  • 25. tizen.org25 Tizen Kernel MM, UMM Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF A mechanism to share between DRM, V4L2, and others w/o memcpy
  • 26. tizen.org26 Tizen Kernel MM, UMM Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF Requirement from Tizen platform and hardware • Different Memory Managers: GEM, VB2, GPU-adhoc, … • Share buffers • w/o memcpy • From and to users • Never expose directly to users (e.g., physical address)  UMM DMABUF!
  • 27. tizen.org27 Tizen Kernel Memory Management Unified Memory Management (UMM) • Introduced by Jesse Barker, 2011 • Includes – DMABUF (sharing buffer) – DMA Mapping API for Allocation. – CMA (Contiguous Memory Allocator) IOMMU (MMU for I/O devs)
  • 28. tizen.org28 Tizen Kernel MM, UMM DMA Buffer Sharing: DMABUF • Export – GEM/VB2/… object  DMABUF • Import – DMABUF  GEM/VB2/… object • Userspace sees DMABUF as a File Descriptor
  • 29. tizen.org29 DMA Buffer Sharing: DMABUF, Example Camera  Display X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 30. tizen.org30 DMA Buffer Sharing: DMABUF, Example Conceptual Data Flow X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 31. tizen.org31 DMABUF Usage Example 1/4 Camera App 1) Request V4L2 camera buffer (U) 2) Allocate CMA buffer (K) 3) Request a camera frame at the V4L2 buffer (U) 4) Store the camera frame & Notify user (K) 5) Request DMABUF export for the V4L2 camera buffer (U) 6) dma_buf_exporter() (K) - Create DMABUF from V4L2 buffer 7) dma_buf_fd() (K) - Provide FD of the DMABUF to user X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 32. tizen.org32 DMABUF Usage Example 1/4 Camera App 1) Request V4L2 camera buffer (U) 2) Allocate CMA buffer (K) 3) Request a camera frame at the V4L2 buffer (U) 4) Store the camera frame & Notify user (K) 5) Request DMABUF export for the V4L2 camera buffer (U) 6) dma_buf_exporter() (K) - Create DMABUF from V4L2 buffer 7) dma_buf_fd() (K) - Provide FD of the DMABUF to user X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 33. tizen.org33 DMABUF Usage Example 1/4 Camera App 1) Request V4L2 camera buffer (U) 2) Allocate CMA buffer (K) 3) Request a camera frame at the V4L2 buffer (U) 4) Store the camera frame & Notify user (K) 5) Request DMABUF export for the V4L2 camera buffer (U) 6) dma_buf_exporter() (K) - Create DMABUF from V4L2 buffer 7) dma_buf_fd() (K) - Provide FD of the DMABUF to user X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 34. tizen.org34 DMABUF Usage Example 2/4 Camera App 8) Request FD->GEM conversion (U) 9) dma_buf_get(fd) (K) - Get DMABUF from FD 10)dma_buf_attach(dma-buf) / dma_buf_map_attachment() (K) - Get Buffer from DMABUF 11) Import as GEM, send user (K) 12) Request GEM object name (U) 13) Return GEM object name (K) 14) Send GEM object name to X (U) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 35. tizen.org35 DMABUF Usage Example 2/4 Camera App 8) Request FD->GEM conversion (U) 9) dma_buf_get(fd) (K) - Get DMABUF from FD 10) dma_buf_attach(dma-buf) / dma_buf_map_attachment() (K) - Get Buffer from DMABUF 11) Import as GEM, send user (K) 12) Request GEM object name (U) 13) Return GEM object name (K) 14) Send GEM object name to X (U) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 36. tizen.org36 DMABUF Usage Example 3/4 X server 15) Convert given GEM object name to GEM. Display its content. (U & K) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 37. tizen.org37 DMABUF Usage Example 3/4 X server 15) Convert given GEM object name to GEM. Display its content. (U & K) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 38. tizen.org38 DMABUF Usage Example 4/4 Close after usage 1) “Free” the GEM object (U) 2) Remove reference from the DMABUF (K) 3) Close(DMABUF-FD) at cam app (U) 4) (No more reference to DMABUF) Release callback executed (K) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 39. tizen.org39 DMABUF Usage Example 4/4 Close after usage 1) “Free” the GEM object (U) 2) Remove reference from the DMABUF 3) Close(DMABUF-FD) at cam app (U) 4) (No more reference to DMABUF) Release callback executed (K) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 40. tizen.org40 DMABUF Usage Example 4/4 Close after usage 1) “Free” the GEM object (U) 2) Remove reference from the DMABUF 3) Close(DMABUF-FD) at cam app (U) 4) (No more reference to DMABUF) Release callback executed (K) X server Video encoder Xvsink Camera src User space Kernel space DRM KMS GEM Codec CameraV4L2 V4L2 struct dma_buf Display Codec Camera Memory Camera App FD HW
  • 41. tizen.org41 Sorry, Back to DRM/GEM… • DMABUF Import / Export needs to be added • DRM_IOCTL_PRIME_HANDLE_TO_FD • Export gem handle into dmabuf fd • DRM_IOCTL_PRIME_FD_TO_HANDLE • Import dmabuf fd into gem handle
  • 42. tizen.org42 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel – To Run Tizen OS. • Basic Memory Management Components • Buffer Sharing (UMM/DMABUF) • Buffer Allocation (UMM/DMAAPI) • Buffer Synchronization • Memory Size Optimization
  • 43. tizen.org43 Tizen Kernel Memory Management Unified Memory Management (UMM) • Introduced by Jesse Barker, 2011 • Includes – DMABUF (sharing buffer) – DMA Mapping API for Allocation. – CMA (Contiguous Memory Allocator) IOMMU (MMU for I/O devs)
  • 44. tizen.org44 Tizen Kernel MM, UMM DMA Mapping API @ Tizen Reference DRM / GEM DMA Mapping Framework IOMMUBuddyCMA IOMMU Common Driver System Memory V4L2 / VB2 1 2 1: “Exynos-DRM” provides unified device address space for all DRM devices 2: Each V4L2 device has its own device address space 2 2
  • 45. tizen.org45 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel – To Run Tizen OS. • Basic Memory Management Components • Buffer Sharing (UMM/DMABUF) • Buffer Allocation (UMM/DMAAPI) • Buffer Synchronization • Memory Size Optimization
  • 46. tizen.org46 Tizen Kernel Memory Management We Still Have A HUGE Problem!
  • 47. tizen.org47 Tizen Kernel MM, Buffer Sync. Kernel / Device Drivers (BSP) Kernel / Core & Subsystem X Server DRM Framework GEM Display HDMI Virtual Display Post Processor G2D EFL Evas 2D GPU backend X Video Drivers Userptr NEON 2D GPU backend PIXMAN EXA V4L2 VB2 Codec Camera GStreamer OpenMAX Libdrm XV Extension UMM Open GL Multimedia FW XvImageSink Core External Library Core Framework OEM Adaptation Kernel Kernel GPU DDK (G3D) Radio * Images from MS Office clipart and Samsung Gstreamer- CameraSrc DMABUF Synchronization?
  • 48. tizen.org48 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU GPU Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1
  • 49. tizen.org49 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU GPU Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1
  • 50. tizen.org50 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU GPU Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1
  • 51. tizen.org51 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU GPU Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1
  • 52. tizen.org52 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU GPU Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1
  • 53. tizen.org53 Tizen Kernel MM, Buffer Sync. What’s the problem? Simple Usage Scenario 1. CPU writes to buffer1. 2. CPU tells GPU to do something on buffer1. 3. GPU does something on buffer1. 4. GPU finishes. 5. CPU reads the buffer1 How to ensure CPU won’t use buffer 1 until step 4? (esp., a user process)
  • 54. tizen.org54 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU, Thread1 GPU • What if there are two threads using GPU? – And if the two look at the same buffer? • Not even aware of it? CPU, Thread2
  • 55. tizen.org55 Tizen Kernel MM, Buffer Sync. What’s the problem? BUS DRAMDRAMDRAM CPU, Thread1 GPU • What if the two DMA devices (GPU, FIMC) share buffer? – But hard to know it at drivers or user threads. – FIMC never knows when GPU finishes – FIMC never knows when Threads1 stops using “buffer1” – Threads2 never know when GPU stops using “buffer1” CPU, Thread2 FIMC-IPP (Image Post Processing)
  • 56. tizen.org56 Tizen Kernel Memory Management Buffer Synchronization • TGL (Tizen Global Lock) @ Tizen 2.0 – … Let userspace handle the issue … – Kernel patch required. • Sync Framework (Google) – Jun, 2012. Resources w/o DMABUF (similar with TGL) • KDS (Kernel Dependency System, ARM) – May 2012 / DMABUF-compatible • DMA Fence Framework (Canonical/TI) – Aug 2012 / DMABUF-compatible – Work-In-Progress
  • 57. tizen.org57 Contents • Tizen Kernel Overview • Memory Management in Tizen Kernel • Memory Size Optimization – To Run w/ More Devices
  • 58. tizen.org58 Memory Size Optimization: Challenge • A device with 512MB RAM • Graphics/Multimedia devices want 400MB reserved – No IOMMU. • The userspace wants to run a web browser and HTML5 app! •REALLY POSSIBLE?
  • 59. tizen.org59 Memory Size Optimization: Challenge • A device with 512MB RAM • Graphics/Multimedia devices want 400MB reserved – No IOMMU • The userspace wants to run a web browser and HTML5 app! •REALLY POSSIBLE? •WHY NOT?
  • 60. tizen.org60 Minimize H/W Reserved Memory CMA (Contiguous Memory Allocator) • Camera wants to reserve 400MB. – No IOMMU: too primitive to use paging. • You don’t use cameras while web browsing. – Free the 400MB reserved to camera, let userspace use it. • CMA can do.
  • 61. tizen.org61 Minimize H/W Reserved Memory • (Obsolete/Low-cost) ARM SoC’s DMA devices – No IOMMU – Use physically continuous memory chunk. • No paging • Potentially, a lot of memory is wasted. BUS CPU MMU L2 Cache DRAM Controller DRAMDRAMDRAM CPUCPU GPU
  • 62. tizen.org62 Minimize H/W Reserved Memory IOMMU • (Modern/Mid-High-cost) ARM SoC’s DMA devices – IOMMU for DMA devices! – Use paging! • Dynamically allocate & free BUS CPU MMU L2 Cache DRAM Controller DRAMDRAMDRAM CPUCPU GPU IOMMU
  • 63. tizen.org63 Minimize H/W Reserved Memory IOMMU • Exynos4210/4412-based Tizen mobile device – Achieved near-zero reserved memory. – At the “menuscreen”, only around ~40MB allocated for display and GPU. – Unfortunately, not included in the Tizen reference kernel. • But easily supported by Vanilla kernel for Tizen reference boards
  • 64. tizen.org64 Minimize H/W Reserved Memory Results with 1GB RAM Device -sh-4.1# free total used free shared buffers cached Mem: 1029428 302020 727408 0 16164 133084 -/+ buffers/cache: 152772 876656 Swap: 0 0 0 -sh-4.1# uname -a Linux localhost 3.8.3-00841-gc1981b1 #34 SMP PREEMPT Wed Apr 10 10:24:04 KST 2013 armv7l GNU/Linux Mostly available to kernel (1005.3 of 1024MB) Even with Tizen loaded, mostly free to users (856MB of 1GB)
  • 65. tizen.org65 Memory Size Optimization: Still Hungry? • Further optimization required for low-budget devices – Running full features with 512MB? – Or even < 512MB? • What about multi-tasking or “background apps”?
  • 66. tizen.org66 Memory Size Optimization: SWAP • Swap – zRAM • Used in some Samsung mobile devices successfully – Or even swap-to-flash?
  • 67. tizen.org67 Memory Size Optimization: Multitasking / Background Apps • Limit multitasking & background-app support • Pseudo multitasking by freezing background apps