summaryrefslogtreecommitdiff
path: root/kernel/scs.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/scs.c')
-rw-r--r--kernel/scs.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/scs.c b/kernel/scs.c
index 38f8f31c9451..6d2f983ac54e 100644
--- a/kernel/scs.c
+++ b/kernel/scs.c
@@ -6,8 +6,10 @@
*/
#include <linux/kasan.h>
+#include <linux/mm.h>
#include <linux/scs.h>
#include <linux/slab.h>
+#include <linux/vmstat.h>
#include <asm/scs.h>
static struct kmem_cache *scs_cache;
@@ -40,6 +42,17 @@ void __init scs_init(void)
scs_cache = kmem_cache_create("scs_cache", SCS_SIZE, 0, 0, NULL);
}
+static struct page *__scs_page(struct task_struct *tsk)
+{
+ return virt_to_page(task_scs(tsk));
+}
+
+static void scs_account(struct task_struct *tsk, int account)
+{
+ mod_zone_page_state(page_zone(__scs_page(tsk)), NR_KERNEL_SCS_KB,
+ account * (SCS_SIZE / 1024));
+}
+
int scs_prepare(struct task_struct *tsk, int node)
{
void *s = scs_alloc(node);
@@ -49,6 +62,7 @@ int scs_prepare(struct task_struct *tsk, int node)
task_scs(tsk) = s;
task_scs_offset(tsk) = 0;
+ scs_account(tsk, 1);
return 0;
}
@@ -61,5 +75,6 @@ void scs_release(struct task_struct *tsk)
return;
WARN(scs_corrupted(tsk), "corrupted shadow stack detected when freeing task\n");
+ scs_account(tsk, -1);
scs_free(s);
}