/* kmemtest - a memory tester to run as a kernel thread under Linux Copyright (C) 2005 Kasper Dupont 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 with permission from the author any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #define MB 1000 #define PAGES (MB*256) struct page *p[PAGES]; struct seed { uint32_t hi; uint16_t lo; uint16_t in; } s1, s2; pid_t thread_pid = 0; uint16_t page[4][2048]; void kmemtest_cleanup(void) { int i; for (i=0;i>16; x^=x>>8; x^=x>>4; x^=x>>2; x^=x>>1; return x&1; } void init(uint16_t *p,uint16_t lo, uint16_t in) { int i; for (i=0;i<2048;++i) p[i]=parity(i&lo)?~in:in; } static DECLARE_COMPLETION(kmemtest_exited); int kmemtest_thread(void *arg) { //sigset_t blocked; int i,pass=0,errors=0; struct task_struct *curtask = current; daemonize(/*"kmemtest"*/); //sigemptyset(&blocked); //sigprocmask(SIG_SETMASK, &blocked, NULL); set_user_nice(curtask, 19); while(1) { snprintf(curtask->comm,15,"kmemtest %d",++pass); get_random_bytes(&s2,8); init(page[2],s2.lo,s2.in); init(page[3],s2.lo,~s2.in); for (i=0;i