ksm - dynamic page sharing driver for linux v3
Subsystems (6)
cover ksm - dynamic page sharing driver for linux v3
Quoted 1 line
From v2 to v3:
1)Remove unnessery check of is_dirty_pte() inside PageKsm()
We have added the is_dirty_pte() chceck to protect against the
reuse: case inside do_wp_page().
Andrea pointed to me that such condtion couldnt ever happen, du to the fact that if VM_SHARED is set no Anonymous page can be on the vma, therefore it is unpossible that such Page would become KsmPage and therefore KsmPages would never trigger the reuse case (Checkout From v1 to v2 for more info)
2)Add !vm_file check in addition to PageKsm() to check if sharedpage
Until now Ksm was checking whatever Pages are sharedpages (KsmPage) by just running get_user_page() and then check if Page != AnonPage. The problem raise as Ksm keep virtual addresses inside its data strctures and if the user will free page and allocate new !AnonPage Page, Ksm might think this page is shared page.
To solve this problem we have added an additional check for Ksm, We are checking whatever the vma->vm_file is set to NULL, in case we see a virtual address that its vma->vm_file is NULL and the page that it pointing into it isnt AnonPage we can safetly know that this is shared page (KsmPage).
3)Replace jhash() with jhash2()
Andrey Panin pointed that we should use jhash2 as it faster than jhash().
Thanks.
(Below is info from previous posts)
Quoted 1 line
From v1 to v2:
1)Fixed security issue found by Chris Wright:
Ksm was checking if page is a shared page by running !PageAnon. Beacuse that Ksm scan only anonymous memory, all !PageAnons inside ksm data strctures are shared page, however there might be a case for do_wp_page() when the VM_SHARED is used where do_wp_page() would instead of copying the page into new anonymos page, would reuse the page, it was fixed by adding check for the dirty_bit of the virtual addresses pointing into the shared page. I was not finding any VM code tha would clear the dirty bit from this virtual address (due to the fact that we allocate the page using page_alloc() - kernel allocated pages), ~but i still want confirmation about this from the vm guys - thanks.~
2)Moved to sysfs to control ksm:
It was requested as a better way to control the ksm scanning thread than ioctls.
the sysfs api:
dir: /sys/kernel/mm/ksm/
kernel_pages_allocated - information about how many kernel pages ksm have allocated, this pages are not swappable, and each page like that is used by ksm to share pages with identical content
pages_shared - how many pages were shared by ksm
run - set to 1 when you want ksm to run, 0 when no
max_kernel_pages - set the maximum amount of kernel pages to be allocated by ksm, set 0 for unlimited.
pages_to_scan - how many pages to scan before ksm will sleep
sleep - how much usecs ksm will sleep.
3)Add sysfs paramater to control the maximum kernel pages to be by ksm.
4)Add statistics about how much pages are really shared.
One issue still to be discussed:
There was a suggestion to use madvice(SHAREABLE) instead of using ioctls to register memory that need to be scanned by ksm. Such change is outside the area of ksm.c and would required adding new madvice api, and change some parts of the vm and the kernel code, so first thing to do, is realized if we really want this.
I dont know any other open issues.
Thanks.
This is from the first post:
(The kvm part, togather with the kvm-userspace part, was post with V1 before about a week, whoever want to test ksm may download the patch from lkml archive)
KSM is a linux driver that allows dynamicly sharing identical memory pages between one or more processes.
Unlike tradtional page sharing that is made at the allocation of the memory, ksm do it dynamicly after the memory was created. Memory is periodically scanned; identical pages are identified and merged.
The sharing is unnoticeable by the process that use this memory. (the shared pages are marked as readonly, and in case of write do_wp_page() take care to create new copy of the page)
To find identical pages ksm use algorithm that is split into three primery levels:
1) Ksm will start scan the memory and will calculate checksum for each page that is registred to be scanned.
(In the first round of the scanning, ksm would only calculate
this checksum for all the pages)
2) Ksm will go again on the whole memory and will recalculate the checmsum of the pages, pages that are found to have the same checksum value, would be considered "pages that are most likely wont changed"
Ksm will insert this pages into sorted by page content RB-tree that is called "unstable tree", the reason that this tree is called unstable is due to the fact that the page contents might changed while they are still inside the tree, and therefore the tree would become corrupted.
Due to this problem ksm take two more steps in addition to the checksum calculation:
a) Ksm will throw and recreate the entire unstable tree each round of memory scanning - so if we have corruption, it will be fixed when we will rebuild the tree.
b) Ksm is using RB-tree, that its balancing is made by the node color and not by the content, so even if the page get corrupted, it still would take the same amount of time to search on it.
3) In addition to the unstable tree, ksm hold another tree that is called "stable tree" - this tree is RB-tree that is sorted by the pages content and all its pages are write protected, and therefore it cant get corrupted.
Each time ksm will find two identcial pages using the unstable tree, it will create new write-protected shared page, and this page will be inserted into the stable tree, and would be saved there, the stable tree, unlike the unstable tree, is never throwen away, so each page that we find would be saved inside it.
Taking into account the three levels that described above, the algorithm work like that:
search primary tree (sorted by entire page contents, pages write protected)
- if match found, merge
- if no match found...
- search secondary tree (sorted by entire page contents, pages not write protected)
- if match found, merge
- remove from secondary tree and insert merged page into primary tree
- if no match found...
- checksum
- if checksum hasn't changed
- insert into secondary tree
- if it has, store updated checksum (note: first time this page is handled it won't have a checksum, so checksum will appear as "changed", so it takes two passes w/ no other matches to get into secondary tree)
- do not insert into any tree, will see it again on next pass
The basic idea of this algorithm, is that even if the unstable tree doesnt promise to us to find two identical pages in the first round, we would probably find them in the second or the third or the tenth round, then after we have found this two identical pages only once, we will insert them into the stable tree, and then they would be protected there forever. So the all idea of the unstable tree, is just to build the stable tree and then we will find the identical pages using it.
The current implemantion can be improved alot:
we dont have to calculate exspensive checksum, we can just use the host dirty bit.
currently we dont support shared pages swapping (other pages that are not shared can be swapped (all the pages that we didnt find to be identical to other pages...).
Walking on the tree, we keep call to get_user_pages(), we can optimized it by saving the pfn, and using mmu notifiers to know when the virtual address mapping was changed.
We currently scan just programs that were registred to be used by ksm, we would later want to add the abilaty to tell ksm to scan PIDS (so you can scan closed binary applications as well).
Right now ksm scanning is made by just one thread, multiple scanners support might would be needed.
This driver is very useful for KVM as in cases of runing multiple guests operation system of the same type.
(For desktop work loads we have achived more than x2 memory overcommit (more like x3))
This driver have found users other than KVM, for example CERN, Fons Rademakers:
"on many-core machines we run one large detector simulation program per core. These simulation programs are identical but run each in their own process and need about 2 - 2.5 GB RAM.
We typically buy machines with 2GB RAM per core and so have a problem to run one of these programs per core.
Of the 2 - 2.5 GB about 700MB is identical data in the form of magnetic field maps, detector geometry, etc.
Currently people have been trying to start one program, initialize the geometry and field maps and then fork it N times, to have the data shared. With KSM this would be done automatically by the system so it sounded extremely attractive when Andrea presented it."
I am sending another seires of patchs for kvm kernel and kvm-userspace that would allow users of kvm to test ksm with it.
The kvm patchs would apply to Avi git tree.
Izik Eidus (4):
MMU_NOTIFIERS: add set_pte_at_notify()
add page_wrprotect(): write protecting page. add replace_page(): change the page pte is pointing to. add ksm kernel shared memory driver.
include/linux/ksm.h | 48 ++ include/linux/miscdevice.h | 1 + include/linux/mm.h | 5 + include/linux/mmu_notifier.h | 34 + include/linux/rmap.h | 11 + mm/Kconfig | 6 + mm/Makefile | 1 + mm/ksm.c | 1674 ++++++++++++++++++++++++++++++++++++++++++ mm/memory.c | 90 +++- mm/mmu_notifier.c | 20 + mm/rmap.c | 139 ++++ 11 files changed, 2027 insertions(+), 2 deletions(-) create mode 100644 include/linux/ksm.h create mode 100644 mm/ksm.c
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/4 MMU_NOTIFIERS: add set_pte_at_notify()
this macro allow setting the pte in the shadow page tables directly instead of flushing the shadow page table entry and then get vmexit in order to set it.
This function is optimzation for kvm/users of mmu_notifiers for COW pages, it is useful for kvm when ksm is used beacuse it allow kvm not to have to recive VMEXIT and only then map the shared page into the mmu shadow pages, but instead map it directly at the same time linux map the page into the host page table.
this mmu notifer macro is working by calling to callback that will map directly the physical page into the shadow page tables.
(users of mmu_notifiers that didnt implement the set_pte_at_notify() call back will just recive the mmu_notifier_invalidate_page callback)
--- include/linux/mmu_notifier.h | 34 ++++++++++++++++++++++++++++++++++ mm/memory.c | 10 ++++++++-- mm/mmu_notifier.c | 20 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 2 deletions(-)
include/linux/mmu_notifier.h +34 -0
@@ -61,6 +61,15 @@ struct mmu_notifier_ops {struct mm_struct *mm, unsigned long address); +/* +* change_pte is called in cases that pte mapping into page is changed +* for example when ksm mapped pte to point into a new shared page. +*/ +void (*change_pte)(struct mmu_notifier *mn, +struct mm_struct *mm, +unsigned long address, +pte_t pte); +/* * Before this is invoked any secondary MMU is still ok to * read/write to the page previously pointed to by the Linux
@@ -154,6 +163,8 @@ extern void __mmu_notifier_mm_destroy(struct mm_struct *mm);extern void __mmu_notifier_release (struct mm_struct *mm);extern int __mmu_notifier_clear_flush_young (struct mm_struct *mm,unsigned long address); +extern void __mmu_notifier_change_pte (struct mm_struct *mm, +unsigned long address,pte_t pte);extern void __mmu_notifier_invalidate_page (struct mm_struct *mm,unsigned long address); extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm,
@@ -175,6 +186,13 @@ static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,return 0 ; } +static inline void mmu_notifier_change_pte (struct mm_struct *mm, +unsigned long address,pte_t pte) +{ +if (mm_has_notifiers (mm)) +__mmu_notifier_change_pte (mm, address, pte); +} +static inline void mmu_notifier_invalidate_page (struct mm_struct *mm,unsigned long address) {
@@ -236,6 +254,16 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) __young; \ }) +#define set_pte_at_notify (__mm, __address, __ptep, __pte) \ +({ \ + struct mm_struct *___mm = __mm; \ + unsigned long ___address = __address; \ + pte_t ___pte = __pte; \ + \ + set_pte_at(__mm, __address, __ptep, ___pte); \ + mmu_notifier_change_pte(___mm, ___address, ___pte); \ +}) +#else /* CONFIG_MMU_NOTIFIER */ static inline void mmu_notifier_release (struct mm_struct *mm)
@@ -248,6 +276,11 @@ static inline int mmu_notifier_clear_flush_young(struct mm_struct *mm,return 0 ; } +static inline void mmu_notifier_change_pte (struct mm_struct *mm, +unsigned long address,pte_t pte) +{ +} +static inline void mmu_notifier_invalidate_page (struct mm_struct *mm,unsigned long address) {
@@ -273,6 +306,7 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm)#define ptep_clear_flush_young_notify ptep_clear_flush_young#define ptep_clear_flush_notify ptep_clear_flush +#define set_pte_at_notify set_pte_at#endif /* CONFIG_MMU_NOTIFIER */
mm/memory.c +8 -2
@@ -2051,9 +2051,15 @@ gotten:* seen in the presence of one thread doing SMC and another * thread doing COW. */ -ptep_clear_flush_notify (vma, address, page_table); +ptep_clear_flush (vma, address, page_table);page_add_new_anon_rmap (new_page, vma, address); -set_pte_at (mm, address, page_table, entry); +/* +* We call here the notify macro beacuse in cases of using +* secondary mmu page table like kvm shadow page, tables we want +* the new page to be mapped directly into the secondary page +* table +*/ +set_pte_at_notify (mm, address, page_table, entry);update_mmu_cache (vma, address, entry);if (old_page) {/*
mm/mmu_notifier.c +20 -0
@@ -99,6 +99,26 @@ int __mmu_notifier_clear_flush_young(struct mm_struct *mm,return young; } +void __mmu_notifier_change_pte (struct mm_struct *mm,unsigned long address, +pte_t pte) +{ +struct mmu_notifier *mn; +struct hlist_node *n; + +rcu_read_lock (); +hlist_for_each_entry_rcu (mn, n, &mm->mmu_notifier_mm->list, hlist) { +if (mn->ops->change_pte) + mn->ops->change_pte (mn, mm, address, pte); +/* +* some drivers dont have change_pte and therefor we must call +* for invalidate_page in that case +*/ +else if (mn->ops->invalidate_page) + mn->ops->invalidate_page (mn, mm, address); + } +rcu_read_unlock (); +} +void __mmu_notifier_invalidate_page (struct mm_struct *mm,unsigned long address) {
Signature · 7 lines
1.5.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/4 add page_wrprotect(): write protecting page.
this patch add new function called page_wrprotect(), page_wrprotect() is used to take a page and mark all the pte that point into it as readonly.
The function is working by walking the rmap of the page, and setting each pte realted to the page as readonly.
The odirect_sync parameter is used to protect against possible races with odirect while we are marking the pte as readonly,
as noted by Andrea Arcanglei:
"While thinking at get_user_pages_fast I figured another worse way things can go wrong with ksm and o_direct: think a thread writing constantly to the last 512bytes of a page, while another thread read and writes to/from the first 512bytes of the page. We can lose O_DIRECT reads, the very moment we mark any pte wrprotected..."
--- include/linux/rmap.h | 11 ++++ mm/rmap.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 0 deletions(-)
include/linux/rmap.h +11 -0
@@ -118,6 +118,10 @@ static inline int try_to_munlock(struct page *page) }#endif +#if defined(CONFIG_KSM ) || defined(CONFIG_KSM_MODULE ) +int page_wrprotect (struct page *page,int *odirect_sync,int count_offset); +#endif +#else /* !CONFIG_MMU */ #define anon_vma_init () do {} while (0)
@@ -132,6 +136,13 @@ static inline int page_mkclean(struct page *page) return 0; } +#if defined(CONFIG_KSM ) || defined(CONFIG_KSM_MODULE ) +static inline int page_wrprotect (struct page *page,int *odirect_sync, +int count_offset) +{ +return 0 ; +} +#endif #endif /* CONFIG_MMU */
mm/rmap.c +139 -0
145 lines not on this page · raw message
Signature · 7 lines
1.5.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/4 add replace_page(): change the page pte is pointing to.
replace_page() allow changing the mapping of pte from one physical page into diffrent physical page.
this function is working by removing oldpage from the rmap and calling put_page on it, and by setting the pte to point into newpage and by inserting it to the rmap using page_add_file_rmap().
note: newpage must be non anonymous page, the reason for this is:replace_page() is built to allow mapping one page into more than one virtual addresses, the mapping of this page can happen in diffrent offsets inside each vma, and therefore we cannot trust the page->index anymore.
the side effect of this issue is that newpage cannot be anything but kernel allocated page that is not swappable.
--- include/linux/mm.h | 5 +++ mm/memory.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 0 deletions(-)
include/linux/mm.h +5 -0
@@ -1240,6 +1240,11 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr,int vm_insert_mixed (struct vm_area_struct *vma,unsigned long addr,unsigned long pfn); +#if defined(CONFIG_KSM ) || defined(CONFIG_KSM_MODULE ) +int replace_page (struct vm_area_struct *vma,struct page *oldpage, +struct page *newpage,pte_t orig_pte,pgprot_t prot); +#endif +struct page *follow_page (struct vm_area_struct *,unsigned long address,unsigned int foll_flags);#define FOLL_WRITE 0x01/* check pte is writable */
mm/memory.c +80 -0
86 lines not on this page · raw message
Signature · 7 lines
1.5.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/4 add ksm kernel shared memory driver.
Ksm is driver that allow merging identical pages between one or more applications in way unvisible to the application that use it. Pages that are merged are marked as readonly and are COWed when any application try to change them.
Ksm is used for cases where using fork() is not suitable, one of this cases is where the pages of the application keep changing dynamicly and the application cannot know in advance what pages are going to be identical.
Ksm works by walking over the memory pages of the applications it scan in order to find identical pages.
It uses a two sorted data strctures called stable and unstable trees to find in effective way the identical pages.
When ksm finds two identical pages, it marks them as readonly and merges them into single one page,
after the pages are marked as readonly and merged into one page, linux will treat this pages as normal copy_on_write pages and will fork them when write access will happen to them.
Ksm scan just memory areas that were registred to be scanned by it.
Ksm api:
KSM_GET_API_VERSION:
Give the userspace the api version of the module.
KSM_CREATE_SHARED_MEMORY_AREA:
Create shared memory reagion fd, that latter allow the user to register the memory region to scan by using:KSM_REGISTER_MEMORY_REGION and KSM_REMOVE_MEMORY_REGION
KSM_REGISTER_MEMORY_REGION:
Register userspace virtual address range to be scanned by ksm. This ioctl is using the ksm_memory_region structure:ksm_memory_region:__u32 npages;
number of pages to share inside this memory region.__u32 pad;__u64 addr:
the begining of the virtual address of this region.__u64 reserved_bits;
reserved bits for future usage.
KSM_REMOVE_MEMORY_REGION:
Remove memory region from ksm.
--- include/linux/ksm.h | 48 ++ include/linux/miscdevice.h | 1 + mm/Kconfig | 6 + mm/Makefile | 1 + mm/ksm.c | 1674 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1730 insertions(+), 0 deletions(-) create mode 100644 include/linux/ksm.h create mode 100644 mm/ksm.c
include/linux/ksm.h new file +48 -0
@@ -0,0 +1,48 @@ +#ifndef __LINUX_KSM_H +#define __LINUX_KSM_H + +/* +* Userspace interface for /dev/ksm - kvm shared memory +*/ + +#include <linux/types.h> +#include <linux/ioctl.h> + +#include <asm/types.h> + +#define KSM_API_VERSION 1 + +#define ksm_control_flags_run 1 + +/* for KSM_REGISTER_MEMORY_REGION */ +struct ksm_memory_region { +__u32 npages;/* number of pages to share */ +__u32 pad; +__u64 addr;/* the begining of the virtual address */ +__u64 reserved_bits; +}; + +#define KSMIO 0xAB + +/* ioctls for /dev/ksm */ + +#define KSM_GET_API_VERSION _IO(KSMIO, 0x00) +/* +* KSM_CREATE_SHARED_MEMORY_AREA - create the shared memory reagion fd +*/ +#define KSM_CREATE_SHARED_MEMORY_AREA _IO(KSMIO, 0x01)/* return SMA fd */ + +/* ioctls for SMA fds */ + +/* +* KSM_REGISTER_MEMORY_REGION - register virtual address memory area to be +* scanned by kvm. +*/ +#define KSM_REGISTER_MEMORY_REGION _IOW(KSMIO, 0x20,\ + struct ksm_memory_region) +/* +* KSM_REMOVE_MEMORY_REGION - remove virtual address memory area from ksm. +*/ +#define KSM_REMOVE_MEMORY_REGION _IO(KSMIO, 0x21) + +#endif
include/linux/miscdevice.h +1 -0
@@ -30,6 +30,7 @@#define HPET_MINOR 228#define FUSE_MINOR 229#define KVM_MINOR 232 +#define KSM_MINOR 233#define MISC_DYNAMIC_MINOR 255struct device ;
mm/Kconfig +6 -0
@@ -223,3 +223,9 @@ config HAVE_MLOCKED_PAGE_BIT config MMU_NOTIFIER bool + +config KSM + tristate "Enable KSM for page sharing" + help + Enable the KSM kernel module to allow page sharing of equal pages + among different tasks.
mm/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o obj-$(CONFIG_SLOB) += slob.o obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o +obj-$(CONFIG_KSM) += ksm.o obj-$(CONFIG_PAGE_POISONING) += debug-pagealloc.o obj-$(CONFIG_SLAB) += slab.o obj-$(CONFIG_SLUB) += slub.o
mm/ksm.c new file +1674 -0
1,674 lines not on this page · raw message
Signature · 7 lines
1.5.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 45 lines · On Thu, 9 Apr 2009 06:58:41 +0300 Izik Eidus <[email protected]> wrote:
Ksm is driver that allow merging identical pages between one or more applications in way unvisible to the application that use it. Pages that are merged are marked as readonly and are COWed when any application try to change them.
Ksm is used for cases where using
fork()is not suitable, one of this cases is where the pages of the application keep changing dynamicly and the application cannot know in advance what pages are going to be identical.Ksm works by walking over the memory pages of the applications it scan in order to find identical pages.
It uses a two sorted data strctures called stable and unstable trees to find in effective way the identical pages.When ksm finds two identical pages, it marks them as readonly and merges them into single one page,
after the pages are marked as readonly and merged into one page, linux will treat this pages as normalcopy_on_writepages and will fork them when write access will happen to them.Ksm scan just memory areas that were registred to be scanned by it.
Ksm api:
KSM_GET_API_VERSION:
Give the userspace the api version of the module.
KSM_CREATE_SHARED_MEMORY_AREA:
Create shared memory reagion fd, that latter allow the user to register the memory region to scan by using:KSM_REGISTER_MEMORY_REGIONandKSM_REMOVE_MEMORY_REGION
KSM_REGISTER_MEMORY_REGION:
Register userspace virtual address range to be scanned by ksm. This ioctl is using theksm_memory_regionstructure:ksm_memory_region:__u32npages;
number of pages to share inside this memory region.__u32pad;__u64addr:
the begining of the virtual address of this region.__u64reserved_bits;
reserved bits for future usage.
Quoted 7 lines
KSM_REMOVE_MEMORY_REGION:
Remove memory region from ksm....
+/* ioctls for
/dev/ksm*/
Confused. In the covering email you indicated that v2 of the patchset had abandoned ioctls and had moved the interface to sysfs.
It would be good to completely (and briefly) describe KSM's proposed userspace intefaces in the changelog or somewhere. I'm a bit confused.
Quoted 7 lines
...
+/*
+ *slots_lockprotect against removing and adding memory regions while a scanner
+ * is in the middle of scanning.
+ */
"protects"
mm/ksm.c line 186
Quoted 9 lines
mm/ksm.c new file +9
-0+static DECLARE_RWSEM (slots_lock); + +/* The stable and unstable trees heads. */ +struct rb_root root_stable_tree =RB_ROOT ; +struct rb_root root_unstable_tree =RB_ROOT ; + + +/* The number of linked list members inside the hash table */ +static int nrmaps_hash;
A signed type doesn't seem appropriate.
Quoted 5 lines
mm/ksm.c new file +5
-0+/* rmap_hash hash table */ +static struct hlist_head *rmap_hash; + +static struct kmem_cache *tree_item_cache; +static struct kmem_cache *rmap_item_cache;
mm/ksm.c line 201
Quoted 10 lines
mm/ksm.c new file +10
-0+ +/* the number of nodes inside the stable tree */ +static unsigned long nnodes_stable_tree; + +/* the number of kernel allocated pages outside the stable tree */ +static unsigned long nkpage_out_tree; + +static int kthread_sleep;/* sleep time of the kernel thread */ +static int kthread_pages_to_scan;/* npages to scan for the kernel thread */ +static int kthread_max_kernel_pages;/* number of unswappable pages allowed */
The kthread_max_kernel_pages isn't very illuminating.
The use of "kthread" in the identifier makes is look like part of the kthread subsystem.
Quoted 24 lines
mm/ksm.c new file +21
-0+static unsigned long ksm_pages_shared; +static struct ksm_scan kthread_ksm_scan; +static int ksmd_flags; +static struct task_struct *kthread; +static DECLARE_WAIT_QUEUE_HEAD (kthread_wait); +static DECLARE_RWSEM (kthread_lock); + + +static pte_t *get_pte (struct mm_struct *mm,unsigned long addr) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *ptep =NULL ; + + pgd =pgd_offset (mm, addr); +if (!pgd_present (*pgd)) + goto out; + + pud =pud_offset (pgd, addr); +if (!pud_present (*pud))
mm/ksm.c line 289
Quoted 10 lines
mm/ksm.c new file +10
-0+ goto out; + + pmd =pmd_offset (pud, addr); +if (!pmd_present (*pmd)) + goto out; + + ptep =pte_offset_map (pmd, addr); +out: +return ptep; +}
hm, this looks very generic. Does it duplicate anything which core kernel already provides? If not, perhaps core kernel should provide this (perhaps after some reorganisation).
mm/ksm.c line 333
Quoted 10 lines
...
mm/ksm.c new file +7
-0+static int rmap_hash_init (void ) +{ +if (!rmap_hash_size) { +struct sysinfo sinfo; + +si_meminfo (&sinfo); + rmap_hash_size = sinfo.totalram /10 ;
One slot per ten pages of physical memory? Is this too large, too small or just right?
Quoted 12 lines
mm/ksm.c new file +9
-0+ } + nrmaps_hash = rmap_hash_size; + rmap_hash =vmalloc (nrmaps_hash *sizeof (struct hlist_head )); +if (!rmap_hash) +return -ENOMEM ; +memset (rmap_hash,0 , nrmaps_hash *sizeof (struct hlist_head )); +return 0 ; +} +
mm/ksm.c line 356
Quoted 10 lines
mm/ksm.c new file +10
-0+static void break_cow (struct mm_struct *mm,unsigned long addr) +{ +struct page *page[1 ]; + +down_read (&mm->mmap_sem); +if (get_user_pages (current, mm, addr,1 ,1 ,0 , page,NULL )) { +put_page (page[0 ]); + } +up_read (&mm->mmap_sem); +}
- unneeded brakes around single statement
- that single statement is over-indented.
- and it seems wrong. If get_user_pages() returned, say, -ENOMEM, we end up doing put_page(random-uninitialised-address-from-stack-go-oops)?
Quoted 24 lines
...
mm/ksm.c new file +21
-0+static int ksm_sma_ioctl_register_memory_region (struct ksm_sma *ksm_sma, +struct ksm_memory_region *mem) +{ +struct ksm_mem_slot *slot; +int ret = -EPERM ; + + slot =kzalloc (sizeof (struct ksm_mem_slot ),GFP_KERNEL ); +if (!slot) { + ret = -ENOMEM ; + goto out; + } + + slot->mm =get_task_mm (current); +if (!slot->mm) + goto out_free; + slot->addr = mem->addr; + slot->npages = mem->npages; + +down_write (&slots_lock); + +list_add_tail (&slot->link, &slots);
mm/ksm.c line 501
Quoted 10 lines
mm/ksm.c new file +10
-0+list_add_tail (&slot->sma_link, &ksm_sma->sma_slots); + +up_write (&slots_lock); +return 0 ; + +out_free: +kfree (slot); +out: +return ret; +}
So this function pins the mm_struct. I wonder what the implications of this are. Not much, I guess. Some comments in the code which explain the object lifecycles would be nice.
Quoted 6 lines
mm/ksm.c new file +6
-0+static void remove_mm_from_hash_and_tree (struct mm_struct *mm) +{ +struct ksm_mem_slot *slot; +int pages_count; + +list_for_each_entry (slot, &slots, link)
mm/ksm.c line 518
Quoted 10 lines
mm/ksm.c new file +10
-0+if (slot->mm == mm) +break ; +BUG_ON (!slot); + + root_unstable_tree =RB_ROOT ; +for (pages_count =0 ; pages_count < slot->npages; ++pages_count) +remove_page_from_tree (mm, slot->addr + + pages_count *PAGE_SIZE ); +list_del (&slot->link); +}
/* Called under slots_lock */
Quoted 5 lines
...
mm/ksm.c new file +2
-0+static int memcmp_pages (struct page *page1,struct page *page2) +{
mm/ksm.c line 584
Quoted 10 lines
mm/ksm.c new file +10
-0+char *addr1, *addr2; +int r; + + addr1 =kmap_atomic (page1,KM_USER0 ); + addr2 =kmap_atomic (page2,KM_USER1 ); + r =memcmp (addr1, addr2,PAGE_SIZE ); +kunmap_atomic (addr1,KM_USER0 ); +kunmap_atomic (addr2,KM_USER1 ); +return r; +}
I wonder if this code all does enough cpu cache flushing to be able to guarantee that it's looking at valid data. Not my area, and presumably not an issue on x86.
Quoted 31 lines
...
mm/ksm.c new file +28
-0+static int try_to_merge_one_page (struct mm_struct *mm, +struct vm_area_struct *vma, +struct page *oldpage, +struct page *newpage, +pgprot_t newprot) +{ +int ret =1 ; +int odirect_sync; +unsigned long page_addr_in_vma; +pte_t orig_pte, *orig_ptep; + +if (!PageAnon (oldpage)) + goto out; + +get_page (newpage); +get_page (oldpage); + +down_read (&mm->mmap_sem); + + page_addr_in_vma =addr_in_vma (vma, oldpage); +if (page_addr_in_vma == -EFAULT ) + goto out_unlock; + + orig_ptep =get_pte (mm, page_addr_in_vma); +if (!orig_ptep) + goto out_unlock; + orig_pte = *orig_ptep; +pte_unmap (orig_ptep);
mm/ksm.c line 643
Quoted 10 lines
mm/ksm.c new file +10
-0+if (!pte_present (orig_pte)) + goto out_unlock; +if (page_to_pfn (oldpage) !=pte_pfn (orig_pte)) + goto out_unlock; +/* +* we need the page lock to read a stable PageSwapCache in +* page_wrprotect() +*/ +if (!trylock_page (oldpage)) + goto out_unlock;
We need a comment here explaining why we can't use the much preferable lock_page().
Why can't we use the much preferable lock_page()?
Quoted 51 lines
mm/ksm.c new file +48
-0+/* +* page_wrprotect check if the page is swapped or in swap cache, +* in the future we might want to run here if_present_pte and then +* swap_free +*/ +if (!page_wrprotect (oldpage, &odirect_sync,2 )) { +unlock_page (oldpage); + goto out_unlock; + } +unlock_page (oldpage); +if (!odirect_sync) + goto out_unlock; + + orig_pte =pte_wrprotect (orig_pte); + +if (pages_identical (oldpage, newpage)) + ret =replace_page (vma, oldpage, newpage, orig_pte, newprot); + +out_unlock: +up_read (&mm->mmap_sem); +put_page (oldpage); +put_page (newpage); +out: +return ret; +} +static int try_to_merge_two_pages_alloc (struct mm_struct *mm1, +struct page *page1, +struct mm_struct *mm2, +struct page *page2, +unsigned long addr1, +unsigned long addr2) +{ +struct vm_area_struct *vma; +pgprot_t prot; +int ret =1 ; +struct page *kpage; + +/* +* The number of the nodes inside the stable tree + +* nkpage_out_tree is the same as the number kernel pages that +* we hold. +*/ +if (kthread_max_kernel_pages && + (nnodes_stable_tree + nkpage_out_tree) >= + kthread_max_kernel_pages) +return ret; + + kpage =alloc_page (GFP_HIGHUSER );
mm/ksm.c line 713
Quoted 10 lines
mm/ksm.c new file +10
-0+if (!kpage) +return ret; +down_read (&mm1->mmap_sem); + vma =find_vma (mm1, addr1); +up_read (&mm1->mmap_sem); +if (!vma) { +put_page (kpage); +return ret; + } + prot = vma->vm_page_prot;
What locking protects *vma here?
Quoted 7 lines
mm/ksm.c new file +7
-0+pgprot_val (prot) &= ~_PAGE_RW; + +copy_user_highpage (kpage, page1, addr1, vma); + ret =try_to_merge_one_page (mm1, vma, page1, kpage, prot); + +if (!ret) { +down_read (&mm2->mmap_sem);
mm/ksm.c line 730
Quoted 10 lines
mm/ksm.c new file +10
-0+ vma =find_vma (mm2, addr2); +up_read (&mm2->mmap_sem); +if (!vma) { +put_page (kpage); +break_cow (mm1, addr1); + ret =1 ; +return ret; + } + + prot = vma->vm_page_prot;
And here.
Quoted 35 lines
mm/ksm.c new file +35
-0+pgprot_val (prot) &= ~_PAGE_RW; + + ret =try_to_merge_one_page (mm2, vma, page2, kpage, + prot); +/* +* If the secoend try_to_merge_one_page call was failed, +* we are in situation where we have Ksm page that have +* just one pte pointing to it, in this case we break +* it. +*/ +if (ret) { +break_cow (mm1, addr1); + }else { + ksm_pages_shared +=2 ; + } + } + +put_page (kpage); +return ret; +} + +/* +* try_to_merge_two_pages_noalloc - the same astry_to_merge_two_pages_alloc, +* but no new kernel page is allocated (page2 should be KsmPage) +*/ +static int try_to_merge_two_pages_noalloc (struct mm_struct *mm1, +struct page *page1, +struct page *page2, +unsigned long addr1) +{ +struct vm_area_struct *vma; +pgprot_t prot; +int ret =1 ; + +/*
mm/ksm.c line 775
Quoted 10 lines
mm/ksm.c new file +10
-0+* If page2 is shared, we can just make the pte of mm1(page1) point to +* page2. +*/ +BUG_ON (!PageKsm (page2)); +down_read (&mm1->mmap_sem); + vma =find_vma (mm1, addr1); +up_read (&mm1->mmap_sem); +if (!vma) +return ret; + prot = vma->vm_page_prot;
etc.
Quoted 28 lines
mm/ksm.c new file +28
-0+pgprot_val (prot) &= ~_PAGE_RW; + ret =try_to_merge_one_page (mm1, vma, page1, page2, prot); +if (!ret) + ksm_pages_shared++; + +return ret; +} + +/* +* is_zapped_item - check if the page belong to the rmap_item was zapped. +* +* This function would check if the page that the virtual address inside +* rmap_item is poiting to is still KsmPage, and therefore we can trust the +* content of this page. +* Since that this function call already to get_user_pages it return the +* pointer to the page as an optimization. +*/ +static int is_zapped_item (struct rmap_item *rmap_item, +struct page **page) +{ +int ret =0 ; +struct vm_area_struct *vma; + +cond_resched (); +if (is_present_pte (rmap_item->mm, rmap_item->address)) { +down_read (&rmap_item->mm->mmap_sem); + vma =find_vma (rmap_item->mm, rmap_item->address); +if (vma && !vma->vm_file) {
mm/ksm.c line 813
Quoted 10 lines
mm/ksm.c new file +10
-0+BUG_ON (vma->vm_flags &VM_SHARED ); + ret =get_user_pages (current, rmap_item->mm, + rmap_item->address, +1 ,0 ,0 , page,NULL ); + } +up_read (&rmap_item->mm->mmap_sem); + } + +if (!ret) +return 1 ;
Failed to check for get_user_pages() -ve return code?
Quoted 30 lines
mm/ksm.c new file +27
-0+if (unlikely (!PageKsm (page[0 ]))) { +put_page (page[0 ]); +return 1 ; + } +return 0 ; +} + +static struct tree_item *unstable_tree_search_insert (struct page *page, +struct page **page2, +struct rmap_item *page_rmap_item) +{ +struct rb_node **new = &(root_unstable_tree.rb_node); +struct rb_node *parent =NULL ; +struct tree_item *tree_item; +struct tree_item *new_tree_item; +struct rmap_item *rmap_item; + +while (*new) { +int ret; + + tree_item = rb_entry(*new, struct tree_item, node); +BUG_ON (!tree_item); + rmap_item = tree_item->rmap_item; +BUG_ON (!rmap_item); + +/* +* We dont want to swap in pages
mm/ksm.c line 1007
Quoted 10 lines
mm/ksm.c new file +10
-0+*/ +if (!is_present_pte (rmap_item->mm, rmap_item->address)) +return NULL ; + +down_read (&rmap_item->mm->mmap_sem); + ret =get_user_pages (current, rmap_item->mm, rmap_item->address, +1 ,0 ,0 , page2,NULL ); +up_read (&rmap_item->mm->mmap_sem); +if (!ret) +return NULL ;
get_user_pages() return code..
Quoted 24 lines
mm/ksm.c new file +24
-0+ ret =memcmp_pages (page, page2[0 ]); + + parent = *new; +if (ret <0 ) { +put_page (page2[0 ]); + new = &((*new)->rb_left); + }else if (ret >0 ) { +put_page (page2[0 ]); + new = &((*new)->rb_right); + }else { +return tree_item; + } + } + +if (!page_rmap_item) +return NULL ; + + new_tree_item =alloc_tree_item (); +if (!new_tree_item) +return NULL ; + + page_rmap_item->tree_item = new_tree_item; + page_rmap_item->stable_tree =0 ; + new_tree_item->rmap_item = page_rmap_item;
mm/ksm.c
Quoted 10 lines
mm/ksm.c new file +7
-0+rb_link_node (&new_tree_item->node, parent, new); +rb_insert_color (&new_tree_item->node, &root_unstable_tree); + +return NULL ; +} + +static struct file_operations ksm_sma_fops = {
const, please.
mm/ksm.c line 1384
Quoted 13 lines
mm/ksm.c new file +13
-0+ .release = ksm_sma_release, + .unlocked_ioctl = ksm_sma_ioctl, + .compat_ioctl = ksm_sma_ioctl, +}; + +static int ksm_dev_ioctl_create_shared_memory_area (void ) +{ +int fd =-1 ; +struct ksm_sma *ksm_sma; + + ksm_sma =kmalloc (sizeof (struct ksm_sma ),GFP_KERNEL ); +if (!ksm_sma) + goto out;
This will cause a return of -1. Returniing -ENOMEM would be better.
Quoted 23 lines
mm/ksm.c new file +23
-0+ +INIT_LIST_HEAD (&ksm_sma->sma_slots); + + fd =anon_inode_getfd ("ksm-sma" , &ksm_sma_fops, ksm_sma,0 ); +if (fd <0 ) + goto out_free; + +return fd; +out_free: +kfree (ksm_sma); +out: +return fd; +} + +static long ksm_dev_ioctl (struct file *filp, +unsigned int ioctl,unsigned long arg) +{ +long r = -EINVAL ; + +switch (ioctl) { +case KSM_GET_API_VERSION : + r =KSM_API_VERSION ; +break ;
mm/ksm.c line 1417
Quoted 10 lines
mm/ksm.c new file +10
-0+case KSM_CREATE_SHARED_MEMORY_AREA : + r =ksm_dev_ioctl_create_shared_memory_area (); +break ; +default : +break ; + } +return r; +} + +static struct file_operations ksm_chardev_ops = {
const
mm/ksm.c
Quoted 8 lines
mm/ksm.c new file +5
-0+ .unlocked_ioctl = ksm_dev_ioctl, + .compat_ioctl = ksm_dev_ioctl, + .owner = THIS_MODULE, +}; +
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 8 lines · Andrew Morton
On Thu, 9 Apr 2009 06:58:41 +0300
Izik Eidus <[email protected]> wrote:Confused. In the covering email you indicated that v2 of the patchset had abandoned ioctls and had moved the interface to sysfs.
We have abandoned the ioctls that control the ksm behavior (how much cpu it take, how much kernel pages it may allocate and so on...) But we still use ioctls to register the application memory to be used with ksm.
Quoted 3 lines
It would be good to completely (and briefly) describe KSM's proposed userspace intefaces in the changelog or somewhere. I'm a bit confused.
I will post new clean description for the ksm api with V4.
Quoted 23 lines
Quoted 23 lines
mm/ksm.c new file +19
-0+static pte_t *get_pte (struct mm_struct *mm,unsigned long addr) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *ptep =NULL ; + + pgd =pgd_offset (mm, addr); +if (!pgd_present (*pgd)) + goto out; + + pud =pud_offset (pgd, addr); +if (!pud_present (*pud)) + goto out; + + pmd =pmd_offset (pud, addr); +if (!pmd_present (*pmd)) + goto out; +
Quoted 8 lines
mm/ksm.c line 289
Quoted 5 lines
mm/ksm.c new file +4
-0+ ptep =pte_offset_map (pmd, addr); +out: +return ptep; +}hm, this looks very generic. Does it duplicate anything which core kernel already provides?
I dont think so.
Quoted 3 lines
If not, perhaps core kernel should provide
this (perhaps after some reorganisation).
Quick grep on the code show me at least 2 places that can use this function one is:remove_migration_pte() inside migrate.c
and the other is:page_check_address() inside rmap.c
I will post with V4 an inline get_ptep() function, worst case i will get nacked.
Quoted 15 lines
mm/ksm.c line 333
Quoted 11 lines
...
mm/ksm.c new file +7
-0+static int rmap_hash_init (void ) +{ +if (!rmap_hash_size) { +struct sysinfo sinfo; + +si_meminfo (&sinfo); + rmap_hash_size = sinfo.totalram /10 ;One slot per ten pages of physical memory? Is this too large, too small or just right?
Highly depend on the number of processes / memory regions that will be registered inside ksm It is a module parameter and so user can change it to how much it want.
Quoted 27 lines
Quoted 14 lines
mm/ksm.c new file +9
-0+ } + nrmaps_hash = rmap_hash_size; + rmap_hash =vmalloc (nrmaps_hash *sizeof (struct hlist_head )); +if (!rmap_hash) +return -ENOMEM ; +memset (rmap_hash,0 , nrmaps_hash *sizeof (struct hlist_head )); +return 0 ; +} +mm/ksm.c line 356
Quoted 10 lines
mm/ksm.c new file +10
-0+static void break_cow (struct mm_struct *mm,unsigned long addr) +{ +struct page *page[1 ]; + +down_read (&mm->mmap_sem); +if (get_user_pages (current, mm, addr,1 ,1 ,0 , page,NULL )) { +put_page (page[0 ]); + } +up_read (&mm->mmap_sem); +}- unneeded brakes around single statement
Quoted 5 lines
- that single statement is over-indented.
- and it seems wrong. If
get_user_pages()returned, say,-ENOMEM, we end up doingput_page(random-uninitialised-address-from-stack-go-oops)?
Good catch.
Quoted 30 lines
Quoted 30 lines
...
mm/ksm.c new file +27
-0+static int ksm_sma_ioctl_register_memory_region (struct ksm_sma *ksm_sma, +struct ksm_memory_region *mem) +{ +struct ksm_mem_slot *slot; +int ret = -EPERM ; + + slot =kzalloc (sizeof (struct ksm_mem_slot ),GFP_KERNEL ); +if (!slot) { + ret = -ENOMEM ; + goto out; + } + + slot->mm =get_task_mm (current); +if (!slot->mm) + goto out_free; + slot->addr = mem->addr; + slot->npages = mem->npages; + +down_write (&slots_lock); + +list_add_tail (&slot->link, &slots); +list_add_tail (&slot->sma_link, &ksm_sma->sma_slots); + +up_write (&slots_lock); +return 0 ; + +out_free:
Quoted 8 lines
mm/ksm.c line 501
Quoted 5 lines
mm/ksm.c new file +4
-0+kfree (slot); +out: +return ret; +}So this function pins the
mm_struct. I wonder what the implications of this are.
The mm struct wont go away until the file will be closed... (Application close the file descriptor, or the Application die)
Quoted 16 lines
Not much, I guess. Some comments in the code which explain
the object lifecycles would be nice.Quoted 11 lines
...
mm/ksm.c new file +9
-0+static int memcmp_pages (struct page *page1,struct page *page2) +{ +char *addr1, *addr2; +int r; + + addr1 =kmap_atomic (page1,KM_USER0 ); + addr2 =kmap_atomic (page2,KM_USER1 ); + r =memcmp (addr1, addr2,PAGE_SIZE ); +kunmap_atomic (addr1,KM_USER0 );
Quoted 9 lines
mm/ksm.c line 584
Quoted 4 lines
mm/ksm.c new file +3
-0+kunmap_atomic (addr2,KM_USER1 ); +return r; +}I wonder if this code all does enough cpu cache flushing to be able to guarantee that it's looking at valid data. Not my area, and presumably not an issue on x86.
Andrea pointed in previous reply that due to the fact that we are running page_wrprotect() on this pages memcmp_pages should be stable.
Quoted 46 lines
Quoted 32 lines
...
mm/ksm.c new file +28
-0+static int try_to_merge_one_page (struct mm_struct *mm, +struct vm_area_struct *vma, +struct page *oldpage, +struct page *newpage, +pgprot_t newprot) +{ +int ret =1 ; +int odirect_sync; +unsigned long page_addr_in_vma; +pte_t orig_pte, *orig_ptep; + +if (!PageAnon (oldpage)) + goto out; + +get_page (newpage); +get_page (oldpage); + +down_read (&mm->mmap_sem); + + page_addr_in_vma =addr_in_vma (vma, oldpage); +if (page_addr_in_vma == -EFAULT ) + goto out_unlock; + + orig_ptep =get_pte (mm, page_addr_in_vma); +if (!orig_ptep) + goto out_unlock; + orig_pte = *orig_ptep; +pte_unmap (orig_ptep);mm/ksm.c line 643
Quoted 10 lines
mm/ksm.c new file +10
-0+if (!pte_present (orig_pte)) + goto out_unlock; +if (page_to_pfn (oldpage) !=pte_pfn (orig_pte)) + goto out_unlock; +/* +* we need the page lock to read a stable PageSwapCache in +* page_wrprotect() +*/ +if (!trylock_page (oldpage)) + goto out_unlock;We need a comment here explaining why we can't use the much preferable
lock_page().
Quoted 2 lines
Why can't we use the much preferable
lock_page()?
We can, but i am not sure if we want, why block on I/O when we can just move into the next page? (We will come to this page latter...)
Quoted 57 lines
Quoted 57 lines
mm/ksm.c new file +53
-0+/* +* page_wrprotect check if the page is swapped or in swap cache, +* in the future we might want to run here if_present_pte and then +* swap_free +*/ +if (!page_wrprotect (oldpage, &odirect_sync,2 )) { +unlock_page (oldpage); + goto out_unlock; + } +unlock_page (oldpage); +if (!odirect_sync) + goto out_unlock; + + orig_pte =pte_wrprotect (orig_pte); + +if (pages_identical (oldpage, newpage)) + ret =replace_page (vma, oldpage, newpage, orig_pte, newprot); + +out_unlock: +up_read (&mm->mmap_sem); +put_page (oldpage); +put_page (newpage); +out: +return ret; +} +static int try_to_merge_two_pages_alloc (struct mm_struct *mm1, +struct page *page1, +struct mm_struct *mm2, +struct page *page2, +unsigned long addr1, +unsigned long addr2) +{ +struct vm_area_struct *vma; +pgprot_t prot; +int ret =1 ; +struct page *kpage; + +/* +* The number of the nodes inside the stable tree + +* nkpage_out_tree is the same as the number kernel pages that +* we hold. +*/ +if (kthread_max_kernel_pages && + (nnodes_stable_tree + nkpage_out_tree) >= + kthread_max_kernel_pages) +return ret; + + kpage =alloc_page (GFP_HIGHUSER ); +if (!kpage) +return ret; +down_read (&mm1->mmap_sem); + vma =find_vma (mm1, addr1); +up_read (&mm1->mmap_sem);
Quoted 9 lines
mm/ksm.c line 713
Quoted 6 lines
mm/ksm.c new file +5
-0+if (!vma) { +put_page (kpage); +return ret; + } + prot = vma->vm_page_prot;What locking protects *vma here?
Good catch.
Quoted 36 lines
Quoted 36 lines
mm/ksm.c new file +33
-0+pgprot_val (prot) &= ~_PAGE_RW; + ret =try_to_merge_one_page (mm1, vma, page1, page2, prot); +if (!ret) + ksm_pages_shared++; + +return ret; +} + +/* +* is_zapped_item - check if the page belong to the rmap_item was zapped. +* +* This function would check if the page that the virtual address inside +* rmap_item is poiting to is still KsmPage, and therefore we can trust the +* content of this page. +* Since that this function call already to get_user_pages it return the +* pointer to the page as an optimization. +*/ +static int is_zapped_item (struct rmap_item *rmap_item, +struct page **page) +{ +int ret =0 ; +struct vm_area_struct *vma; + +cond_resched (); +if (is_present_pte (rmap_item->mm, rmap_item->address)) { +down_read (&rmap_item->mm->mmap_sem); + vma =find_vma (rmap_item->mm, rmap_item->address); +if (vma && !vma->vm_file) { +BUG_ON (vma->vm_flags &VM_SHARED ); + ret =get_user_pages (current, rmap_item->mm, + rmap_item->address, +1 ,0 ,0 , page,NULL ); + }
Quoted 9 lines
mm/ksm.c line 813
Quoted 6 lines
mm/ksm.c new file +5
-0+up_read (&rmap_item->mm->mmap_sem); + } + +if (!ret) +return 1 ;Failed to check for
get_user_pages()-ve return code?
Right.
Quoted 85 lines
Quoted 32 lines
mm/ksm.c new file +27
-0+if (unlikely (!PageKsm (page[0 ]))) { +put_page (page[0 ]); +return 1 ; + } +return 0 ; +} + +static struct tree_item *unstable_tree_search_insert (struct page *page, +struct page **page2, +struct rmap_item *page_rmap_item) +{ +struct rb_node **new = &(root_unstable_tree.rb_node); +struct rb_node *parent =NULL ; +struct tree_item *tree_item; +struct tree_item *new_tree_item; +struct rmap_item *rmap_item; + +while (*new) { +int ret; + + tree_item = rb_entry(*new, struct tree_item, node); +BUG_ON (!tree_item); + rmap_item = tree_item->rmap_item; +BUG_ON (!rmap_item); + +/* +* We dont want to swap in pages mm/ksm.c line 1007
Quoted 10 lines
mm/ksm.c new file +10
-0+*/ +if (!is_present_pte (rmap_item->mm, rmap_item->address)) +return NULL ; + +down_read (&rmap_item->mm->mmap_sem); + ret =get_user_pages (current, rmap_item->mm, rmap_item->address, +1 ,0 ,0 , page2,NULL ); +up_read (&rmap_item->mm->mmap_sem); +if (!ret) +return NULL ;
get_user_pages()return code..Quoted 25 lines
mm/ksm.c new file +24
-0+ ret =memcmp_pages (page, page2[0 ]); + + parent = *new; +if (ret <0 ) { +put_page (page2[0 ]); + new = &((*new)->rb_left); + }else if (ret >0 ) { +put_page (page2[0 ]); + new = &((*new)->rb_right); + }else { +return tree_item; + } + } + +if (!page_rmap_item) +return NULL ; + + new_tree_item =alloc_tree_item (); +if (!new_tree_item) +return NULL ; + + page_rmap_item->tree_item = new_tree_item; + page_rmap_item->stable_tree =0 ; + new_tree_item->rmap_item = page_rmap_item;mm/ksm.c
Quoted 10 lines
mm/ksm.c new file +7
-0+rb_link_node (&new_tree_item->node, parent, new); +rb_insert_color (&new_tree_item->node, &root_unstable_tree); + +return NULL ; +} + +static struct file_operations ksm_sma_fops = {const, please.
Quoted 17 lines
Quoted 4 lines
mm/ksm.c new file +3
-0+ .release = ksm_sma_release, + .unlocked_ioctl = ksm_sma_ioctl, + .compat_ioctl = ksm_sma_ioctl,mm/ksm.c line 1384
Quoted 10 lines
mm/ksm.c new file +10
-0+}; + +static int ksm_dev_ioctl_create_shared_memory_area (void ) +{ +int fd =-1 ; +struct ksm_sma *ksm_sma; + + ksm_sma =kmalloc (sizeof (struct ksm_sma ),GFP_KERNEL ); +if (!ksm_sma) + goto out;This will cause a return of -1. Returniing
-ENOMEMwould be better.
Right.
Thanks for the review i will cock V4 will test it and send it.
Thanks.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 6 lines · On Thu, 16 Apr 2009 01:37:25 +0300 Izik Eidus <[email protected]> wrote:
Quoted 5 lines · Andrew Morton
On Thu, 9 Apr 2009 06:58:41 +0300
Izik Eidus <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines
Confused. In the covering email you indicated that v2 of the patchset had abandoned ioctls and had moved the interface to sysfs.
We have abandoned the ioctls that control the ksm behavior (how much cpu it take, how much kernel pages it may allocate and so on...) But we still use ioctls to register the application memory to be used with ksm.
hm. ioctls make kernel people weep and gnash teeth.
An appropriate interface would be to add new syscalls. But as ksm is an optional thing and can even be modprobed, that doesn't work. And having a driver in mm/ which can be modprobed is kinda neat.
I can't immediately think of a nicer interface. You could always poke numbers into some pseudo-file but to me that seems as ugly, or uglier than an ioctl (others seem to disagee).
Ho hum. Please design the ioctl interface so that it doesn't need any compat handling if poss.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 2 lines · Andrew Morton
an optional thing and can even be modprobed, that doesn't work. And having a driver in
mm/which can be modprobed is kinda neat.
Agreed. I think madvise with all its vma split requirements and ksm-unregistering invoked at vma destruction time (under CONFIG_KSM || CONFIG_KSM_MODULE) is clean approach only if ksm is considered a piece of the core kernel VM. As long as only certain users out there use ksm (i.e. only virtualization servers and LHC computations) the pseduochar ioctl interface keeps it out of the kernel, so core kernel MM API remains almost unaffected by ksm.
It's kinda neat it's external as self-contained module, but the whole point is that to be self-contained it has to use ioctl.
Another thing is that madvise usually doesn't require mangling sysfs to be effective. madvise without enabling ksm with sysfs would be entirely useless. So doing it as madvise that returns success and has no effect unless 'root' does something, is kind of weird.
Thinking about the absolute worst case: if this really turns out to be wrong decision, simply /dev/ksm won't exist anymore and no app could ever break as they will graceful handle the missing pseudochar. They won't run the ioctl and just continue like if ksm.ko wasn't loaded. As there are only a few (but critically important) apps using KSM, converting them to fallback on madvise is a few liner trivial change (kvm-userland will have 10 more lines to keep opening /dev/ksm before calling madvise if we ever later decide KSM has to become a VM core kernel functionality with madvise or its own per-arch syscall).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
In reply to Andrew MortonQuoted 20 lines · Andrew Morton
Quoted 20 lines
mm/ksm.c new file +20
-0+static pte_t *get_pte (struct mm_struct *mm,unsigned long addr) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *ptep =NULL ; + + pgd =pgd_offset (mm, addr); +if (!pgd_present (*pgd)) + goto out; + + pud =pud_offset (pgd, addr); +if (!pud_present (*pud)) + goto out; + + pmd =pmd_offset (pud, addr); +if (!pmd_present (*pmd)) + goto out; + + ptep =pte_offset_map (pmd, addr);
Quoted 9 lines
mm/ksm.c line 289
Quoted 4 lines
mm/ksm.c new file +3
-0+out: +return ptep; +}hm, this looks very generic. Does it duplicate anything which core kernel already provides? If not, perhaps core kernel should provide this (perhaps after some reorganisation).
It is lookup_address() which works on user addresses, and as such is very useful. But it would need to deal with returning a level so it can deal with large pages in usermode, and have some well-defined semantics on whether the caller is responsible for unmapping the returned thing (ie, only if its a pte).
I implemented this myself a couple of months ago, but I can't find it anywhere...
Quoted 9 lines
Quoted 9 lines
mm/ksm.c new file +9
-0+static int memcmp_pages (struct page *page1,struct page *page2) +{ +char *addr1, *addr2; +int r; + + addr1 =kmap_atomic (page1,KM_USER0 ); + addr2 =kmap_atomic (page2,KM_USER1 ); + r =memcmp (addr1, addr2,PAGE_SIZE ); +kunmap_atomic (addr1,KM_USER0 );
Quoted 9 lines
mm/ksm.c line 584
Quoted 4 lines
mm/ksm.c new file +3
-0+kunmap_atomic (addr2,KM_USER1 ); +return r; +}I wonder if this code all does enough cpu cache flushing to be able to guarantee that it's looking at valid data. Not my area, and presumably not an issue on x86.
Shouldn't that be kmap_atomic's job anyway? Otherwise it would be hard to use on any virtual-tag/indexed cache machine.
J
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 31 lines · Jeremy Fitzhardinge
Quoted 20 lines · Andrew Morton
Quoted 20 lines
mm/ksm.c new file +20
-0+static pte_t *get_pte (struct mm_struct *mm,unsigned long addr) +{ +pgd_t *pgd; +pud_t *pud; +pmd_t *pmd; +pte_t *ptep =NULL ; + + pgd =pgd_offset (mm, addr); +if (!pgd_present (*pgd)) + goto out; + + pud =pud_offset (pgd, addr); +if (!pud_present (*pud)) + goto out; + + pmd =pmd_offset (pud, addr); +if (!pmd_present (*pmd)) + goto out; + + ptep =pte_offset_map (pmd, addr);Quoted 9 lines
mm/ksm.c line 289
Quoted 4 lines
mm/ksm.c new file +3
-0+out: +return ptep; +}hm, this looks very generic. Does it duplicate anything which core kernel already provides? If not, perhaps core kernel should provide this (perhaps after some reorganisation).
Quoted 1 line
It is
lookup_address()which works on user addresses, and as such is very useful.
But ksm need the pgd offset of an mm struct, not the kernel pgd, so maybe changing it to get the pgd offset would be nice..
Another thing it is just for x86 right now, so probably it need to go out to the common code
Quoted 23 lines
But it would need to deal with returning a level so it can deal with large pages in usermode, and have some well-defined semantics on whether the caller is responsible for unmapping the returned thing (ie, only if its a pte).
I implemented this myself a couple of months ago, but I can't find it anywhere...
Quoted 9 lines
Quoted 9 lines
mm/ksm.c new file +9
-0+static int memcmp_pages (struct page *page1,struct page *page2) +{ +char *addr1, *addr2; +int r; + + addr1 =kmap_atomic (page1,KM_USER0 ); + addr2 =kmap_atomic (page2,KM_USER1 ); + r =memcmp (addr1, addr2,PAGE_SIZE ); +kunmap_atomic (addr1,KM_USER0 );Quoted 9 lines
mm/ksm.c line 584
Quoted 4 lines
mm/ksm.c new file +3
-0+kunmap_atomic (addr2,KM_USER1 ); +return r; +}I wonder if this code all does enough cpu cache flushing to be able to guarantee that it's looking at valid data. Not my area, and presumably not an issue on x86.
Quoted 3 lines
Shouldn't that be kmap_atomic's job anyway? Otherwise it would be hard to use on any virtual-tag/indexed cache machine.
J
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
In reply to Jeremy FitzhardingeQuoted 1 line · Jeremy Fitzhardinge
Shouldn't that be kmap_atomic's job anyway? Otherwise it would be hard to
No because those are full noops in no-highmem kernels. I commented in other email why I think it's safe thanks to the wrprotect + smp tlb flush of the userland PTE.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
Quoted 9 lines · Andrea Arcangeli
Quoted 2 lines · Jeremy Fitzhardinge
Shouldn't that be kmap_atomic's job anyway? Otherwise it would be hard to
No because those are full noops in no-highmem kernels. I commented in other email why I think it's safe thanks to the wrprotect + smp tlb flush of the userland PTE.
I think Andrew's query was about data cache synchronization in architectures with virtually indexed d-cache. On x86 it's a non-issue, but on architectures for which it is an issue, I assume kmap_atomic does any necessary cache flushes, as it does tlb flushes on x86 (which may be none at all, if no mapping actually happens).
J
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/4] add ksm kernel shared memory driver.
In reply to Andrew MortonQuoted 4 lines · Andrew Morton
We need a comment here explaining why we can't use the much preferable
lock_page().Why can't we use the much preferable
lock_page()?
We might but then it'd risk to waste time waiting. It's not worth waiting, we want kksmd to be allowed to keep one (in future more than one as we scale it smp/numa) CPU busy at all times running memcmp and not schedule (other than for need_resched()) to try to free memory at the fastest peace possible.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerRe: [PATCH 3/4] add replace_page(): change the page pte is pointing to.
In reply to Izik EidusQuoted 2 lines · On Thu, 9 Apr 2009 06:58:40 +0300 Izik Eidus <[email protected]> wrote:
replace_page()allow changing the mapping of pte from one physical page into diffrent physical page.
At a high level, this is very similar to what page migration does. Yet this implementation shares nothing with the page migration code.
Can this situation be improved?
Quoted 4 lines
this function is working by removing oldpage from the rmap and calling
put_pageon it, and by setting the pte to point into newpage and by inserting it to the rmap usingpage_add_file_rmap().
Quoted 9 lines
note: newpage must be non anonymous page, the reason for this is:
replace_page()is built to allow mapping one page into more than one virtual addresses, the mapping of this page can happen in diffrent offsets inside each vma, and therefore we cannot trust thepage->indexanymore.the side effect of this issue is that newpage cannot be anything but kernel allocated page that is not swappable.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] add replace_page(): change the page pte is pointing to.
Quoted 10 lines · Andrew Morton
Quoted 2 lines · On Thu, 9 Apr 2009 06:58:40 +0300 Izik Eidus <[email protected]> wrote:
replace_page()allow changing the mapping of pte from one physical page into diffrent physical page.At a high level, this is very similar to what page migration does. Yet this implementation shares nothing with the page migration code.
Can this situation be improved?
This was discussed last time too. Basically the thing is that using migration entry with its special page fault paths, for this looks a bit of an overkill complexity and unnecessary dependency on the migration code. All we need is to mark the pte readonly. replace_page is a no brainer then. The brainer part is page_wrprotect (page_wrprotect is like fork).
The data visibility in the final memcmp you mentioned in the other mail is supposedly taken care of by page_wrprotect too. It already does flush_cache_page for the virtual indexed and not physically tagged caches. page_wrprotect has to also IPI all CPUs to nuke any not wrprotected tlb entry. I don't think we need further smp memory barriers when we're guaranteed all tlb entries are wrprotected in the other cpus and an IPI and invlpg run in them, to be sure we read the data stable during memcmp even if we read through the kernel pagetables and the last userland write happened through userland ptes before they become effective wrprotected by the IPI.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/4] add replace_page(): change the page pte is pointing to.
Quoted 12 lines · Andrea Arcangeli
Quoted 10 lines · Andrew Morton
Quoted 3 lines · On Thu, 9 Apr 2009 06:58:40 +0300 Izik Eidus <[email protected]> wrote:
replace_page()allow changing the mapping of pte from one physical page into diffrent physical page.At a high level, this is very similar to what page migration does. Yet this implementation shares nothing with the page migration code.
Quoted 7 lines
Quoted 2 lines
Can this situation be improved?
This was discussed last time too. Basically the thing is that using migration entry with its special page fault paths, for this looks a bit of an overkill complexity and unnecessary dependency on the migration code.
I agree about that.
Quoted 4 lines
All we need is to mark the pte readonly.
replace_pageis a no brainer then. The brainer part ispage_wrprotect(page_wrprotectis like fork).
Quoted 11 lines
The data visibility in the final memcmp you mentioned in the other mail is supposedly taken care of by
page_wrprotecttoo. It already doesflush_cache_pagefor the virtual indexed and not physically tagged caches.page_wrprotecthas to also IPI all CPUs to nuke any not wrprotected tlb entry. I don't think we need further smp memory barriers when we're guaranteed all tlb entries are wrprotected in the other cpus and an IPI and invlpg run in them, to be sure we read the data stable during memcmp even if we read through the kernel pagetables and the last userland write happened through userland ptes before they become effective wrprotected by the IPI.
Yup agree.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 2 lines · On Thu, 9 Apr 2009 06:58:37 +0300 Izik Eidus <[email protected]> wrote:
KSM is a linux driver that allows dynamicly sharing identical memory pages between one or more processes.
Generally looks OK to me. But that doesn't mean much. We should rub bottles with words like "hugh" and "nick" on them to be sure.
Quoted 14 lines
...
include/linux/ksm.h | 48 ++ include/linux/miscdevice.h | 1 + include/linux/mm.h | 5 + include/linux/mmu_notifier.h | 34 + include/linux/rmap.h | 11 + mm/Kconfig | 6 + mm/Makefile | 1 + mm/ksm.c | 1674 ++++++++++++++++++++++++++++++++++++++++++ mm/memory.c | 90 +++- mm/mmu_notifier.c | 20 + mm/rmap.c | 139 ++++
And it's pretty unobtrusive for what it is. I expect we can get this into 2.6.31 unless there are some pratfalls which I missed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 8 lines · On Wednesday 15 April 2009 08:09:03 Andrew Morton wrote:
Quoted 2 lines · On Thu, 9 Apr 2009 06:58:37 +0300 Izik Eidus <[email protected]> wrote:
KSM is a linux driver that allows dynamicly sharing identical memory pages between one or more processes.
Generally looks OK to me. But that doesn't mean much. We should rub bottles with words like "hugh" and "nick" on them to be sure.
I haven't looked too closely at it yet sorry. Hugh has a great eye for these details, though, hint hint :)
As everyone knows, my favourite thing is to say nasty things about any new feature that adds complexity to common code. I feel like crying to hear about how many more instances of MS Office we can all run, if only we apply this patch. And the poorly written HPC app just sounds like scrapings from the bottom of justification barrel.
I'm sorry, maybe I'm way off with my understanding of how important this is. There isn't too much help in the changelog. A discussion of where the memory savings comes from, and how far does things like sharing of fs image, or ballooning goes and how much extra savings we get from this... with people from other hypervisors involved as well. Have I missed this kind of discussion?
Careful what you wish for, ay? :)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · Nick Piggin
Quoted 10 lines · On Wednesday 15 April 2009 08:09:03 Andrew Morton wrote:
Quoted 3 lines · On Thu, 9 Apr 2009 06:58:37 +0300 Izik Eidus <[email protected]> wrote:
KSM is a linux driver that allows dynamicly sharing identical memory pages between one or more processes.
Generally looks OK to me. But that doesn't mean much. We should rub bottles with words like "hugh" and "nick" on them to be sure.
Quoted 5 lines
I haven't looked too closely at it yet sorry. Hugh has a great eye for these details, though, hint hint :)
As everyone knows, my favourite thing is to say nasty things about any new feature that adds complexity to common code.
The whole idea and the way i wrote it so it wont touch common code, i didnt change the linux mm logic no where. The worst thing that we have add is helper functions.
Quoted 3 lines
I feel like crying to
hear about how many more instances of MS Office we can all run, if only we apply this patch.
And more instances of linux guests...
Quoted 3 lines
And the poorly written HPC app just sounds like
scrapings from the bottom of justification barrel.
So if you have a big rendering application that load gigas of geometrical data that is handled by many threads
and you have a case that each thread sometimes change this geometrical data and you dont want the other threads will notice it. How would you share it in traditional way?, after one time shared data will get cowed, how will you recollect it again when it become identical? KSM do it for applications transparently
KSM writing motivation indeed was KVM where there it is highly needed you may check what VMware say about the fact that they have much better overcommit than Hyper-V / XEN:
http://blogs.vmware.com/virtualreality/2008/03/cheap-hyperviso.html
It is important to understand that in virtualization enviorments there are cases where memory is much more critical than any other resource for higher density.
Together with KSM, KVM will have the same memory overcommit abilitys such as VMware have.
Quoted 3 lines
I'm sorry, maybe I'm way off with my understanding of how important this is. There isn't too much help in the changelog. A discussion of where the memory savings comes from,
Memory saving come from identical librarys, identical kernels, zeroed pages -> that is for virtualization. The Librarys code will always be identical among similar guests, so why have this code at multiple places on the host memory?
Quoted 3 lines
and how far does things like
sharing of fs image, or ballooning goes and how much extra savings we get from this...
Ballooning is much worse when it come to performance, beacuse what it does is shrink the guest memory, with KSM we find identical pages and merge them into one page, so we dont get guest performance lose
Quoted 5 lines
with people from other hypervisors involved as well.
Have I missed this kind of discussion?Careful what you wish for, ay? :)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines
As everyone knows, my favourite thing is to say nasty things about any new feature that adds complexity to common code. I feel like crying to hear about how many more instances of MS Office we can all run, if only we apply this patch. And the poorly written HPC app just sounds like scrapings from the bottom of justification barrel.
Quoted 6 lines
I'm sorry, maybe I'm way off with my understanding of how important this is. There isn't too much help in the changelog. A discussion of where the memory savings comes from, and how far does things like sharing of fs image, or ballooning goes and how much extra savings we get from this... with people from other hypervisors involved as well. Have I missed this kind of discussion?
Nick,
I don't know about other hypervisors, fs and balloonings, but I have tried this out. It works. It works on apps I don't consider, "poorly written". I'm very excited about this. I got >10% saving in a roughly off the shelf embedded system. No user noticeable performance impact.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · On Friday 17 April 2009 17:08:07 Jared Hulbert wrote:
Quoted 6 lines
As everyone knows, my favourite thing is to say nasty things about any new feature that adds complexity to common code. I feel like crying to hear about how many more instances of MS Office we can all run, if only we apply this patch. And the poorly written HPC app just sounds like scrapings from the bottom of justification barrel.
Quoted 6 lines
I'm sorry, maybe I'm way off with my understanding of how important this is. There isn't too much help in the changelog. A discussion of where the memory savings comes from, and how far does things like sharing of fs image, or ballooning goes and how much extra savings we get from this... with people from other hypervisors involved as well. Have I missed this kind of discussion?
Quoted 7 lines
Nick,
I don't know about other hypervisors, fs and balloonings, but I have tried this out. It works. It works on apps I don't consider, "poorly written". I'm very excited about this. I got >10% saving in a roughly off the shelf embedded system. No user noticeable performance impact.
OK well that's what I want to hear. Thanks, that means a lot to me.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>