From: Zou Nan hai <nanhai.zou@intel.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linux-IA64 <linux-ia64@vger.kernel.org>,
Tony <tony.luck@intel.com>, Kenneth W <kenneth.w.chen@intel.com>
Subject: Re: [PATCH 6/8] IA64 various hugepage size - introduce prctl options to set/get hugepage size
Date: 14 Apr 2006 08:52:33 +0800 [thread overview]
Message-ID: <1144975953.5817.102.camel@linux-znh> (raw)
In-Reply-To: <1144975746.5817.94.camel@linux-znh>
Introduce 2 prctl option to set/get hugepage size.
Signed-off-by: Zou Nan hai <nanhai.zou@intel.com>
diff -Nraup a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
--- a/arch/ia64/mm/hugetlbpage.c 2006-04-13 08:41:37.000000000 +0800
+++ b/arch/ia64/mm/hugetlbpage.c 2006-04-13 08:34:57.000000000 +0800
@@ -194,3 +194,25 @@ int is_valid_hpage_size(unsigned long lo
return 1;
}
+int set_hugepagesize(struct task_struct *task,unsigned long size)
+{
+ struct mm_struct *mm = task->mm;
+ struct vm_area_struct *vma;
+ unsigned int shift;
+ if (!is_valid_hpage_size(size))
+ return -EINVAL;
+ shift = __ffs(size);
+ if (shift == mm->hugepage_shift)
+ return 0;
+ down_write(&mm->mmap_sem);
+ for (vma = mm->mmap; vma ; vma = vma->vm_next) {
+ if (vma->vm_flags & VM_HUGETLB) {
+ up_write(&mm->mmap_sem);
+ return -EPERM;
+ }
+ }
+ mm->hugepage_shift = shift;
+ activate_mm(mm, mm);
+ up_write(&mm->mmap_sem);
+ return 0;
+}
diff -Nraup a/include/asm-ia64/page.h b/include/asm-ia64/page.h
--- a/include/asm-ia64/page.h 2006-04-13 08:41:37.000000000 +0800
+++ b/include/asm-ia64/page.h 2006-04-13 08:30:21.000000000 +0800
@@ -166,6 +166,8 @@ typedef union ia64_va {
(REGION_NUMBER(addr) == RGN_HPAGE || \
REGION_NUMBER((addr)+(len)-1) == RGN_HPAGE)
extern unsigned int init_hpage_shift;
+struct task_struct;
+extern int set_hugepagesize(struct task_struct *,unsigned long);
#endif
static __inline__ int
diff -Nraup a/include/asm-ia64/processor.h b/include/asm-ia64/processor.h
--- a/include/asm-ia64/processor.h 2006-04-13 08:41:37.000000000 +0800
+++ b/include/asm-ia64/processor.h 2006-04-13 08:30:13.000000000 +0800
@@ -211,6 +211,14 @@ typedef struct {
(int __user *) (addr)); \
})
+#ifdef CONFIG_HUGETLB_PAGE
+#define GET_HUGEPAGESIZE(task,addr) \
+({ put_user((1UL<<(task)->mm->hugepage_shift), \
+ (unsigned long __user *)(addr)); \
+})
+#define SET_HUGEPAGESIZE(task,size) set_hugepagesize(task,size)
+#endif
+
#ifdef CONFIG_IA32_SUPPORT
struct desc_struct {
unsigned int a, b;
diff -Nraup a/include/linux/prctl.h b/include/linux/prctl.h
--- a/include/linux/prctl.h 2006-03-20 13:53:29.000000000 +0800
+++ b/include/linux/prctl.h 2006-04-13 08:43:37.000000000 +0800
@@ -52,4 +52,8 @@
#define PR_SET_NAME 15 /* Set process name */
#define PR_GET_NAME 16 /* Get process name */
+/* Get/set task huge page size (if meaningful) */
+#define PR_SET_HUGEPAGE_SIZE 17
+#define PR_GET_HUGEPAGE_SIZE 18
+
#endif /* _LINUX_PRCTL_H */
diff -Nraup a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c 2006-04-13 08:41:37.000000000 +0800
+++ b/kernel/sys.c 2006-04-13 08:47:41.000000000 +0800
@@ -57,6 +57,12 @@
#ifndef GET_FPEXC_CTL
# define GET_FPEXC_CTL(a,b) (-EINVAL)
#endif
+#ifndef GET_HUGEPAGESIZE
+# define GET_HUGEPAGESIZE(a,b) (-EINVAL)
+#endif
+#ifndef SET_HUGEPAGESIZE
+# define SET_HUGEPAGESIZE(a,b) (-EINVAL)
+#endif
/*
* this is where the system-wide overflow UID and GID are defined, for
@@ -2057,6 +2063,12 @@ asmlinkage long sys_prctl(int option, un
return -EFAULT;
return 0;
}
+ case PR_SET_HUGEPAGE_SIZE:
+ error = SET_HUGEPAGESIZE(current, arg2);
+ break;
+ case PR_GET_HUGEPAGE_SIZE:
+ error = GET_HUGEPAGESIZE(current, arg2);
+ break;
default:
error = -EINVAL;
break;
next prev parent reply other threads:[~2006-04-14 2:35 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-14 0:26 [PATCH 0/8] IA64 various hugepage size - Overview Zou Nan hai
2006-04-14 0:31 ` [PATCH 1/8] IA64 various hugepage size - Add a variable to mm structure Zou Nan hai
2006-04-14 0:34 ` [PATCH 2/8] IA64 various hugepage size - Add the is_valid_hpage_size function Zou Nan hai
2006-04-14 0:41 ` [PATCH 3/8] IA64 various hugepage size - Add a mount option to hugetlbfs Zou Nan hai
2006-04-14 0:45 ` [PATCH 4/8] IA64 various hugepage size - modify HPAGE related macros Zou Nan hai
2006-04-14 0:49 ` [PATCH 5/8] IA64 various hugepage size - mount more hugetlb fs for SHM Zou Nan hai
2006-04-14 0:52 ` Zou Nan hai [this message]
2006-04-14 0:57 ` [PATCH 7/8] IA64 various hugepage size - Add proc control to reserve and free Zou Nan hai
2006-04-14 1:00 ` [PATCH 8/8] IA64 various hugepage size - Modify kernel document Zou Nan hai
2006-04-14 3:12 ` Randy.Dunlap
-- strict thread matches above, loose matches on Subject: below --
2006-04-16 0:49 [PATCH 6/8] IA64 various hugepage size - introduce prctl options to set/get hugepage size Helge Deller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1144975953.5817.102.camel@linux-znh \
--to=nanhai.zou@intel.com \
--cc=kenneth.w.chen@intel.com \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox