-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ShivamKumarJha <[email protected]>
- Loading branch information
1 parent
6b6887d
commit 381fbff
Showing
11 changed files
with
596 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
* lifting | ||
* | ||
* Copyright IBM Corp. 2007-2010 Mel Gorman <[email protected]> | ||
* Copyright (C) 2021 XiaoMi, Inc. | ||
*/ | ||
#include <linux/cpu.h> | ||
#include <linux/swap.h> | ||
|
@@ -1905,7 +1906,7 @@ static enum compact_result __compact_finished(struct compact_control *cc) | |
* other migratetype buddy lists. | ||
*/ | ||
if (find_suitable_fallback(area, order, migratetype, | ||
true, &can_steal) != -1) { | ||
true, &can_steal, cc->order) != -1) { | ||
|
||
/* movable pages are OK in any pageblock */ | ||
if (migratetype == MIGRATE_MOVABLE) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
/* internal.h: mm/ internal definitions | ||
* | ||
* Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. | ||
* Copyright (C) 2021 XiaoMi, Inc. | ||
* Written by David Howells ([email protected]) | ||
*/ | ||
#ifndef __MM_INTERNAL_H | ||
|
@@ -241,7 +242,7 @@ unsigned long | |
isolate_migratepages_range(struct compact_control *cc, | ||
unsigned long low_pfn, unsigned long end_pfn); | ||
int find_suitable_fallback(struct free_area *area, unsigned int order, | ||
int migratetype, bool only_stealable, bool *can_steal); | ||
int migratetype, bool only_stealable, bool *can_steal, unsigned int start_order); | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
* This file contains common generic and tag-based KASAN code. | ||
* | ||
* Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
* Copyright (C) 2021 XiaoMi, Inc. | ||
* Author: Andrey Ryabinin <[email protected]> | ||
* | ||
* Some code borrowed from https://github.com/xairy/kasan-prototype by | ||
|
@@ -470,7 +471,8 @@ static bool __kasan_slab_free(struct kmem_cache *cache, void *object, | |
|
||
kasan_set_free_info(cache, object, tag); | ||
|
||
quarantine_put(get_free_info(cache, object), cache); | ||
if (!quarantine_put(get_free_info(cache, object), cache)) | ||
return false; | ||
|
||
return IS_ENABLED(CONFIG_KASAN_GENERIC); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
* | ||
* Author: Alexander Potapenko <[email protected]> | ||
* Copyright (C) 2016 Google, Inc. | ||
* Copyright (C) 2021 XiaoMi, Inc. | ||
* | ||
* Based on code by Dmitry Chernenkov. | ||
* | ||
|
@@ -29,6 +30,7 @@ | |
#include <linux/srcu.h> | ||
#include <linux/string.h> | ||
#include <linux/types.h> | ||
#include <linux/cpuhotplug.h> | ||
|
||
#include "../slab.h" | ||
#include "kasan.h" | ||
|
@@ -43,6 +45,7 @@ struct qlist_head { | |
struct qlist_node *head; | ||
struct qlist_node *tail; | ||
size_t bytes; | ||
bool offline; | ||
}; | ||
|
||
#define QLIST_INIT { NULL, NULL, 0 } | ||
|
@@ -170,7 +173,7 @@ static void qlist_free_all(struct qlist_head *q, struct kmem_cache *cache) | |
qlist_init(q); | ||
} | ||
|
||
void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) | ||
bool quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) | ||
{ | ||
unsigned long flags; | ||
struct qlist_head *q; | ||
|
@@ -187,6 +190,10 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) | |
local_irq_save(flags); | ||
|
||
q = this_cpu_ptr(&cpu_quarantine); | ||
if (q->offline) { | ||
local_irq_restore(flags); | ||
return false; | ||
} | ||
qlist_put(q, &info->quarantine_link, cache->size); | ||
if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) { | ||
qlist_move_all(q, &temp); | ||
|
@@ -208,6 +215,8 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) | |
} | ||
|
||
local_irq_restore(flags); | ||
|
||
return true; | ||
} | ||
|
||
void quarantine_reduce(void) | ||
|
@@ -327,3 +336,36 @@ void quarantine_remove_cache(struct kmem_cache *cache) | |
|
||
synchronize_srcu(&remove_cache_srcu); | ||
} | ||
|
||
static int kasan_cpu_online(unsigned int cpu) | ||
{ | ||
this_cpu_ptr(&cpu_quarantine)->offline = false; | ||
return 0; | ||
} | ||
|
||
static int kasan_cpu_offline(unsigned int cpu) | ||
{ | ||
struct qlist_head *q; | ||
|
||
q = this_cpu_ptr(&cpu_quarantine); | ||
/* Ensure the ordering between the writing to q->offline and | ||
* qlist_free_all. Otherwise, cpu_quarantine may be corrupted | ||
* by interrupt. | ||
*/ | ||
WRITE_ONCE(q->offline, true); | ||
barrier(); | ||
qlist_free_all(q, NULL); | ||
return 0; | ||
} | ||
|
||
static int __init kasan_cpu_quarantine_init(void) | ||
{ | ||
int ret = 0; | ||
|
||
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mm/kasan:online", | ||
kasan_cpu_online, kasan_cpu_offline); | ||
if (ret < 0) | ||
pr_err("kasan cpu quarantine register failed [%d]\n", ret); | ||
return ret; | ||
} | ||
late_initcall(kasan_cpu_quarantine_init); |
Oops, something went wrong.