lkml.org 
[lkml]   [2009]   [Mar]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch 2/14] x86, mm: add release_locked_buffer_on_behalf
Allow the release of a locked buffer on behalf of another task.


Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
---

Index: git-tip/include/linux/mm.h
===================================================================
--- git-tip.orig/include/linux/mm.h 2009-03-23 16:23:19.000000000 +0100
+++ git-tip/include/linux/mm.h 2009-03-23 16:33:03.000000000 +0100
@@ -13,6 +13,7 @@
#include <linux/prio_tree.h>
#include <linux/debug_locks.h>
#include <linux/mm_types.h>
+#include <linux/sched.h>

struct mempolicy;
struct anon_vma;
@@ -1318,6 +1319,11 @@ void vmemmap_populate_print_last(void);

extern void *alloc_locked_buffer(size_t size);
extern void free_locked_buffer(void *buffer, size_t size);
-extern void release_locked_buffer(void *buffer, size_t size);
+extern void release_locked_buffer_on_behalf(struct mm_struct *mm,
+ void *buffer, size_t size);
+static inline void release_locked_buffer(void *buffer, size_t size)
+{
+ release_locked_buffer_on_behalf(current->mm, buffer, size);
+}
#endif /* __KERNEL__ */
#endif /* _LINUX_MM_H */
Index: git-tip/mm/mlock.c
===================================================================
--- git-tip.orig/mm/mlock.c 2009-03-23 16:23:19.000000000 +0100
+++ git-tip/mm/mlock.c 2009-03-23 16:24:24.000000000 +0100
@@ -660,16 +660,17 @@ void *alloc_locked_buffer(size_t size)
return buffer;
}

-void release_locked_buffer(void *buffer, size_t size)
+void release_locked_buffer_on_behalf(struct mm_struct *mm,
+ void *buffer, size_t size)
{
unsigned long pgsz = PAGE_ALIGN(size) >> PAGE_SHIFT;

- down_write(&current->mm->mmap_sem);
+ down_write(&mm->mmap_sem);

- current->mm->total_vm -= pgsz;
- current->mm->locked_vm -= pgsz;
+ mm->total_vm -= pgsz;
+ mm->locked_vm -= pgsz;

- up_write(&current->mm->mmap_sem);
+ up_write(&mm->mmap_sem);
}

void free_locked_buffer(void *buffer, size_t size)
---------------------------------------------------------------------
Intel GmbH
Dornacher Strasse 1
85622 Feldkirchen/Muenchen Germany
Sitz der Gesellschaft: Feldkirchen bei Muenchen
Geschaeftsfuehrer: Douglas Lusk, Peter Gleissner, Hannes Schwaderer
Registergericht: Muenchen HRB 47456 Ust.-IdNr.
VAT Registration No.: DE129385895
Citibank Frankfurt (BLZ 502 109 00) 600119052
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



\
 
 \ /
  Last update: 2009-03-27 10:39    [W:0.055 / U:3.848 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site