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
| niedbalski@theos-mobile:~$ cat test-madvise.c | |
| #include <sys/mman.h> | |
| #include <unistd.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| int main(void) { | |
| size_t size = sysconf(_SC_PAGE_SIZE) * 6; //24K |
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
| //from https://people.freedesktop.org/~chrisbmr/a0c0-counter.c | |
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <math.h> | |
| #include <float.h> | |
| #include <unistd.h> | |
| #include <assert.h> |
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
| // https://people.freedesktop.org/~chrisbmr/90c0.c | |
| #include <stdint.h> | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <math.h> | |
| #include <float.h> | |
| #include <libdrm/nouveau.h> |
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
| // http://www.zarb.org/~trem/kernel/pci/pci-driver.c | |
| /*************************************************************************** | |
| * Copyright (C) 2005 by trem * | |
| * [email protected] * | |
| * * | |
| * This program is free software; you can redistribute it and/or modify * | |
| * it under the terms of the GNU General Public License as published by * | |
| * the Free Software Foundation; either version 2 of the License, or * | |
| * (at your option) any later version. * | |
| * * |
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
| obj-m += sample.o | |
| KDIR := /lib/modules/$(shell uname -r)/build | |
| PWD := $(shell pwd) | |
| all: | |
| $(MAKE) -C $(KDIR) M=$(PWD) modules | |
| clean: | |
| $(MAKE) -C $(KDIR) M=$(PWD) clean |
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
| all: | |
| gcc -I/usr/include/glib-2.0/ ghashtable.c -o main -lglib-2.0 | |
| clean: | |
| rm -rf main |
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
| echo 'export PATH=$PATH:/usr/local/cuda/bin' >> ~/.bashrc | |
| echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib:/usr/local/cuda/lib64' >> ~/.bashrc | |
| source ~/.bashrc | |
| sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf" | |
| sudo ldconfig |
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
| #!/bin/bash | |
| version="$(cat /usr/local/cuda/version.txt | head -n1|cut -d " " -f3)" | |
| echo $version | |
| majorminor=${version%.*} | |
| echo $majorminor |
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
| diff -PurN dummy/gu_page.c get_user_pages/gu_page.c | |
| --- dummy/gu_page.c 1970-01-01 01:00:00.000000000 +0100 | |
| +++ get_user_pages/gu_page.c 2012-06-14 14:41:31.797310260 +0100 | |
| @@ -0,0 +1,124 @@ | |
| +#include <linux/module.h> | |
| +#include <linux/mm.h> | |
| +#include <linux/sched.h> | |
| +#include <linux/slab.h> | |
| +#include <linux/vmalloc.h> | |
| + |
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
| int _mmap(struct file *f, struct vm_area_struct *vma) { | |
| unsigned long pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | |
| unsigned long addr; | |
| struct page *page; | |
| int i,rc=-ENODEV; | |
| // TODO need any semaphore for vma manipulation? | |
| printk(KERN_DEBUG "vma->vm_end %lu vm_start %lu len %lu pages %lu vm_pgoff %lu\n", | |
| vma->vm_end, vma->vm_start, vma->vm_end - vma->vm_start, pages, vma->vm_pgoff); | |
| /* allocate and insert pages to fill the vma. */ | |
| for(i=0; i < pages; i++) { |