SlideShare a Scribd company logo
1 of 18
Download to read offline
John Stultz and Sumit Semwal, LCA14-509, Macau
ION: Next Steps
Background: What is ION
• Constraint aware* memory allocator
• Different devices have different constraints on
what memory they can access
• ION manages and provides a method of
allocating from different pools or types of
memory, which will then be shared with various
devices (via dma-bufs).
* “Aware” is maybe not quite accurate, but we’ll talk about that later
History
• Introduced into Android for ICS 3.0+ kernels
• 32bit ARM only
• Problematic DMA API usage
• Very hardware-specific interface and implementations
• Summarized these and other issues on LWN
• https://lwn.net/Articles/565469/
• Thanks to Jesse and Arnd for help identifying these
problems
• Synced with Android developers at Linux
Plumbers
• ION interface mostly used with graphics, which
tend to be proprietary
• No access to drivers for testing with latest
upstream kernels
• ARMv8 architecture models don’t even have gpu
hardware available.
• Upstream graphics developers not fond of ION or
Android’s approach to graphics
Difficulties
Since Linux Plumbers
• Colin Cross addressed most of the issues we
pointed out, via heavy refactoring of the code.
• Colin also provided unit tests, which I’ve ported to
non-android Linux environments
• Rom Lemarchand implemented compat_ioctl
support
• Developed a dummy driver to allow for testing on
systems that don’t have ION enabled graphics
• Worked with Colin to get the code tested and
stabilized.
• Pushed the entire ION patchset upstream via
staging (115+ patches).
Current Status
• ION builds and runs on ARM, x86_64, ARM64,
etc.
• Thanks to Jesse Barker for validating ARMv8!
• Compat ioctl support for 32bit applications
running on 64bit kernels
• Working on getting ion unit tests integrated into
lava.
Remaining issues
• ION still assumes phys addresses and bus
addresses are the same.
• This is ok on the hardware they care about so far.
• ION’s API requires userspace to manage the
device-constraint to memory type mapping
• Requires hardware specific gralloc userspace
• The types and subtleties of constraints is not
easily enumerable, as they may be different
device to device
• ION uses heap-ids to specify memory types, but heap-ids
are often device specific.
Interface examples
fd = open(“/dev/ion”, O_RDONLY);
struct ion_allocation_data data = {
.len = len,
.align = align,
.heap_id_mask = heap_mask,
.flags = flags,
};
ret = ioctl(fd, ION_IOC_ALLOC, &data);
Returns a buffer reference via: data.handle
Also:
ION_IOC_FREE: Free allocated buffer
ION_IOC_MAP: Generates an fd that can be mmaped
ION_IOC_SHARE: Generates a dma-buf fd that can be
shared
ION_IOC_IMPORT: Imports a dma-buf fd
ION_IOC_SYNC: Syncs the buffer to memory (deprecated)
ION_IOC_CUSTOM: Heap specific ioctl multiplexer (ugh)
• dmabuf usage model:
dma_buf_export()
...
dma_buf_get()
dma_buf_attach()
dma_buf_map_attachment()
dma_buf_unmap_attachment()
dma_buf_detach()
dma_buf_put()
• dmabuf exporter doesn’t necessarily allocate backing buffer
until map_attachment() time.
• When attaching, add device constraints to dmabuf, then
when allocating at map time, use those constraints to allocate
the right type of memory
What upstream developers want
• All devices have to have attached before the first
map.
• This can have permissions limitations, since process
starting things may not have permissions to access all the
devices that may eventually use the buffer
• dmabuf exporters are all driver specific
• Current dmabuf exporters don’t all use delayed (map
time) allocation.
• Android developers unlikely to move from ION
• Don’t require generic solution, ok with device specific
userland
• They like the directness of their approach
Issues with this approach
• Create a set of constraint aware dmabuf
allocation helper functions
• Try to share code with ION by reusing the heaps
• On dma_buf_attach(), store compatible heap
flags for that device in dma_buf
• Provide helper functions that will look at heap
flags on dmabuf and allocate memory from the
compatible ION heap
• Once we have common infrastructure, ION can
be reduced to just a shim interface that provides
the Android preferred semantics.
Plan
• Start looking at how to share the backing heap
allocators with the map-time post-attach
allocation that the dma-buf developers want to
see.
• Initially, we’ll do a PoC to prove ‘things work’
• Two steps: Sharing constraints, and using allocator
helpers for dma-bufs
Next steps
Next steps
• Sharing constraints
• add access_constraints_mask to dev->dma_parms of
importers
• values for the mask are deliberately kept ‘open’ to allow use-
case / platform-driven definition
• Then at each dma_buf_attach() call, check this mask for
attaching device and add to the global mask for the given
dma_buf
• error out if the new constraint causes the mask to become
zero => new device’s constraints won’t work with other
devices in the use case
• At each dma_buf_detach() call, re-calculate global mask for the
currently attached importers - this could help in backing storage
migration if so desired by exporter.
• Allocation helpers for dma-buf
• Central allocation helpers tied to dma-bufs - relevant only
when buffers are being shared around.
• Used by dma-buf exporters to provide map-time backing-
storage allocation for each dma-buf
• In the PoC, we intend to reuse the most common ION
heap functions for fixed ION constraint masks (heap
masks); later, the design would be updated to allow
adding custom allocation with function pointers and
platform-specific constraint masks
Next steps
• New functionality in the usage sequence:
dma_buf_get()
- importer to set constraints in dev->dma_parms-
>access_constraints_mask
dma_buf_attach()
- adds constraint to dma-buf; will return error if new
device attachment doesn’t satisfy existing constraints
dma_buf_map_attachment()
- exporter looks at constraint mask, and (optionally) uses
allocation helpers to allocate
dma_buf_unmap_attachment()
dma_buf_detach()
- re-calculates dma-buf’s constraint mask
dma_buf_put()
Next steps
• Dynamic handling of device specific heaps and dynamic
heap priority
• Per-platform allocation policy
• Separate from the constraint
• Allows for preferring some dimms over others, contig memory in
special regions (secure playback), etc.
• Likely per-platform and will need heap specific function pointer for
policy allocator.
• Generic userland api
• Current dma-buf exporters are via per-device/subsystem ioctls (like
drm/gem or v4l2).
• May be use for generic dma-buf exporter chardev?
• Not yet handling some of the caching optimizations ION
uses, nor performance issues connected with proper
dma-api usage w/ things like IOMMUs
Issues still to address
Links/Questions?
• Constraints / allocator helper PoC current code:
https://git.linaro.org/people/sumit.semwal/linux-3.x.git
• Areas of concern?
• Does the constraint and policy split make sense?
• Thoughts on enumeration theory?
• Other possible consumers other than graphics?
• Networking?
• eMMC / storage?
• other?
More about Linaro Connect: http://connect.linaro.org
More about Linaro: http://www.linaro.org/about/
More about Linaro engineering: http://www.linaro.org/engineering/
Linaro members: www.linaro.org/members

More Related Content

More from Linaro

It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...Linaro
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Linaro
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Linaro
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Linaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteLinaro
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopLinaro
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineLinaro
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allLinaro
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorLinaro
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMULinaro
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MLinaro
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation Linaro
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootLinaro
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...Linaro
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramLinaro
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNLinaro
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...Linaro
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...Linaro
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionLinaro
 

More from Linaro (20)

It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
It just keeps getting better - SUSE enablement for Arm - Linaro HPC Workshop ...
 
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
Intelligent Interconnect Architecture to Enable Next Generation HPC - Linaro ...
 
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
Yutaka Ishikawa - Post-K and Arm HPC Ecosystem - Linaro Arm HPC Workshop Sant...
 
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
Andrew J Younge - Vanguard Astra - Petascale Arm Platform for U.S. DOE/ASC Su...
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening KeynoteHKG18-100K1 - George Grey: Opening Keynote
HKG18-100K1 - George Grey: Opening Keynote
 
HKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP WorkshopHKG18-318 - OpenAMP Workshop
HKG18-318 - OpenAMP Workshop
 
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainlineHKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
HKG18-501 - EAS on Common Kernel 4.14 and getting (much) closer to mainline
 
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and allHKG18-315 - Why the ecosystem is a wonderful thing, warts and all
HKG18-315 - Why the ecosystem is a wonderful thing, warts and all
 
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse HypervisorHKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
HKG18- 115 - Partitioning ARM Systems with the Jailhouse Hypervisor
 
HKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMUHKG18-TR08 - Upstreaming SVE in QEMU
HKG18-TR08 - Upstreaming SVE in QEMU
 
HKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8MHKG18-113- Secure Data Path work with i.MX8M
HKG18-113- Secure Data Path work with i.MX8M
 
HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation HKG18-120 - Devicetree Schema Documentation and Validation
HKG18-120 - Devicetree Schema Documentation and Validation
 
HKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted bootHKG18-223 - Trusted FirmwareM: Trusted boot
HKG18-223 - Trusted FirmwareM: Trusted boot
 
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
HKG18-500K1 - Keynote: Dileep Bhandarkar - Emerging Computing Trends in the D...
 
HKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready ProgramHKG18-317 - Arm Server Ready Program
HKG18-317 - Arm Server Ready Program
 
HKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NNHKG18-312 - CMSIS-NN
HKG18-312 - CMSIS-NN
 
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
HKG18-301 - Dramatically Accelerate 96Board Software via an FPGA with Integra...
 
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
HKG18-300K2 - Keynote: Tomas Evensen - All Programmable SoCs? – Platforms to ...
 
HKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: IntroductionHKG18-212 - Trusted Firmware M: Introduction
HKG18-212 - Trusted Firmware M: Introduction
 

Recently uploaded

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

LCA14: LCA14-509: ION upstreaming status & next steps

  • 1. John Stultz and Sumit Semwal, LCA14-509, Macau ION: Next Steps
  • 2. Background: What is ION • Constraint aware* memory allocator • Different devices have different constraints on what memory they can access • ION manages and provides a method of allocating from different pools or types of memory, which will then be shared with various devices (via dma-bufs). * “Aware” is maybe not quite accurate, but we’ll talk about that later
  • 3. History • Introduced into Android for ICS 3.0+ kernels • 32bit ARM only • Problematic DMA API usage • Very hardware-specific interface and implementations • Summarized these and other issues on LWN • https://lwn.net/Articles/565469/ • Thanks to Jesse and Arnd for help identifying these problems • Synced with Android developers at Linux Plumbers
  • 4. • ION interface mostly used with graphics, which tend to be proprietary • No access to drivers for testing with latest upstream kernels • ARMv8 architecture models don’t even have gpu hardware available. • Upstream graphics developers not fond of ION or Android’s approach to graphics Difficulties
  • 5. Since Linux Plumbers • Colin Cross addressed most of the issues we pointed out, via heavy refactoring of the code. • Colin also provided unit tests, which I’ve ported to non-android Linux environments • Rom Lemarchand implemented compat_ioctl support • Developed a dummy driver to allow for testing on systems that don’t have ION enabled graphics • Worked with Colin to get the code tested and stabilized. • Pushed the entire ION patchset upstream via staging (115+ patches).
  • 6. Current Status • ION builds and runs on ARM, x86_64, ARM64, etc. • Thanks to Jesse Barker for validating ARMv8! • Compat ioctl support for 32bit applications running on 64bit kernels • Working on getting ion unit tests integrated into lava.
  • 7. Remaining issues • ION still assumes phys addresses and bus addresses are the same. • This is ok on the hardware they care about so far. • ION’s API requires userspace to manage the device-constraint to memory type mapping • Requires hardware specific gralloc userspace • The types and subtleties of constraints is not easily enumerable, as they may be different device to device • ION uses heap-ids to specify memory types, but heap-ids are often device specific.
  • 8. Interface examples fd = open(“/dev/ion”, O_RDONLY); struct ion_allocation_data data = { .len = len, .align = align, .heap_id_mask = heap_mask, .flags = flags, }; ret = ioctl(fd, ION_IOC_ALLOC, &data); Returns a buffer reference via: data.handle Also: ION_IOC_FREE: Free allocated buffer ION_IOC_MAP: Generates an fd that can be mmaped ION_IOC_SHARE: Generates a dma-buf fd that can be shared ION_IOC_IMPORT: Imports a dma-buf fd ION_IOC_SYNC: Syncs the buffer to memory (deprecated) ION_IOC_CUSTOM: Heap specific ioctl multiplexer (ugh)
  • 9. • dmabuf usage model: dma_buf_export() ... dma_buf_get() dma_buf_attach() dma_buf_map_attachment() dma_buf_unmap_attachment() dma_buf_detach() dma_buf_put() • dmabuf exporter doesn’t necessarily allocate backing buffer until map_attachment() time. • When attaching, add device constraints to dmabuf, then when allocating at map time, use those constraints to allocate the right type of memory What upstream developers want
  • 10. • All devices have to have attached before the first map. • This can have permissions limitations, since process starting things may not have permissions to access all the devices that may eventually use the buffer • dmabuf exporters are all driver specific • Current dmabuf exporters don’t all use delayed (map time) allocation. • Android developers unlikely to move from ION • Don’t require generic solution, ok with device specific userland • They like the directness of their approach Issues with this approach
  • 11. • Create a set of constraint aware dmabuf allocation helper functions • Try to share code with ION by reusing the heaps • On dma_buf_attach(), store compatible heap flags for that device in dma_buf • Provide helper functions that will look at heap flags on dmabuf and allocate memory from the compatible ION heap • Once we have common infrastructure, ION can be reduced to just a shim interface that provides the Android preferred semantics. Plan
  • 12. • Start looking at how to share the backing heap allocators with the map-time post-attach allocation that the dma-buf developers want to see. • Initially, we’ll do a PoC to prove ‘things work’ • Two steps: Sharing constraints, and using allocator helpers for dma-bufs Next steps
  • 13. Next steps • Sharing constraints • add access_constraints_mask to dev->dma_parms of importers • values for the mask are deliberately kept ‘open’ to allow use- case / platform-driven definition • Then at each dma_buf_attach() call, check this mask for attaching device and add to the global mask for the given dma_buf • error out if the new constraint causes the mask to become zero => new device’s constraints won’t work with other devices in the use case • At each dma_buf_detach() call, re-calculate global mask for the currently attached importers - this could help in backing storage migration if so desired by exporter.
  • 14. • Allocation helpers for dma-buf • Central allocation helpers tied to dma-bufs - relevant only when buffers are being shared around. • Used by dma-buf exporters to provide map-time backing- storage allocation for each dma-buf • In the PoC, we intend to reuse the most common ION heap functions for fixed ION constraint masks (heap masks); later, the design would be updated to allow adding custom allocation with function pointers and platform-specific constraint masks Next steps
  • 15. • New functionality in the usage sequence: dma_buf_get() - importer to set constraints in dev->dma_parms- >access_constraints_mask dma_buf_attach() - adds constraint to dma-buf; will return error if new device attachment doesn’t satisfy existing constraints dma_buf_map_attachment() - exporter looks at constraint mask, and (optionally) uses allocation helpers to allocate dma_buf_unmap_attachment() dma_buf_detach() - re-calculates dma-buf’s constraint mask dma_buf_put() Next steps
  • 16. • Dynamic handling of device specific heaps and dynamic heap priority • Per-platform allocation policy • Separate from the constraint • Allows for preferring some dimms over others, contig memory in special regions (secure playback), etc. • Likely per-platform and will need heap specific function pointer for policy allocator. • Generic userland api • Current dma-buf exporters are via per-device/subsystem ioctls (like drm/gem or v4l2). • May be use for generic dma-buf exporter chardev? • Not yet handling some of the caching optimizations ION uses, nor performance issues connected with proper dma-api usage w/ things like IOMMUs Issues still to address
  • 17. Links/Questions? • Constraints / allocator helper PoC current code: https://git.linaro.org/people/sumit.semwal/linux-3.x.git • Areas of concern? • Does the constraint and policy split make sense? • Thoughts on enumeration theory? • Other possible consumers other than graphics? • Networking? • eMMC / storage? • other?
  • 18. More about Linaro Connect: http://connect.linaro.org More about Linaro: http://www.linaro.org/about/ More about Linaro engineering: http://www.linaro.org/engineering/ Linaro members: www.linaro.org/members