Skip to content

Commit 212c5c0

Browse files
soleenjoergroedel
authored andcommitted
iommu: account IOMMU allocated memory
In order to be able to limit the amount of memory that is allocated by IOMMU subsystem, the memory must be accounted. Account IOMMU as part of the secondary pagetables as it was discussed at LPC. The value of SecPageTables now contains mmeory allocation by IOMMU and KVM. There is a difference between GFP_ACCOUNT and what NR_IOMMU_PAGES shows. GFP_ACCOUNT is set only where it makes sense to charge to user processes, i.e. IOMMU Page Tables, but there more IOMMU shared data that should not really be charged to a specific process. Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com> Acked-by: David Rientjes <rientjes@google.com> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com> Link: https://lore.kernel.org/r/20240413002522.1101315-12-pasha.tatashin@soleen.com Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent bd3520a commit 212c5c0

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ PAGE_SIZE multiple when read back.
14321432
sec_pagetables
14331433
Amount of memory allocated for secondary page tables,
14341434
this currently includes KVM mmu allocations on x86
1435-
and arm64.
1435+
and arm64 and IOMMU page tables.
14361436

14371437
percpu (npn)
14381438
Amount of memory used for storing per-cpu kernel

Documentation/filesystems/proc.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,8 @@ KernelStack
11101110
PageTables
11111111
Memory consumed by userspace page tables
11121112
SecPageTables
1113-
Memory consumed by secondary page tables, this currently
1114-
currently includes KVM mmu allocations on x86 and arm64.
1113+
Memory consumed by secondary page tables, this currently includes
1114+
KVM mmu and IOMMU allocations on x86 and arm64.
11151115
NFS_Unstable
11161116
Always zero. Previous counted pages which had been written to
11171117
the server, but has not been committed to stable storage.

drivers/iommu/iommu-pages.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static inline void __iommu_alloc_account(struct page *page, int order)
3030
const long pgcnt = 1l << order;
3131

3232
mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, pgcnt);
33+
mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, pgcnt);
3334
}
3435

3536
/**
@@ -42,6 +43,7 @@ static inline void __iommu_free_account(struct page *page, int order)
4243
const long pgcnt = 1l << order;
4344

4445
mod_node_page_state(page_pgdat(page), NR_IOMMU_PAGES, -pgcnt);
46+
mod_lruvec_page_state(page, NR_SECONDARY_PAGETABLE, -pgcnt);
4547
}
4648

4749
/**

include/linux/mmzone.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ enum node_stat_item {
205205
NR_KERNEL_SCS_KB, /* measured in KiB */
206206
#endif
207207
NR_PAGETABLE, /* used for pagetables */
208-
NR_SECONDARY_PAGETABLE, /* secondary pagetables, e.g. KVM pagetables */
208+
NR_SECONDARY_PAGETABLE, /* secondary pagetables, KVM & IOMMU */
209209
#ifdef CONFIG_IOMMU_SUPPORT
210210
NR_IOMMU_PAGES, /* # of pages allocated by IOMMU */
211211
#endif

0 commit comments

Comments
 (0)