*/
struct mempolicy *(*get_policy)(struct vm_area_struct *vma,
unsigned long addr);
+
+ /*
+ * If the policy is interleave allow the vma to suggest a node.
+ */
+ unsigned long (*interleave)(struct vm_area_struct *vma,
+ unsigned long addr);
+
int (*migrate)(struct vm_area_struct *vma, const nodemask_t *from,
const nodemask_t *to, unsigned long flags);
#endif
char *symlink; /* unswappable short symlink */
};
struct shared_policy policy; /* NUMA memory alloc policy */
+ unsigned long node_offset; /* bias for interleaved nodes */
struct list_head swaplist; /* chain of maybes on swap */
struct list_head xattr_list; /* list of shmem_xattr */
struct inode vfs_inode;
kgid_t gid; /* Mount gid for root directory */
umode_t mode; /* Mount mode for root directory */
struct mempolicy *mpol; /* default memory policy for mappings */
+ unsigned long next_pref_node;
+ /* next interleave bias to suggest for inodes */
};
static inline struct shmem_inode_info *SHMEM_I(struct inode *inode)
{
if (vma) {
unsigned long off;
+ if (vma->vm_ops && vma->vm_ops->interleave) {
+ off = vma->vm_ops->interleave(vma, addr);
+ return offset_il_node(pol, vma, off);
+ }
/*
* for small pages, there is no difference between
pvma.vm_start = 0;
pvma.vm_pgoff = index;
pvma.vm_policy = spol;
+ pvma.vm_private_data = (void *) info->node_offset;
if (pvma.vm_policy)
pvma.vm_ops = &shmem_vm_ops;
else
pvma.vm_start = 0;
pvma.vm_pgoff = index;
pvma.vm_policy = mpol_shared_policy_lookup(&info->policy, index);
+ pvma.vm_private_data = (void *) info->node_offset;
if (pvma.vm_policy)
pvma.vm_ops = &shmem_vm_ops;
else
index = ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
return mpol_shared_policy_lookup(&SHMEM_I(inode)->policy, index);
}
+
+static unsigned long shmem_interleave(struct vm_area_struct *vma,
+ unsigned long addr)
+{
+ unsigned long offset;
+
+ /* Use the vm_files prefered node as the initial offset. */
+ offset = (unsigned long *) vma->vm_private_data;
+
+ offset += ((addr - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
+
+ return offset;
+}
#endif
int shmem_lock(struct file *file, int lock, struct user_struct *user)
inode->i_fop = &shmem_file_operations;
mpol_shared_policy_init(&info->policy,
shmem_get_sbmpol(sbinfo));
+ info->node_offset = ++(sbinfo->next_pref_node);
break;
case S_IFDIR:
inc_nlink(inode);
static const struct vm_operations_struct shmem_vm_ops = {
.fault = shmem_fault,
#ifdef CONFIG_NUMA
+ .interleave = shmem_interleave,
.set_policy = shmem_set_policy,
.get_policy = shmem_get_policy,
#endif