Skip to content

Commit 35ec8fa

Browse files
Hugh Dickinsakpm00
authored andcommitted
mempolicy: mpol_shared_policy_init() without pseudo-vma
mpol_shared_policy_init() does not need to use a pseudo-vma: it can use sp_alloc() and sp_insert() directly, since the object's shared policy tree is empty and inaccessible (needing no lock) at get_inode() time. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Hugh Dickins <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: "Huang, Ying" <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Mel Gorman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Kravetz <[email protected]> Cc: Nhat Pham <[email protected]> Cc: Sidhartha Kumar <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: Tejun heo <[email protected]> Cc: Vishal Moola (Oracle) <[email protected]> Cc: Yang Shi <[email protected]> Cc: Yosry Ahmed <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 93397c3 commit 35ec8fa

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

mm/mempolicy.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2736,30 +2736,30 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
27362736
rwlock_init(&sp->lock);
27372737

27382738
if (mpol) {
2739-
struct vm_area_struct pvma;
2740-
struct mempolicy *new;
2739+
struct sp_node *sn;
2740+
struct mempolicy *npol;
27412741
NODEMASK_SCRATCH(scratch);
27422742

27432743
if (!scratch)
27442744
goto put_mpol;
2745-
/* contextualize the tmpfs mount point mempolicy */
2746-
new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
2747-
if (IS_ERR(new))
2745+
2746+
/* contextualize the tmpfs mount point mempolicy to this file */
2747+
npol = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
2748+
if (IS_ERR(npol))
27482749
goto free_scratch; /* no valid nodemask intersection */
27492750

27502751
task_lock(current);
2751-
ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch);
2752+
ret = mpol_set_nodemask(npol, &mpol->w.user_nodemask, scratch);
27522753
task_unlock(current);
27532754
if (ret)
2754-
goto put_new;
2755-
2756-
/* Create pseudo-vma that contains just the policy */
2757-
vma_init(&pvma, NULL);
2758-
pvma.vm_end = TASK_SIZE; /* policy covers entire file */
2759-
mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
2760-
2761-
put_new:
2762-
mpol_put(new); /* drop initial ref */
2755+
goto put_npol;
2756+
2757+
/* alloc node covering entire file; adds ref to file's npol */
2758+
sn = sp_alloc(0, MAX_LFS_FILESIZE >> PAGE_SHIFT, npol);
2759+
if (sn)
2760+
sp_insert(sp, sn);
2761+
put_npol:
2762+
mpol_put(npol); /* drop initial ref on file's npol */
27632763
free_scratch:
27642764
NODEMASK_SCRATCH_FREE(scratch);
27652765
put_mpol:

0 commit comments

Comments
 (0)