lkml.org 
[lkml]   [2018]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 12/14] mm/hbind: add migrate command to hbind() ioctl
Date
From: Jérôme Glisse <jglisse@redhat.com>

This patch add migrate commands to hbind() ioctl, user space can use
this commands to migrate a range of virtual address to list of target
memory.

This does not change the policy for the range, it also ignores any of
the existing policy range, it does not changes the policy for the
range.

Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Haggai Eran <haggaie@mellanox.com>
Cc: Balbir Singh <balbirs@au1.ibm.com>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Felix Kuehling <felix.kuehling@amd.com>
Cc: Philip Yang <Philip.Yang@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Paul Blinzer <Paul.Blinzer@amd.com>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Mark Hairgrove <mhairgrove@nvidia.com>
Cc: Vivek Kini <vkini@nvidia.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Ben Skeggs <bskeggs@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
---
include/uapi/linux/hbind.h | 9 ++++++++
mm/hms.c | 43 ++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)

diff --git a/include/uapi/linux/hbind.h b/include/uapi/linux/hbind.h
index 7bb876954e3f..ededbba22121 100644
--- a/include/uapi/linux/hbind.h
+++ b/include/uapi/linux/hbind.h
@@ -57,6 +57,15 @@ struct hbind_params {
*/
#define HBIND_CMD_BIND 1

+/*
+ * HBIND_CMD_MIGRATE move existing memory to use listed target memory. This is
+ * a best effort.
+ *
+ * Additional dwords:
+ * [0] result ie number of pages that have been migrated.
+ */
+#define HBIND_CMD_MIGRATE 2
+

#define HBIND_IOCTL _IOWR('H', 0x00, struct hbind_params)

diff --git a/mm/hms.c b/mm/hms.c
index 6be6f4acdd49..6764908f47bf 100644
--- a/mm/hms.c
+++ b/mm/hms.c
@@ -368,6 +368,39 @@ static int hbind_bind(struct mm_struct *mm, struct hbind_params *params,
}


+static int hbind_migrate(struct mm_struct *mm, struct hbind_params *params,
+ const uint32_t *targets, uint32_t *atoms)
+{
+ unsigned long size, npages;
+ int ret = -EINVAL;
+ unsigned i;
+
+ size = PAGE_ALIGN(params->end) - (params->start & PAGE_MASK);
+ npages = size >> PAGE_SHIFT;
+
+ for (i = 0; params->ntargets; ++i) {
+ struct hms_target *target;
+
+ target = hms_target_find(targets[i]);
+ if (target == NULL)
+ continue;
+
+ ret = target->hbind->migrate(target, mm, params->start,
+ params->end, params->natoms,
+ atoms);
+ hms_target_put(target);
+
+ if (ret)
+ continue;
+
+ if (atoms[0] >= npages)
+ break;
+ }
+
+ return ret;
+}
+
+
static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg)
{
uint32_t *targets, *_dtargets = NULL, _ftargets[HBIND_FIX_ARRAY];
@@ -458,6 +491,16 @@ static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg)
if (ret)
goto out_mm;
break;
+ case HBIND_CMD_MIGRATE:
+ if (ndwords != 2) {
+ ret = -EINVAL;
+ goto out_mm;
+ }
+ ret = hbind_migrate(current->mm, &params,
+ targets, atoms);
+ if (ret)
+ goto out_mm;
+ break;
default:
ret = -EINVAL;
goto out_mm;
--
2.17.2
\
 
 \ /
  Last update: 2018-12-04 00:37    [W:0.146 / U:37.872 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site