Merge branch 'akpm' (patches from Andrew)
Merge misc fixes from Andrew Morton: "3 fixes" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: userfaultfd: remove uffd flags from vma->vm_flags if UFFD_EVENT_FORK fails ipc/shm.c add ->pagesize function to shm_vm_ops memcg: remove memcg_cgroup::id from IDR on mem_cgroup_css_alloc() failure
This commit is contained in:
commit
98d7e10098
|
@ -633,8 +633,10 @@ static void userfaultfd_event_wait_completion(struct userfaultfd_ctx *ctx,
|
||||||
/* the various vma->vm_userfaultfd_ctx still points to it */
|
/* the various vma->vm_userfaultfd_ctx still points to it */
|
||||||
down_write(&mm->mmap_sem);
|
down_write(&mm->mmap_sem);
|
||||||
for (vma = mm->mmap; vma; vma = vma->vm_next)
|
for (vma = mm->mmap; vma; vma = vma->vm_next)
|
||||||
if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx)
|
if (vma->vm_userfaultfd_ctx.ctx == release_new_ctx) {
|
||||||
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
|
vma->vm_userfaultfd_ctx = NULL_VM_UFFD_CTX;
|
||||||
|
vma->vm_flags &= ~(VM_UFFD_WP | VM_UFFD_MISSING);
|
||||||
|
}
|
||||||
up_write(&mm->mmap_sem);
|
up_write(&mm->mmap_sem);
|
||||||
|
|
||||||
userfaultfd_ctx_put(release_new_ctx);
|
userfaultfd_ctx_put(release_new_ctx);
|
||||||
|
|
12
ipc/shm.c
12
ipc/shm.c
|
@ -427,6 +427,17 @@ static int shm_split(struct vm_area_struct *vma, unsigned long addr)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned long shm_pagesize(struct vm_area_struct *vma)
|
||||||
|
{
|
||||||
|
struct file *file = vma->vm_file;
|
||||||
|
struct shm_file_data *sfd = shm_file_data(file);
|
||||||
|
|
||||||
|
if (sfd->vm_ops->pagesize)
|
||||||
|
return sfd->vm_ops->pagesize(vma);
|
||||||
|
|
||||||
|
return PAGE_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NUMA
|
#ifdef CONFIG_NUMA
|
||||||
static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
|
static int shm_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
|
||||||
{
|
{
|
||||||
|
@ -554,6 +565,7 @@ static const struct vm_operations_struct shm_vm_ops = {
|
||||||
.close = shm_close, /* callback for when the vm-area is released */
|
.close = shm_close, /* callback for when the vm-area is released */
|
||||||
.fault = shm_fault,
|
.fault = shm_fault,
|
||||||
.split = shm_split,
|
.split = shm_split,
|
||||||
|
.pagesize = shm_pagesize,
|
||||||
#if defined(CONFIG_NUMA)
|
#if defined(CONFIG_NUMA)
|
||||||
.set_policy = shm_set_policy,
|
.set_policy = shm_set_policy,
|
||||||
.get_policy = shm_get_policy,
|
.get_policy = shm_get_policy,
|
||||||
|
|
|
@ -3167,6 +3167,13 @@ static vm_fault_t hugetlb_vm_op_fault(struct vm_fault *vmf)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When a new function is introduced to vm_operations_struct and added
|
||||||
|
* to hugetlb_vm_ops, please consider adding the function to shm_vm_ops.
|
||||||
|
* This is because under System V memory model, mappings created via
|
||||||
|
* shmget/shmat with "huge page" specified are backed by hugetlbfs files,
|
||||||
|
* their original vm_ops are overwritten with shm_vm_ops.
|
||||||
|
*/
|
||||||
const struct vm_operations_struct hugetlb_vm_ops = {
|
const struct vm_operations_struct hugetlb_vm_ops = {
|
||||||
.fault = hugetlb_vm_op_fault,
|
.fault = hugetlb_vm_op_fault,
|
||||||
.open = hugetlb_vm_op_open,
|
.open = hugetlb_vm_op_open,
|
||||||
|
|
|
@ -4037,6 +4037,14 @@ static struct cftype mem_cgroup_legacy_files[] = {
|
||||||
|
|
||||||
static DEFINE_IDR(mem_cgroup_idr);
|
static DEFINE_IDR(mem_cgroup_idr);
|
||||||
|
|
||||||
|
static void mem_cgroup_id_remove(struct mem_cgroup *memcg)
|
||||||
|
{
|
||||||
|
if (memcg->id.id > 0) {
|
||||||
|
idr_remove(&mem_cgroup_idr, memcg->id.id);
|
||||||
|
memcg->id.id = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
|
static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)
|
||||||
{
|
{
|
||||||
VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0);
|
VM_BUG_ON(atomic_read(&memcg->id.ref) <= 0);
|
||||||
|
@ -4047,8 +4055,7 @@ static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n)
|
||||||
{
|
{
|
||||||
VM_BUG_ON(atomic_read(&memcg->id.ref) < n);
|
VM_BUG_ON(atomic_read(&memcg->id.ref) < n);
|
||||||
if (atomic_sub_and_test(n, &memcg->id.ref)) {
|
if (atomic_sub_and_test(n, &memcg->id.ref)) {
|
||||||
idr_remove(&mem_cgroup_idr, memcg->id.id);
|
mem_cgroup_id_remove(memcg);
|
||||||
memcg->id.id = 0;
|
|
||||||
|
|
||||||
/* Memcg ID pins CSS */
|
/* Memcg ID pins CSS */
|
||||||
css_put(&memcg->css);
|
css_put(&memcg->css);
|
||||||
|
@ -4185,8 +4192,7 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
|
||||||
idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
|
idr_replace(&mem_cgroup_idr, memcg, memcg->id.id);
|
||||||
return memcg;
|
return memcg;
|
||||||
fail:
|
fail:
|
||||||
if (memcg->id.id > 0)
|
mem_cgroup_id_remove(memcg);
|
||||||
idr_remove(&mem_cgroup_idr, memcg->id.id);
|
|
||||||
__mem_cgroup_free(memcg);
|
__mem_cgroup_free(memcg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -4245,6 +4251,7 @@ mem_cgroup_css_alloc(struct cgroup_subsys_state *parent_css)
|
||||||
|
|
||||||
return &memcg->css;
|
return &memcg->css;
|
||||||
fail:
|
fail:
|
||||||
|
mem_cgroup_id_remove(memcg);
|
||||||
mem_cgroup_free(memcg);
|
mem_cgroup_free(memcg);
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue