Nicolas Boichat
6d6ea1e967
mm: add support for kmem caches in DMA32 zone
...
Patch series "iommu/io-pgtable-arm-v7s: Use DMA32 zone for page tables",
v6.
This is a followup to the discussion in [1], [2].
IOMMUs using ARMv7 short-descriptor format require page tables (level 1
and 2) to be allocated within the first 4GB of RAM, even on 64-bit
systems.
For L1 tables that are bigger than a page, we can just use
__get_free_pages with GFP_DMA32 (on arm64 systems only, arm would still
use GFP_DMA).
For L2 tables that only take 1KB, it would be a waste to allocate a full
page, so we considered 3 approaches:
1. This series, adding support for GFP_DMA32 slab caches.
2. genalloc, which requires pre-allocating the maximum number of L2 page
tables (4096, so 4MB of memory).
3. page_frag, which is not very memory-efficient as it is unable to reuse
freed fragments until the whole page is freed. [3]
This series is the most memory-efficient approach.
stable@ note:
We confirmed that this is a regression, and IOMMU errors happen on 4.19
and linux-next/master on MT8173 (elm, Acer Chromebook R13). The issue
most likely starts from commit ad67f5a654
("arm64: replace ZONE_DMA
with ZONE_DMA32"), i.e. 4.15, and presumably breaks a number of Mediatek
platforms (and maybe others?).
[1] https://lists.linuxfoundation.org/pipermail/iommu/2018-November/030876.html
[2] https://lists.linuxfoundation.org/pipermail/iommu/2018-December/031696.html
[3] https://patchwork.codeaurora.org/patch/671639/
This patch (of 3):
IOMMUs using ARMv7 short-descriptor format require page tables to be
allocated within the first 4GB of RAM, even on 64-bit systems. On arm64,
this is done by passing GFP_DMA32 flag to memory allocation functions.
For IOMMU L2 tables that only take 1KB, it would be a waste to allocate
a full page using get_free_pages, so we considered 3 approaches:
1. This patch, adding support for GFP_DMA32 slab caches.
2. genalloc, which requires pre-allocating the maximum number of L2
page tables (4096, so 4MB of memory).
3. page_frag, which is not very memory-efficient as it is unable
to reuse freed fragments until the whole page is freed.
This change makes it possible to create a custom cache in DMA32 zone using
kmem_cache_create, then allocate memory using kmem_cache_alloc.
We do not create a DMA32 kmalloc cache array, as there are currently no
users of kmalloc(..., GFP_DMA32). These calls will continue to trigger a
warning, as we keep GFP_DMA32 in GFP_SLAB_BUG_MASK.
This implies that calls to kmem_cache_*alloc on a SLAB_CACHE_DMA32
kmem_cache must _not_ use GFP_DMA32 (it is anyway redundant and
unnecessary).
Link: http://lkml.kernel.org/r/20181210011504.122604-2-drinkcat@chromium.org
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org >
Acked-by: Vlastimil Babka <vbabka@suse.cz >
Acked-by: Will Deacon <will.deacon@arm.com >
Cc: Robin Murphy <robin.murphy@arm.com >
Cc: Joerg Roedel <joro@8bytes.org >
Cc: Christoph Lameter <cl@linux.com >
Cc: Pekka Enberg <penberg@kernel.org >
Cc: David Rientjes <rientjes@google.com >
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com >
Cc: Michal Hocko <mhocko@suse.com >
Cc: Mel Gorman <mgorman@techsingularity.net >
Cc: Sasha Levin <Alexander.Levin@microsoft.com >
Cc: Huaisheng Ye <yehs1@lenovo.com >
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com >
Cc: Yong Wu <yong.wu@mediatek.com >
Cc: Matthias Brugger <matthias.bgg@gmail.com >
Cc: Tomasz Figa <tfiga@google.com >
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com >
Cc: Christoph Hellwig <hch@infradead.org >
Cc: Matthew Wilcox <willy@infradead.org >
Cc: Hsin-Yi Wang <hsinyi@chromium.org >
Cc: <stable@vger.kernel.org >
Signed-off-by: Andrew Morton <akpm@linux-foundation.org >
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org >
2019-03-29 10:01:37 -07:00
..
2019-02-26 11:23:49 +00:00
2018-11-14 10:56:33 -08:00
2019-02-06 09:36:36 -08:00
2018-11-09 17:33:32 +01:00
2019-03-20 16:27:40 +01:00
2019-02-15 16:47:55 +02:00
2019-01-07 17:57:13 +05:30
2019-02-15 17:17:57 +01:00
2019-03-06 09:41:12 -08:00
2019-02-14 08:45:22 +01:00
2018-11-12 10:33:49 +01:00
2019-02-02 09:28:51 +00:00
2019-02-06 22:17:42 -08:00
2019-03-21 12:30:54 +01:00
2019-03-06 20:34:20 -06:00
2019-03-08 10:02:58 -08:00
2018-11-22 11:38:36 -08:00
2019-03-17 21:40:39 -03:00
2019-02-28 09:16:12 +01:00
2019-02-25 09:28:54 +01:00
2019-03-01 14:28:43 +01:00
2018-11-21 13:16:33 +00:00
2019-02-07 11:11:05 +05:30
2019-01-28 14:39:52 +01:00
2019-03-14 09:11:54 -07:00
2019-01-20 21:57:43 +01:00
2019-02-08 22:39:01 -08:00
2018-12-20 08:53:23 -08:00
2019-03-03 23:45:27 +00:00
2019-01-28 11:16:04 +01:00
2019-03-08 14:48:40 -08:00
2019-02-12 15:27:14 -06:00
2019-01-30 23:02:10 +00:00
2019-03-10 14:08:19 -04:00
2019-03-01 20:53:41 +01:00
2019-03-16 13:05:32 -07:00
2018-11-07 22:58:29 +01:00
2018-12-17 08:26:24 +01:00
2019-02-11 11:07:49 +01:00
2019-01-31 14:20:54 +01:00
2019-02-08 06:42:53 -07:00
2019-03-15 11:25:48 -07:00
2019-02-13 08:07:31 +01:00
2018-11-01 11:00:46 +01:00
2019-02-07 21:44:27 -05:00
2019-01-22 14:39:38 -07:00
2019-03-05 21:07:21 -08:00
2019-03-05 21:07:14 -08:00
2019-01-05 13:18:59 -08:00
2019-02-24 08:20:17 -07:00
2018-10-31 08:54:12 -07:00
2019-03-07 18:32:00 -08:00
2019-03-18 10:44:48 -06:00
2018-12-21 08:47:05 -07:00
2018-11-07 13:44:59 -07:00
2018-12-13 09:59:08 +01:00
2018-11-07 13:44:59 -07:00
2019-03-20 14:19:36 -06:00
2019-03-20 14:02:07 -06:00
2019-02-07 12:57:17 -07:00
2019-01-31 10:13:21 +01:00
2019-03-13 12:04:35 -07:00
2019-03-08 21:17:07 +01:00
2019-03-13 12:04:35 -07:00
2019-01-11 18:05:41 -08:00
2019-03-26 11:24:47 -07:00
2019-02-05 21:27:40 -05:00
2019-02-01 20:55:38 +01:00
2019-03-07 18:31:59 -08:00
2019-02-28 13:49:22 -07:00
2019-03-07 12:20:11 -08:00
2019-01-18 13:43:10 -07:00
2019-03-07 10:11:41 -08:00
2019-01-31 06:55:57 -08:00
2019-02-22 00:11:47 -08:00
2019-02-06 10:33:10 -08:00
2019-02-06 10:35:02 -08:00
2018-10-25 11:14:36 -07:00
2019-03-05 21:07:20 -08:00
2019-02-07 00:13:27 +01:00
2019-02-15 19:52:17 +01:00
2018-12-14 16:57:16 +01:00
2019-01-09 11:36:41 +01:00
2019-01-21 07:23:42 +13:00
2019-01-09 11:36:41 +01:00
2019-01-09 11:36:41 +01:00
2019-02-19 13:20:35 +01:00
2019-01-18 13:52:41 +01:00
2018-11-29 17:30:48 +02:00
2019-02-08 12:27:36 +01:00
2019-01-30 19:27:00 +01:00
2019-02-12 23:47:42 +01:00
2019-02-23 12:13:45 +01:00
2019-01-17 22:16:13 +01:00
2019-01-08 13:18:44 -08:00
2019-01-25 18:41:52 +08:00
2019-01-10 13:58:00 +05:30
2018-12-04 21:32:00 -08:00
2019-01-30 11:02:11 -08:00
2019-03-07 18:32:01 -08:00
2018-10-26 16:26:32 -07:00
2018-12-11 11:40:13 +09:00
2019-03-05 14:53:50 -05:00
2019-03-10 11:54:48 -07:00
2019-01-04 09:02:17 +01:00
2018-12-13 21:06:18 +01:00
2019-01-17 10:12:32 +01:00
2018-12-07 12:44:16 +01:00
2018-12-06 06:56:48 -08:00
2019-03-10 12:47:57 -07:00
2018-12-13 21:06:18 +01:00
2018-12-05 12:01:55 +03:00
2018-12-20 09:51:31 -07:00
2019-03-07 18:32:00 -08:00
2018-11-13 21:55:24 +01:00
2019-03-10 10:17:23 -07:00
2018-11-07 13:42:32 -07:00
2018-12-11 15:16:58 +01:00
2019-02-28 03:28:53 -05:00
2019-02-22 12:55:31 -08:00
2019-02-24 17:33:59 -08:00
2018-12-01 23:13:14 +09:00
2019-03-12 18:59:17 -07:00
2019-02-07 16:47:32 +01:00
2019-01-16 17:42:35 +01:00
2019-02-19 10:10:05 +01:00
2018-12-19 09:40:13 +01:00
2019-02-28 08:24:23 -07:00
2019-03-06 07:59:36 -08:00
2018-12-19 10:42:08 +01:00
2019-03-05 21:07:18 -08:00
2019-02-28 03:29:37 -05:00
2019-02-28 03:28:53 -05:00
2019-01-21 17:48:13 +01:00
2019-03-12 14:08:19 -07:00
2018-11-28 13:19:20 +00:00
2019-01-23 23:56:43 -05:00
2018-12-02 16:25:28 -08:00
2019-01-18 10:02:09 +01:00
2019-02-18 12:41:16 +01:00
2019-02-07 16:38:36 +01:00
2018-12-31 11:46:59 -08:00
2018-12-07 22:19:07 +01:00
2019-01-04 13:13:46 -08:00
2019-03-12 10:04:02 -07:00
2018-12-10 08:30:38 -07:00
2018-12-20 09:51:31 -07:00
2019-03-05 21:07:16 -08:00
2019-02-15 16:54:38 +01:00
2019-02-06 10:05:16 +00:00
2019-01-25 19:35:20 +02:00
2019-01-29 12:09:11 +01:00
2018-11-16 11:42:12 +00:00
2019-01-16 14:29:48 +01:00
2018-12-28 12:11:47 -08:00
2019-03-12 10:04:00 -07:00
2018-11-23 11:51:21 +01:00
2018-12-28 12:11:50 -08:00
2019-03-05 21:07:19 -08:00
2018-12-16 15:13:22 -08:00
2019-02-14 20:56:10 -05:00
2019-02-05 14:05:03 +01:00
2019-02-24 14:43:22 +01:00
2018-11-04 11:04:46 +01:00
2019-01-31 08:25:09 -07:00
2018-10-21 10:46:33 -04:00
2019-02-22 12:56:24 -08:00
2019-01-24 22:45:34 -08:00
2018-12-07 12:59:08 -08:00
2018-11-21 15:41:30 -08:00
2019-03-09 19:52:47 -08:00
2019-01-22 10:23:17 +01:00
2019-02-04 17:36:01 -05:00
2019-01-22 17:18:09 -08:00
2018-12-17 09:19:49 -08:00
2018-10-29 20:26:06 -07:00
2019-02-04 08:53:56 +01:00
2018-11-07 13:42:32 -07:00
2019-01-14 11:42:18 +01:00
2019-01-11 13:10:03 +01:00
2019-01-11 13:10:03 +01:00
2019-01-22 13:37:25 +01:00
2019-01-22 13:37:25 +01:00
2019-02-23 10:53:31 +01:00
2019-01-22 13:39:59 +01:00
2019-01-22 13:39:59 +01:00
2019-02-11 11:26:48 +01:00
2019-02-24 08:20:17 -07:00
2019-03-01 11:24:51 +01:00
2018-11-19 19:03:46 -07:00
2019-01-22 17:18:08 -08:00
2019-02-09 19:48:42 -06:00
2019-03-03 21:05:10 -08:00
2018-12-13 09:35:31 +00:00
2019-03-21 11:52:37 +01:00
2018-12-18 14:22:28 +01:00
2019-02-23 10:53:31 +01:00
2019-03-08 10:09:53 -08:00
2018-12-04 00:30:22 -05:00
2019-01-06 09:46:51 +09:00
2019-01-06 09:46:51 +09:00
2019-03-05 21:07:13 -08:00
2018-12-28 12:11:44 -08:00
2019-03-23 12:11:49 +01:00
2019-03-04 13:42:05 +01:00
2019-03-07 18:31:59 -08:00
2019-03-12 14:08:19 -07:00
2018-12-26 17:03:51 -08:00
2019-02-15 14:12:09 -08:00
2018-12-13 17:54:12 -08:00
2018-10-26 09:30:46 +01:00
2018-12-30 08:33:06 +00:00
2019-01-30 11:52:21 +01:00
2018-12-06 13:57:03 +01:00
2019-03-05 21:07:15 -08:00
2019-03-06 08:14:05 -08:00
2019-02-20 22:48:50 +01:00
2018-11-22 09:03:17 +01:00
2019-01-16 22:08:07 +01:00
2019-02-08 17:33:00 -05:00
2019-03-16 13:05:32 -07:00
2018-12-11 12:22:35 -07:00
2019-03-07 18:31:59 -08:00
2018-11-30 13:29:04 +00:00
2018-12-05 16:26:16 -08:00
2019-03-05 21:07:16 -08:00
2019-01-11 20:51:24 +01:00
2019-02-28 07:55:53 +01:00
2019-03-12 14:08:19 -07:00
2019-03-07 18:32:03 -08:00
2018-12-21 22:31:26 -06:00
2018-12-21 22:31:26 -06:00
2019-02-24 17:45:25 -08:00
2018-10-26 16:25:19 -07:00
2019-02-05 11:51:56 -07:00
2019-02-18 16:43:54 -08:00
2019-02-12 10:38:46 +01:00
2019-03-12 10:04:02 -07:00
2019-03-05 21:07:17 -08:00
2019-03-11 17:08:14 -07:00
2018-12-05 15:45:54 -08:00
2018-12-28 12:11:52 -08:00
2018-12-28 12:11:51 -08:00
2018-12-05 16:26:16 -08:00
2019-01-04 13:13:48 -08:00
2019-03-09 15:53:03 -08:00
2019-03-12 10:04:01 -07:00
2018-12-28 12:11:50 -08:00
2019-03-05 21:07:21 -08:00
2019-03-10 13:16:37 -07:00
2019-03-09 09:56:17 -08:00
2019-01-30 17:44:24 -05:00
2019-02-08 13:30:10 -06:00
2019-01-30 20:51:47 -05:00
2018-11-22 11:36:54 -08:00
2019-03-15 15:29:47 -07:00
2019-02-16 13:45:01 -08:00
2019-03-02 12:54:35 -08:00
2018-12-19 11:21:37 -08:00
2019-01-06 09:46:51 +09:00
2019-01-28 11:32:58 +01:00
2019-02-04 18:21:12 +01:00
2019-01-06 09:46:51 +09:00
2019-01-19 10:09:58 -08:00
2019-03-01 16:20:16 -05:00
2019-03-01 16:20:16 -05:00
2018-12-19 13:52:46 -05:00
2019-02-20 15:14:20 -05:00
2019-03-01 16:20:16 -05:00
2018-11-06 21:58:00 +01:00
2019-03-05 21:07:20 -08:00
2018-11-03 10:09:37 -07:00
2019-02-13 11:03:18 -05:00
2019-02-20 07:22:17 -07:00
2019-02-20 07:22:17 -07:00
2019-02-20 07:22:19 -07:00
2019-02-20 07:22:10 -07:00
2019-02-20 07:22:05 -07:00
2018-12-06 15:45:46 +01:00
2019-01-22 10:21:45 +01:00
2019-02-08 15:02:49 -08:00
2018-11-23 07:59:59 +01:00
2019-02-13 09:10:14 +01:00
2018-12-03 15:40:30 -08:00
2018-11-09 15:40:53 -06:00
2019-02-28 11:40:49 -06:00
2019-01-10 16:24:44 -06:00
2018-12-28 12:11:48 -08:00
2018-12-28 12:11:44 -08:00
2019-03-05 21:07:19 -08:00
2019-03-29 10:01:37 -07:00
2018-12-28 12:11:51 -08:00
2019-03-15 11:21:25 -07:00
2018-10-21 10:46:39 -04:00
2019-03-25 14:49:00 -07:00
2019-02-01 17:24:52 -06:00
2019-02-28 11:09:29 +01:00
2019-01-08 07:58:37 -05:00
2019-02-15 10:03:35 +00:00
2019-03-10 12:29:52 -07:00
2018-12-06 14:38:53 +00:00
2018-10-31 08:54:14 -07:00
2019-02-28 07:55:37 +01:00
2019-02-28 08:29:50 +01:00
2018-10-26 16:26:35 -07:00
2019-02-07 18:11:58 -08:00
2018-11-09 20:13:51 -08:00
2019-03-03 21:47:57 -08:00
2019-02-24 12:39:45 -08:00
2019-03-07 18:31:59 -08:00
2019-02-01 02:01:45 -05:00
2018-12-13 16:07:04 +01:00
2019-03-08 10:09:53 -08:00
2019-02-15 11:36:38 +01:00
2019-03-06 12:59:46 -08:00
2019-02-20 11:18:07 +01:00
2019-03-12 09:43:00 +01:00
2019-03-07 11:23:17 +01:00
2019-03-12 10:04:03 -07:00
2019-02-07 00:13:27 +01:00
2019-01-15 16:36:13 +01:00
2019-02-20 00:33:08 +01:00
2018-12-07 12:35:46 +00:00
2019-03-09 09:22:42 -08:00
2019-03-05 17:03:53 +01:00
2019-01-29 10:52:40 +01:00
2018-10-26 16:26:32 -07:00
2018-11-30 14:56:14 -08:00
2018-12-03 16:52:35 -08:00
2018-12-03 17:11:02 -08:00
2018-11-09 19:43:51 -08:00
2019-02-17 15:53:01 -08:00
2018-12-03 10:47:53 +01:00
2019-01-10 09:35:00 +01:00
2019-01-10 17:04:45 -06:00
2018-10-21 10:46:48 -04:00
2018-10-31 08:54:13 -07:00
2019-02-09 08:44:32 -08:00
2019-02-09 08:44:41 -08:00
2019-02-09 08:44:46 -08:00
2018-11-08 21:43:20 -08:00
2019-02-09 08:47:52 -08:00
2019-02-09 08:45:46 -08:00
2019-02-09 08:45:52 -08:00
2019-01-23 15:52:15 +00:00
2019-01-03 18:57:57 -08:00
2019-03-07 18:32:03 -08:00
2019-02-20 21:34:17 -08:00
2018-10-25 13:45:23 +02:00
2019-01-07 16:38:26 +01:00
2019-02-22 13:49:00 +01:00
2019-03-13 09:46:10 -04:00
2019-02-25 21:20:45 +01:00
2019-03-22 11:01:02 -06:00
2019-02-11 15:02:33 -07:00
2019-03-07 12:20:11 -08:00
2018-12-11 16:28:41 -08:00
2019-03-12 14:08:19 -07:00
2018-11-27 19:44:21 +01:00
2018-12-17 16:02:57 +01:00
2018-11-09 09:07:17 -08:00
2018-11-29 11:46:34 -08:00
2018-11-11 14:44:53 +05:30
2019-03-05 21:07:18 -08:00
2019-01-12 11:48:20 -06:00
2019-03-11 08:54:01 -07:00
2018-12-20 23:47:09 +01:00
2018-12-28 12:11:44 -08:00
2019-03-29 10:01:37 -07:00
2019-03-05 21:07:14 -08:00
2019-03-15 15:29:47 -07:00
2019-02-09 08:47:52 -08:00
2019-02-09 08:45:59 -08:00
2019-02-09 08:47:52 -08:00
2019-02-07 16:38:35 +01:00
2019-01-30 22:24:49 -08:00
2018-12-22 22:50:29 -05:00
2019-03-14 14:36:20 -07:00
2019-03-10 12:47:57 -07:00
2019-02-11 07:36:13 -05:00
2019-03-16 13:47:14 -07:00
2018-12-03 18:18:19 +02:00
2018-12-07 22:39:46 -05:00
2018-11-21 15:49:52 -08:00
2019-02-28 13:49:29 +01:00
2019-02-07 00:13:27 +01:00
2019-02-07 00:13:28 +01:00
2018-12-18 16:13:05 +01:00
2018-12-18 16:13:05 +01:00
2019-02-07 00:13:28 +01:00
2019-02-09 08:47:52 -08:00
2019-02-13 09:48:51 +02:00
2019-02-13 09:48:52 +02:00
2018-12-18 14:08:12 -08:00
2018-11-12 04:53:27 +01:00
2018-12-04 07:52:30 +01:00
2018-12-10 10:17:45 +01:00
2019-03-07 18:31:59 -08:00
2019-01-04 12:56:09 -08:00
2018-11-08 17:13:08 -08:00
2019-03-23 10:25:12 -07:00
2019-01-11 18:05:40 -08:00
2018-12-05 21:20:14 +01:00
2019-02-04 17:34:07 -05:00
2019-03-07 10:34:37 +01:00
2019-03-06 11:19:57 -05:00
2019-02-24 12:06:19 -08:00
2019-03-06 11:19:15 -05:00
2018-12-28 12:11:51 -08:00
2019-02-26 12:53:55 +01:00
2019-02-11 08:34:04 +01:00
2018-12-22 12:15:29 +01:00
2019-03-07 08:46:07 -08:00
2019-03-06 14:52:48 -08:00
2018-12-07 22:26:37 -07:00
2019-02-20 17:08:54 -05:00
2018-12-28 12:11:46 -08:00