* [Adeos-main] [PATCH 1/2] ipipe: Factor out ipipe_pin_vma
@ 2012-03-29 16:38 Jan Kiszka
2012-03-31 19:32 ` Gilles Chanteperdrix
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2012-03-29 16:38 UTC (permalink / raw)
To: adeos-main
Will be used for pinning during mprotect as well.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
This applies on core-3.2, but should be backported to maintained
versions as well (just leave out the "__").
include/linux/ipipe.h | 1 +
mm/memory.c | 43 +++++++++++++++++++++++++------------------
2 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/include/linux/ipipe.h b/include/linux/ipipe.h
index 9f07346..29051c7 100644
--- a/include/linux/ipipe.h
+++ b/include/linux/ipipe.h
@@ -68,6 +68,7 @@ int __ipipe_migrate_head(void);
void __ipipe_reenter_root(void);
int __ipipe_disable_ondemand_mappings(struct task_struct *p);
+int __ipipe_pin_vma(struct mm_struct *mm, struct vm_area_struct *vma);
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
diff --git a/mm/memory.c b/mm/memory.c
index ef04820..d251268 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4092,13 +4092,31 @@ static inline int ipipe_pin_pud_range(struct mm_struct *mm, pgd_t *pgd,
return 0;
}
-int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
+int __ipipe_pin_vma(struct mm_struct *mm, struct vm_area_struct *vma)
{
unsigned long addr, next, end;
+ pgd_t *pgd;
+
+ addr = vma->vm_start;
+ end = vma->vm_end;
+
+ pgd = pgd_offset(mm, addr);
+ do {
+ next = pgd_addr_end(addr, end);
+ if (pgd_none_or_clear_bad(pgd))
+ continue;
+ if (ipipe_pin_pud_range(mm, pgd, vma, addr, next))
+ return -ENOMEM;
+ } while (pgd++, addr = next, addr != end);
+
+ return 0;
+}
+
+int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
+{
struct vm_area_struct *vma;
struct mm_struct *mm;
int result = 0;
- pgd_t *pgd;
mm = get_task_mm(tsk);
if (!mm)
@@ -4109,23 +4127,12 @@ int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
goto done_mm;
for (vma = mm->mmap; vma; vma = vma->vm_next) {
- if (!is_cow_mapping(vma->vm_flags)
- || !(vma->vm_flags & VM_WRITE))
- continue;
-
- addr = vma->vm_start;
- end = vma->vm_end;
-
- pgd = pgd_offset(mm, addr);
- do {
- next = pgd_addr_end(addr, end);
- if (pgd_none_or_clear_bad(pgd))
- continue;
- if (ipipe_pin_pud_range(mm, pgd, vma, addr, next)) {
- result = -ENOMEM;
+ if (is_cow_mapping(vma->vm_flags) &&
+ (vma->vm_flags & VM_WRITE)) {
+ result = __ipipe_pin_vma(mm, vma);
+ if (result < 0)
goto done_mm;
- }
- } while (pgd++, addr = next, addr != end);
+ }
}
set_bit(MMF_VM_PINNED, &mm->flags);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Adeos-main] [PATCH 1/2] ipipe: Factor out ipipe_pin_vma
2012-03-29 16:38 [Adeos-main] [PATCH 1/2] ipipe: Factor out ipipe_pin_vma Jan Kiszka
@ 2012-03-31 19:32 ` Gilles Chanteperdrix
2012-04-02 14:29 ` [Adeos-main] [PATCH v2 " Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Gilles Chanteperdrix @ 2012-03-31 19:32 UTC (permalink / raw)
To: Jan Kiszka; +Cc: adeos-main
On 03/29/2012 06:38 PM, Jan Kiszka wrote:
> for (vma = mm->mmap; vma; vma = vma->vm_next) {
> - if (!is_cow_mapping(vma->vm_flags)
> - || !(vma->vm_flags & VM_WRITE))
> - continue;
I prefer this style.
> (...)
> + if (is_cow_mapping(vma->vm_flags) &&
> + (vma->vm_flags & VM_WRITE)) {
> + result = __ipipe_pin_vma(mm, vma);
> + if (result < 0)
> goto done_mm;
Than this one, which uselessly cause indentation and scopes nesting.
--
Gilles.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Adeos-main] [PATCH v2 1/2] ipipe: Factor out ipipe_pin_vma
2012-03-31 19:32 ` Gilles Chanteperdrix
@ 2012-04-02 14:29 ` Jan Kiszka
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kiszka @ 2012-04-02 14:29 UTC (permalink / raw)
To: adeos-main
Will be used for pinning during mprotect as well.
Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---
include/linux/ipipe.h | 1 +
mm/memory.c | 38 +++++++++++++++++++++++---------------
2 files changed, 24 insertions(+), 15 deletions(-)
Changes in v2:
- Refactored __ipipe_disable_ondemand_mappings according to request
diff --git a/include/linux/ipipe.h b/include/linux/ipipe.h
index 9f07346..29051c7 100644
--- a/include/linux/ipipe.h
+++ b/include/linux/ipipe.h
@@ -68,6 +68,7 @@ int __ipipe_migrate_head(void);
void __ipipe_reenter_root(void);
int __ipipe_disable_ondemand_mappings(struct task_struct *p);
+int __ipipe_pin_vma(struct mm_struct *mm, struct vm_area_struct *vma);
#ifdef CONFIG_IPIPE_WANT_PREEMPTIBLE_SWITCH
diff --git a/mm/memory.c b/mm/memory.c
index ef04820..58b7f38 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4092,13 +4092,31 @@ static inline int ipipe_pin_pud_range(struct mm_struct *mm, pgd_t *pgd,
return 0;
}
-int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
+int __ipipe_pin_vma(struct mm_struct *mm, struct vm_area_struct *vma)
{
unsigned long addr, next, end;
+ pgd_t *pgd;
+
+ addr = vma->vm_start;
+ end = vma->vm_end;
+
+ pgd = pgd_offset(mm, addr);
+ do {
+ next = pgd_addr_end(addr, end);
+ if (pgd_none_or_clear_bad(pgd))
+ continue;
+ if (ipipe_pin_pud_range(mm, pgd, vma, addr, next))
+ return -ENOMEM;
+ } while (pgd++, addr = next, addr != end);
+
+ return 0;
+}
+
+int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
+{
struct vm_area_struct *vma;
struct mm_struct *mm;
int result = 0;
- pgd_t *pgd;
mm = get_task_mm(tsk);
if (!mm)
@@ -4113,19 +4131,9 @@ int __ipipe_disable_ondemand_mappings(struct task_struct *tsk)
|| !(vma->vm_flags & VM_WRITE))
continue;
- addr = vma->vm_start;
- end = vma->vm_end;
-
- pgd = pgd_offset(mm, addr);
- do {
- next = pgd_addr_end(addr, end);
- if (pgd_none_or_clear_bad(pgd))
- continue;
- if (ipipe_pin_pud_range(mm, pgd, vma, addr, next)) {
- result = -ENOMEM;
- goto done_mm;
- }
- } while (pgd++, addr = next, addr != end);
+ result = __ipipe_pin_vma(mm, vma);
+ if (result < 0)
+ goto done_mm;
}
set_bit(MMF_VM_PINNED, &mm->flags);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-02 14:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-29 16:38 [Adeos-main] [PATCH 1/2] ipipe: Factor out ipipe_pin_vma Jan Kiszka
2012-03-31 19:32 ` Gilles Chanteperdrix
2012-04-02 14:29 ` [Adeos-main] [PATCH v2 " Jan Kiszka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.