提交 46cd9a65 编写于 作者: J Jiankang Chen 提交者: Xie XiuQi

svm: implement get hugeinfo function by ioctl

ascend inclusion
category: feature
bugzilla: 16554
CVE: NA

--------

svm implement get hugeinfo functiion, and this
is runtime features;
Signed-off-by: NJiankang Chen <chenjiankang1@huawei.com>
Signed-off-by: NLijun Fang <fanglijun3@huawei.com>
Reviewed-by: NLi Zefan <lizefan@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 4cdb60f5
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#define SVM_IOCTL_GET_L2PTE_BASE 0xfffb #define SVM_IOCTL_GET_L2PTE_BASE 0xfffb
#define SVM_IOCTL_PIN_MEMORY 0xfff7 #define SVM_IOCTL_PIN_MEMORY 0xfff7
#define SVM_IOCTL_UNPIN_MEMORY 0xfff5 #define SVM_IOCTL_UNPIN_MEMORY 0xfff5
#define SVM_IOCTL_GETHUGEINFO 0xfff6
#endif #endif
#ifndef CONFIG_ACPI #ifndef CONFIG_ACPI
...@@ -114,6 +115,11 @@ struct svm_sdma { ...@@ -114,6 +115,11 @@ struct svm_sdma {
struct page **pages; struct page **pages;
atomic64_t ref; atomic64_t ref;
}; };
struct meminfo {
unsigned long hugetlbfree;
unsigned long hugetlbtotal;
};
#endif #endif
static struct bus_type svm_bus_type = { static struct bus_type svm_bus_type = {
...@@ -137,6 +143,8 @@ static char *svm_cmd_to_string(unsigned int cmd) ...@@ -137,6 +143,8 @@ static char *svm_cmd_to_string(unsigned int cmd)
return "pin memory"; return "pin memory";
case SVM_IOCTL_UNPIN_MEMORY: case SVM_IOCTL_UNPIN_MEMORY:
return "unpin memory"; return "unpin memory";
case SVM_IOCTL_GETHUGEINFO:
return "get hugeinfo";
#endif #endif
default: default:
return "unsupported"; return "unsupported";
...@@ -1346,6 +1354,35 @@ static int svm_get_l2pte_base(struct svm_device *sdev, ...@@ -1346,6 +1354,35 @@ static int svm_get_l2pte_base(struct svm_device *sdev,
kfree(base); kfree(base);
return err; return err;
} }
static long svm_get_hugeinfo(unsigned long __user *arg)
{
long err = -EINVAL;
struct hstate *h = &default_hstate;
struct meminfo info;
if (arg == NULL)
return err;
if (!hugepages_supported())
return -ENOTSUPP;
info.hugetlbfree = h->free_huge_pages;
info.hugetlbtotal = h->nr_huge_pages;
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
pr_info("svm get hugetlb info: order(%u), max_huge_pages(%lu),"
"nr_huge_pages(%lu), free_huge_pages(%lu), resv_huge_pages(%lu)",
h->order,
h->max_huge_pages,
h->nr_huge_pages,
h->free_huge_pages,
h->resv_huge_pages);
return 0;
}
#endif #endif
/*svm ioctl will include some case for HI1980 and HI1910*/ /*svm ioctl will include some case for HI1980 and HI1910*/
static long svm_ioctl(struct file *file, unsigned int cmd, static long svm_ioctl(struct file *file, unsigned int cmd,
...@@ -1409,6 +1446,9 @@ static long svm_ioctl(struct file *file, unsigned int cmd, ...@@ -1409,6 +1446,9 @@ static long svm_ioctl(struct file *file, unsigned int cmd,
case SVM_IOCTL_UNPIN_MEMORY: case SVM_IOCTL_UNPIN_MEMORY:
err = svm_unpin_memory((unsigned long __user *)arg); err = svm_unpin_memory((unsigned long __user *)arg);
break; break;
case SVM_IOCTL_GETHUGEINFO:
err = svm_get_hugeinfo((unsigned long __user *)arg);
break;
#endif #endif
default: default:
err = -EINVAL; err = -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册