Last active
September 26, 2015 17:15
-
-
Save fcangialosi/4cb63f55e232457ddbff to your computer and use it in GitHub Desktop.
Small modification to linux kernel (v3.13.0) that adds *which* pages have been accessed to the /proc/pid/smaps interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
267c267,269 | |
< struct inode *inode = file_inode(vma->vm_file); | |
--- | |
> struct inode *inode; | |
> file = vma_pr_or_file(vma); | |
> inode = file_inode(file); | |
440a443,457 | |
> #define MAX_REF_BUFF 4096 | |
> #define END_OF_REF_BUFFER -1 | |
> static unsigned long *referenced_list; | |
> static int reference_pos; | |
> static int add_to_referenced_list(unsigned long addr) { | |
> if (!referenced_list) { | |
> printk("<1> ERROR REFERENCED LIST DOES NOT EXIST YET.\n"); | |
> } | |
> referenced_list[reference_pos++] = addr; | |
> if (reference_pos >= MAX_REF_BUFF) { | |
> return END_OF_REF_BUFFER; | |
> } | |
> return reference_pos; | |
> } | |
> | |
475c492 | |
< if (pte_young(ptent) || PageReferenced(page)) | |
--- | |
> if (pte_young(ptent) || PageReferenced(page)) { | |
476a494,495 | |
> add_to_referenced_list(addr); | |
> } | |
519a539 | |
> | |
587a608,615 | |
> int i = 0; | |
> | |
> referenced_list = (unsigned long *) kmalloc(MAX_REF_BUFF, GFP_TEMPORARY); | |
> if (!referenced_list) { | |
> printk("<1>ERROR ALLOCATING MEMORY FOR REFERENCED LIST\n"); | |
> return -1; | |
> } | |
> reference_pos = 0; | |
596a625,632 | |
> | |
> seq_printf(m, "Ref_Addrs: ["); | |
> for (i = 0; i < reference_pos; i++) { | |
> seq_printf(m, "%lx,", referenced_list[i]); | |
> } | |
> seq_printf(m, "]\n"); | |
> | |
> | |
636a673,675 | |
> if (referenced_list) { | |
> kfree(referenced_list); | |
> } | |
892c931,935 | |
< #define __PM_SOFT_DIRTY (1LL) | |
--- | |
> #define __PM_SOFT_DIRTY (1LL) | |
> /* F0215-------------------------------------------------------------------- */ | |
> #define __PM_YOUNG (1LL << 60) | |
> /* ------------------------------------------------------------------------- */ | |
> | |
912a956,959 | |
> /* F0215 ------------------------------------------------------------------- */ | |
> //static int add_to_ref_list(unsigned long addr, void *buffer, | |
> /* ------------------------------------------------------------------------- */ | |
> | |
939a987,991 | |
> /* F0215----------------------------------------------------- */ | |
> if (pte_young(pte) || PageReferenced(page)) { | |
> flags |= __PM_YOUNG; | |
> } | |
> /* ---------------------------------------------------------- */ | |
952a1005,1009 | |
> /* F0215----------------------------------------------------- */ | |
> //if (pte_young(pte)) { | |
> flags = __PM_YOUNG; | |
> //} | |
> /* ---------------------------------------------------------- */ | |
955c1012 | |
< *pme = make_pme(PM_NOT_PRESENT(pm->v2) | PM_STATUS2(pm->v2, flags2)); | |
--- | |
> *pme = make_pme(PM_NOT_PRESENT(pm->v2) | PM_STATUS2(pm->v2, flags2)/* F0215- */| flags/* -- */); | |
1353c1410 | |
< if (pte_none(*pte)) | |
--- | |
> if (!pte_present(*pte)) | |
1409a1467 | |
> file = vma_pr_or_file(vma); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment