projects
/
deliverable
/
linux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mm, oom: fix race when specifying a thread as the oom origin
[deliverable/linux.git]
/
mm
/
swapfile.c
diff --git
a/mm/swapfile.c
b/mm/swapfile.c
index f91a25547ffe1f2febdfb0a526ee296996da171b..e97a0e5aea912cf0c0109164811d650cc0b2219e 100644
(file)
--- a/
mm/swapfile.c
+++ b/
mm/swapfile.c
@@
-1443,13
+1443,12
@@
static int setup_swap_extents(struct swap_info_struct *sis, sector_t *span)
return generic_swapfile_activate(sis, swap_file, span);
}
return generic_swapfile_activate(sis, swap_file, span);
}
-static void enable_swap_info(struct swap_info_struct *p, int prio,
+static void
_
enable_swap_info(struct swap_info_struct *p, int prio,
unsigned char *swap_map,
unsigned long *frontswap_map)
{
int i, prev;
unsigned char *swap_map,
unsigned long *frontswap_map)
{
int i, prev;
- spin_lock(&swap_lock);
if (prio >= 0)
p->prio = prio;
else
if (prio >= 0)
p->prio = prio;
else
@@
-1472,10
+1471,25
@@
static void enable_swap_info(struct swap_info_struct *p, int prio,
swap_list.head = swap_list.next = p->type;
else
swap_info[prev]->next = p->type;
swap_list.head = swap_list.next = p->type;
else
swap_info[prev]->next = p->type;
+}
+
+static void enable_swap_info(struct swap_info_struct *p, int prio,
+ unsigned char *swap_map,
+ unsigned long *frontswap_map)
+{
+ spin_lock(&swap_lock);
+ _enable_swap_info(p, prio, swap_map, frontswap_map);
frontswap_init(p->type);
spin_unlock(&swap_lock);
}
frontswap_init(p->type);
spin_unlock(&swap_lock);
}
+static void reinsert_swap_info(struct swap_info_struct *p)
+{
+ spin_lock(&swap_lock);
+ _enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p));
+ spin_unlock(&swap_lock);
+}
+
SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
{
struct swap_info_struct *p = NULL;
SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
{
struct swap_info_struct *p = NULL;
@@
-1484,7
+1498,6
@@
SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
struct address_space *mapping;
struct inode *inode;
struct filename *pathname;
struct address_space *mapping;
struct inode *inode;
struct filename *pathname;
- int oom_score_adj;
int i, type, prev;
int err;
int i, type, prev;
int err;
@@
-1543,19
+1556,13
@@
SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
p->flags &= ~SWP_WRITEOK;
spin_unlock(&swap_lock);
p->flags &= ~SWP_WRITEOK;
spin_unlock(&swap_lock);
-
oom_score_adj = test_set_oom_score_adj(OOM_SCORE_ADJ_MAX
);
+
set_current_oom_origin(
);
err = try_to_unuse(type, false, 0); /* force all pages to be unused */
err = try_to_unuse(type, false, 0); /* force all pages to be unused */
- c
ompare_swap_oom_score_adj(OOM_SCORE_ADJ_MAX, oom_score_adj
);
+ c
lear_current_oom_origin(
);
if (err) {
if (err) {
- /*
- * reading p->prio and p->swap_map outside the lock is
- * safe here because only sys_swapon and sys_swapoff
- * change them, and there can be no other sys_swapon or
- * sys_swapoff for this swap_info_struct at this point.
- */
/* re-insert swap space back into swap_list */
/* re-insert swap space back into swap_list */
-
enable_swap_info(p, p->prio, p->swap_map, frontswap_map_get(p)
);
+
reinsert_swap_info(p
);
goto out_dput;
}
goto out_dput;
}
This page took
0.039166 seconds
and
5
git commands to generate.