Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252837
b: refs/heads/master
c: 6345d24
h: refs/heads/master
i:
  252835: fcfc97c
v: v3
  • Loading branch information
Linus Torvalds committed May 29, 2011
1 parent 891f4c2 commit 025b0c9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cab0d85c8dfcad4d799f9c294571440c6f1db091
refs/heads/master: 6345d24daf0c1fffe6642081d783cdf653ebaa5c
14 changes: 12 additions & 2 deletions trunk/include/linux/mm_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ struct mm_struct {

struct linux_binfmt *binfmt;

cpumask_var_t cpu_vm_mask_var;

/* Architecture-specific MM context */
mm_context_t context;

Expand Down Expand Up @@ -311,10 +313,18 @@ struct mm_struct {
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
pgtable_t pmd_huge_pte; /* protected by page_table_lock */
#endif

cpumask_var_t cpu_vm_mask_var;
#ifdef CONFIG_CPUMASK_OFFSTACK
struct cpumask cpumask_allocation;
#endif
};

static inline void mm_init_cpumask(struct mm_struct *mm)
{
#ifdef CONFIG_CPUMASK_OFFSTACK
mm->cpu_vm_mask_var = &mm->cpumask_allocation;
#endif
}

/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
{
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,6 @@ static inline void mmdrop(struct mm_struct * mm)
if (unlikely(atomic_dec_and_test(&mm->mm_count)))
__mmdrop(mm);
}
extern int mm_init_cpumask(struct mm_struct *mm, struct mm_struct *oldmm);

/* mmput gets rid of the mappings and all user-space */
extern void mmput(struct mm_struct *);
Expand Down
2 changes: 1 addition & 1 deletion trunk/init/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ asmlinkage void __init start_kernel(void)
printk(KERN_NOTICE "%s", linux_banner);
setup_arch(&command_line);
mm_init_owner(&init_mm, &init_task);
mm_init_cpumask(&init_mm);
setup_command_line(command_line);
setup_nr_cpu_ids();
setup_per_cpu_areas();
Expand All @@ -510,7 +511,6 @@ asmlinkage void __init start_kernel(void)
sort_main_extable();
trap_init();
mm_init();
BUG_ON(mm_init_cpumask(&init_mm, 0));

/*
* Set up the scheduler prior starting any interrupts (such as the
Expand Down
42 changes: 10 additions & 32 deletions trunk/kernel/fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,6 @@ static void mm_init_aio(struct mm_struct *mm)
#endif
}

int mm_init_cpumask(struct mm_struct *mm, struct mm_struct *oldmm)
{
#ifdef CONFIG_CPUMASK_OFFSTACK
if (!alloc_cpumask_var(&mm->cpu_vm_mask_var, GFP_KERNEL))
return -ENOMEM;

if (oldmm)
cpumask_copy(mm_cpumask(mm), mm_cpumask(oldmm));
else
memset(mm_cpumask(mm), 0, cpumask_size());
#endif
return 0;
}

static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
{
atomic_set(&mm->mm_users, 1);
Expand Down Expand Up @@ -538,17 +524,8 @@ struct mm_struct * mm_alloc(void)
return NULL;

memset(mm, 0, sizeof(*mm));
mm = mm_init(mm, current);
if (!mm)
return NULL;

if (mm_init_cpumask(mm, NULL)) {
mm_free_pgd(mm);
free_mm(mm);
return NULL;
}

return mm;
mm_init_cpumask(mm);
return mm_init(mm, current);
}

/*
Expand All @@ -559,7 +536,6 @@ struct mm_struct * mm_alloc(void)
void __mmdrop(struct mm_struct *mm)
{
BUG_ON(mm == &init_mm);
free_cpumask_var(mm->cpu_vm_mask_var);
mm_free_pgd(mm);
destroy_context(mm);
mmu_notifier_mm_destroy(mm);
Expand Down Expand Up @@ -753,6 +729,7 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
goto fail_nomem;

memcpy(mm, oldmm, sizeof(*mm));
mm_init_cpumask(mm);

/* Initializing for Swap token stuff */
mm->token_priority = 0;
Expand All @@ -765,9 +742,6 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
if (!mm_init(mm, tsk))
goto fail_nomem;

if (mm_init_cpumask(mm, oldmm))
goto fail_nocpumask;

if (init_new_context(tsk, mm))
goto fail_nocontext;

Expand All @@ -794,9 +768,6 @@ struct mm_struct *dup_mm(struct task_struct *tsk)
return NULL;

fail_nocontext:
free_cpumask_var(mm->cpu_vm_mask_var);

fail_nocpumask:
/*
* If init_new_context() failed, we cannot use mmput() to free the mm
* because it calls destroy_context()
Expand Down Expand Up @@ -1591,6 +1562,13 @@ void __init proc_caches_init(void)
fs_cachep = kmem_cache_create("fs_cache",
sizeof(struct fs_struct), 0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
/*
* FIXME! The "sizeof(struct mm_struct)" currently includes the
* whole struct cpumask for the OFFSTACK case. We could change
* this to *only* allocate as much of it as required by the
* maximum number of CPU's we can ever have. The cpumask_allocation
* is at the end of the structure, exactly for that reason.
*/
mm_cachep = kmem_cache_create("mm_struct",
sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
Expand Down

0 comments on commit 025b0c9

Please sign in to comment.