1 diff -Nurb linux-2.6.22-580/arch/i386/Kconfig linux-2.6.22-590/arch/i386/Kconfig
2 --- linux-2.6.22-580/arch/i386/Kconfig 2009-04-08 16:36:16.000000000 -0400
3 +++ linux-2.6.22-590/arch/i386/Kconfig 2009-04-08 16:37:10.000000000 -0400
6 source "arch/i386/oprofile/Kconfig"
9 + bool "Chopstix (PlanetLab)"
10 + depends on MODULES && OPROFILE
12 + Chopstix allows you to monitor various events by summarizing them
13 + in lossy data structures and transferring these data structures
14 + into user space. If in doubt, say "N".
17 bool "Kprobes (EXPERIMENTAL)"
18 depends on KALLSYMS && EXPERIMENTAL && MODULES
19 diff -Nurb linux-2.6.22-580/arch/i386/kernel/asm-offsets.c linux-2.6.22-590/arch/i386/kernel/asm-offsets.c
20 --- linux-2.6.22-580/arch/i386/kernel/asm-offsets.c 2007-07-08 19:32:17.000000000 -0400
21 +++ linux-2.6.22-590/arch/i386/kernel/asm-offsets.c 2009-04-08 16:37:10.000000000 -0400
23 #include <linux/signal.h>
24 #include <linux/personality.h>
25 #include <linux/suspend.h>
26 +#include <linux/arrays.h>
27 #include <asm/ucontext.h>
29 #include <asm/pgtable.h>
31 #define OFFSET(sym, str, mem) \
32 DEFINE(sym, offsetof(struct str, mem));
34 +#define STACKOFFSET(sym, str, mem) \
35 + DEFINE(sym, offsetof(struct str, mem)-sizeof(struct str));
37 /* workaround for a warning with -Wmissing-prototypes */
42 + unsigned long dcookie;
44 + unsigned int number;
49 OFFSET(SIGCONTEXT_eax, sigcontext, eax);
51 OFFSET(CPUINFO_x86_vendor_id, cpuinfo_x86, x86_vendor_id);
54 - OFFSET(TI_task, thread_info, task);
55 + STACKOFFSET(TASK_thread, task_struct, thread);
56 + STACKOFFSET(THREAD_esp, thread_struct, esp);
57 + STACKOFFSET(EVENT_event_data, event, event_data);
58 + STACKOFFSET(EVENT_task, event, task);
59 + STACKOFFSET(EVENT_event_type, event, event_type);
60 + STACKOFFSET(SPEC_number, event_spec, number);
61 + DEFINE(EVENT_SIZE, sizeof(struct event));
62 + DEFINE(SPEC_SIZE, sizeof(struct event_spec));
63 + DEFINE(SPEC_EVENT_SIZE, sizeof(struct event_spec)+sizeof(struct event));
65 OFFSET(TI_exec_domain, thread_info, exec_domain);
66 OFFSET(TI_flags, thread_info, flags);
67 OFFSET(TI_status, thread_info, status);
68 diff -Nurb linux-2.6.22-580/arch/i386/mm/fault.c linux-2.6.22-590/arch/i386/mm/fault.c
69 --- linux-2.6.22-580/arch/i386/mm/fault.c 2009-04-08 16:36:16.000000000 -0400
70 +++ linux-2.6.22-590/arch/i386/mm/fault.c 2009-04-08 16:37:10.000000000 -0400
72 DIE_PAGE_FAULT, &args);
76 +extern void (*rec_event)(void *,unsigned int);
79 + unsigned long dcookie;
81 + unsigned char reason;
85 * Return EIP plus the CS segment base. The segment limit is also
86 * adjusted, clamped to the kernel/user address space (whichever is
88 * bit 3 == 1 means use of reserved bit detected
89 * bit 4 == 1 means fault was an instruction fetch
93 fastcall void __kprobes do_page_fault(struct pt_regs *regs,
94 unsigned long error_code)
96 diff -Nurb linux-2.6.22-580/block/ll_rw_blk.c linux-2.6.22-590/block/ll_rw_blk.c
97 --- linux-2.6.22-580/block/ll_rw_blk.c 2009-04-08 16:36:09.000000000 -0400
98 +++ linux-2.6.22-590/block/ll_rw_blk.c 2009-04-08 16:37:10.000000000 -0400
100 #include <linux/cpu.h>
101 #include <linux/blktrace_api.h>
102 #include <linux/fault-inject.h>
103 +#include <linux/arrays.h>
107 @@ -3102,6 +3103,13 @@
109 #endif /* CONFIG_FAIL_MAKE_REQUEST */
111 +extern void (*rec_event)(void *,unsigned int);
114 + unsigned long dcookie;
116 + unsigned char reason;
119 * generic_make_request: hand a buffer to its device driver for I/O
120 * @bio: The bio describing the location in memory and on the device.
121 @@ -3220,7 +3228,23 @@
126 +#ifdef CONFIG_CHOPSTIX
128 + struct event event;
129 + struct event_spec espec;
132 + espec.reason = 0;/*request */
134 + eip = bio->bi_end_io;
135 + event.event_data=&espec;
137 + event.event_type=3;
138 + /* index in the event array currently set up */
139 + /* make sure the counters are loaded in the order we want them to show up*/
140 + (*rec_event)(&event, bio->bi_size);
143 ret = q->make_request_fn(q, bio);
146 diff -Nurb linux-2.6.22-580/drivers/oprofile/cpu_buffer.c linux-2.6.22-590/drivers/oprofile/cpu_buffer.c
147 --- linux-2.6.22-580/drivers/oprofile/cpu_buffer.c 2007-07-08 19:32:17.000000000 -0400
148 +++ linux-2.6.22-590/drivers/oprofile/cpu_buffer.c 2009-04-08 16:37:10.000000000 -0400
150 #include <linux/oprofile.h>
151 #include <linux/vmalloc.h>
152 #include <linux/errno.h>
153 +#include <linux/arrays.h>
155 #include "event_buffer.h"
156 #include "cpu_buffer.h"
161 +#ifdef CONFIG_CHOPSTIX
165 + unsigned long dcookie;
169 +extern void (*rec_event)(void *,unsigned int);
173 add_sample(struct oprofile_cpu_buffer * cpu_buf,
174 unsigned long pc, unsigned long event)
177 entry->event = event;
178 increment_head(cpu_buf);
185 int is_kernel = !user_mode(regs);
186 unsigned long pc = profile_pc(regs);
189 +#ifdef CONFIG_CHOPSTIX
192 + struct event_spec espec;
193 + esig.task = current;
196 + esig.event_data=&espec;
197 + esig.event_type=event; /* index in the event array currently set up */
198 + /* make sure the counters are loaded in the order we want them to show up*/
199 + (*rec_event)(&esig, 1);
202 oprofile_add_ext_sample(pc, regs, event, is_kernel);
205 + oprofile_add_ext_sample(pc, regs, event, is_kernel);
211 void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
212 diff -Nurb linux-2.6.22-580/fs/bio.c linux-2.6.22-590/fs/bio.c
213 --- linux-2.6.22-580/fs/bio.c 2007-07-08 19:32:17.000000000 -0400
214 +++ linux-2.6.22-590/fs/bio.c 2009-04-08 16:37:10.000000000 -0400
216 #include <linux/workqueue.h>
217 #include <linux/blktrace_api.h>
218 #include <scsi/sg.h> /* for struct sg_iovec */
219 +#include <linux/arrays.h>
221 #define BIO_POOL_SIZE 2
224 struct kmem_cache *slab;
229 * if you change this list, also change bvec_alloc or things will
230 * break badly! cannot be bigger than what you can fit into an
231 @@ -999,6 +1001,14 @@
237 + unsigned long dcookie;
239 + unsigned char reason;
242 +extern void (*rec_event)(void *,unsigned int);
244 * bio_endio - end I/O on a bio
246 @@ -1028,6 +1038,24 @@
247 bio->bi_size -= bytes_done;
248 bio->bi_sector += (bytes_done >> 9);
250 +#ifdef CONFIG_CHOPSTIX
252 + struct event event;
253 + struct event_spec espec;
256 + espec.reason = 1;/*response */
258 + eip = bio->bi_end_io;
259 + event.event_data=&espec;
261 + event.event_type=3;
262 + /* index in the event array currently set up */
263 + /* make sure the counters are loaded in the order we want them to show up*/
264 + (*rec_event)(&event, bytes_done);
269 bio->bi_end_io(bio, bytes_done, error);
271 diff -Nurb linux-2.6.22-580/fs/exec.c linux-2.6.22-590/fs/exec.c
272 --- linux-2.6.22-580/fs/exec.c 2009-04-08 16:36:16.000000000 -0400
273 +++ linux-2.6.22-590/fs/exec.c 2009-04-08 16:40:34.000000000 -0400
275 #include <linux/mman.h>
276 #include <linux/a.out.h>
277 #include <linux/stat.h>
278 +#include <linux/dcookies.h>
279 #include <linux/fcntl.h>
280 #include <linux/smp_lock.h>
281 #include <linux/init.h>
283 #include <linux/binfmts.h>
284 #include <linux/swap.h>
285 #include <linux/utsname.h>
286 -#include <linux/pid_namespace.h>
287 +/*#include <linux/pid_namespace.h>*/
288 #include <linux/module.h>
289 #include <linux/namei.h>
290 #include <linux/proc_fs.h>
294 struct inode *inode = nd.dentry->d_inode;
295 +#ifdef CONFIG_CHOPSTIX
296 + unsigned long cookie;
297 + extern void (*rec_event)(void *, unsigned int);
298 + if (rec_event && !nd.dentry->d_cookie)
299 + get_dcookie(nd.dentry, nd.mnt, &cookie);
302 file = ERR_PTR(-EACCES);
303 if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
304 S_ISREG(inode->i_mode)) {
306 * Reparenting needs write_lock on tasklist_lock,
307 * so it is safe to do it under read_lock.
310 if (unlikely(tsk->group_leader == child_reaper(tsk)))
311 tsk->nsproxy->pid_ns->child_reaper = tsk;
314 zap_other_threads(tsk);
315 read_unlock(&tasklist_lock);
316 diff -Nurb linux-2.6.22-580/include/linux/arrays.h linux-2.6.22-590/include/linux/arrays.h
317 --- linux-2.6.22-580/include/linux/arrays.h 1969-12-31 19:00:00.000000000 -0500
318 +++ linux-2.6.22-590/include/linux/arrays.h 2009-04-08 16:37:10.000000000 -0400
320 +#ifndef __ARRAYS_H__
321 +#define __ARRAYS_H__
322 +#include <linux/list.h>
324 +#define SAMPLING_METHOD_DEFAULT 0
325 +#define SAMPLING_METHOD_LOG 1
327 +/* Every probe has an array handler */
329 +/* XXX - Optimize this structure */
331 +extern void (*rec_event)(void *,unsigned int);
332 +struct array_handler {
333 + struct list_head link;
334 + unsigned int (*hash_func)(void *);
335 + unsigned int (*sampling_func)(void *,int,void *);
336 + unsigned short size;
337 + unsigned int threshold;
338 + unsigned char **expcount;
339 + unsigned int sampling_method;
340 + unsigned int **arrays;
341 + unsigned int arraysize;
342 + unsigned int num_samples[2];
343 + void **epoch_samples; /* size-sized lists of samples */
344 + unsigned int (*serialize)(void *, void *);
345 + unsigned char code[5];
349 + struct list_head link;
351 + unsigned int count;
352 + unsigned int event_type;
353 + struct task_struct *task;
356 diff -Nurb linux-2.6.22-580/include/linux/mutex.h linux-2.6.22-590/include/linux/mutex.h
357 --- linux-2.6.22-580/include/linux/mutex.h 2007-07-08 19:32:17.000000000 -0400
358 +++ linux-2.6.22-590/include/linux/mutex.h 2009-04-08 16:37:10.000000000 -0400
360 struct thread_info *owner;
364 +#ifdef CONFIG_CHOPSTIX
365 + struct thread_info *owner;
368 #ifdef CONFIG_DEBUG_LOCK_ALLOC
369 struct lockdep_map dep_map;
370 diff -Nurb linux-2.6.22-580/include/linux/sched.h linux-2.6.22-590/include/linux/sched.h
371 --- linux-2.6.22-580/include/linux/sched.h 2009-04-08 16:36:17.000000000 -0400
372 +++ linux-2.6.22-590/include/linux/sched.h 2009-04-08 16:37:10.000000000 -0400
375 unsigned long sleep_avg;
376 unsigned long long timestamp, last_ran;
377 +#ifdef CONFIG_CHOPSTIX
378 + unsigned long last_interrupted, last_ran_j;
381 unsigned long long sched_time; /* sched_clock time spent running */
382 enum sleep_type sleep_type;
384 diff -Nurb linux-2.6.22-580/kernel/mutex.c linux-2.6.22-590/kernel/mutex.c
385 --- linux-2.6.22-580/kernel/mutex.c 2007-07-08 19:32:17.000000000 -0400
386 +++ linux-2.6.22-590/kernel/mutex.c 2009-04-08 16:37:10.000000000 -0400
388 #include <linux/spinlock.h>
389 #include <linux/interrupt.h>
390 #include <linux/debug_locks.h>
391 +#include <linux/arrays.h>
393 +#undef CONFIG_CHOPSTIX
394 +#ifdef CONFIG_CHOPSTIX
397 + unsigned long dcookie;
399 + unsigned char reason;
404 * In the DEBUG case we are using the "NULL fastpath" for mutexes,
406 __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key)
408 atomic_set(&lock->count, 1);
409 +#ifdef CONFIG_CHOPSTIX
412 spin_lock_init(&lock->wait_lock);
413 INIT_LIST_HEAD(&lock->wait_list);
416 * The locking fastpath is the 1->0 transition from
417 * 'unlocked' into 'locked' state.
420 __mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath);
425 __set_task_state(task, state);
427 +#ifdef CONFIG_CHOPSTIX
430 + struct event event;
431 + struct event_spec espec;
432 + struct task_struct *p = lock->owner->task;
433 + /*spin_lock(&p->alloc_lock);*/
434 + espec.reason = 0; /* lock */
435 + event.event_data=&espec;
438 + event.event_type=5;
439 + (*rec_event)(&event, 1);
440 + /*spin_unlock(&p->alloc_lock);*/
448 /* didnt get the lock, go to sleep: */
449 spin_unlock_mutex(&lock->wait_lock, flags);
452 /* got the lock - rejoice! */
453 mutex_remove_waiter(lock, &waiter, task_thread_info(task));
454 debug_mutex_set_owner(lock, task_thread_info(task));
455 +#ifdef CONFIG_CHOPSTIX
456 + lock->owner = task_thread_info(task);
459 /* set it to 0 if there are no waiters left: */
460 if (likely(list_empty(&lock->wait_list)))
462 mutex_lock_nested(struct mutex *lock, unsigned int subclass)
466 __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, subclass);
470 mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass)
474 return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, subclass);
479 debug_mutex_wake_waiter(lock, waiter);
481 +#ifdef CONFIG_CHOPSTIX
484 + struct event event;
485 + struct event_spec espec;
487 + espec.reason = 1; /* unlock */
488 + event.event_data=&espec;
489 + event.task = lock->owner->task;
491 + event.event_type=5;
492 + (*rec_event)(&event, 1);
498 wake_up_process(waiter->task);
501 diff -Nurb linux-2.6.22-580/kernel/sched.c linux-2.6.22-590/kernel/sched.c
502 --- linux-2.6.22-580/kernel/sched.c 2009-04-08 16:36:17.000000000 -0400
503 +++ linux-2.6.22-590/kernel/sched.c 2009-04-08 16:37:10.000000000 -0400
505 * 1998-11-19 Implemented schedule_timeout() and related stuff
506 * by Andrea Arcangeli
507 * 2002-01-04 New ultra-scalable O(1) scheduler by Ingo Molnar:
508 - * hybrid priority-list and round-robin design with
509 + * hybrid priority-list and round-robin deventn with
510 * an array-switch method of distributing timeslices
511 * and per-CPU runqueues. Cleanups and useful suggestions
512 * by Davide Libenzi, preemptible kernel bits by Robert Love.
514 #include <linux/nmi.h>
515 #include <linux/init.h>
516 #include <asm/uaccess.h>
517 +#include <linux/arrays.h>
518 #include <linux/highmem.h>
519 #include <linux/smp_lock.h>
520 #include <asm/mmu_context.h>
522 #include <linux/vs_sched.h>
523 #include <linux/vs_cvirt.h>
525 +#define INTERRUPTIBLE -1
529 * Scheduler clock - returns current time in nanosec units.
530 * This is default implementation.
536 spin_lock(&rq->lock);
537 if (unlikely(rq != task_rq(p))) {
538 spin_unlock(&rq->lock);
539 @@ -1741,6 +1746,21 @@
540 * event cannot wake it up and insert it on the runqueue either.
542 p->state = TASK_RUNNING;
543 +#ifdef CONFIG_CHOPSTIX
544 + /* The jiffy of last interruption */
545 + if (p->state & TASK_UNINTERRUPTIBLE) {
546 + p->last_interrupted=jiffies;
549 + if (p->state & TASK_INTERRUPTIBLE) {
550 + p->last_interrupted=INTERRUPTIBLE;
553 + p->last_interrupted=RUNNING;
555 + /* The jiffy of last execution */
556 + p->last_ran_j=jiffies;
560 * Make sure we do not leak PI boosting priority to the child:
561 @@ -3608,6 +3628,7 @@
566 static inline int interactive_sleep(enum sleep_type sleep_type)
568 return (sleep_type == SLEEP_INTERACTIVE ||
569 @@ -3617,16 +3638,28 @@
571 * schedule() is the main scheduler function.
574 +#ifdef CONFIG_CHOPSTIX
575 +extern void (*rec_event)(void *,unsigned int);
578 + unsigned long dcookie;
579 + unsigned int count;
580 + unsigned int reason;
584 asmlinkage void __sched schedule(void)
586 struct task_struct *prev, *next;
587 struct prio_array *array;
588 struct list_head *queue;
589 unsigned long long now;
590 - unsigned long run_time;
591 + unsigned long run_time, diff;
592 int cpu, idx, new_prio;
595 + int sampling_reason;
598 * Test if we are atomic. Since do_exit() needs to call into
599 @@ -3680,6 +3713,7 @@
600 switch_count = &prev->nivcsw;
601 if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
602 switch_count = &prev->nvcsw;
604 if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
605 unlikely(signal_pending(prev))))
606 prev->state = TASK_RUNNING;
607 @@ -3689,6 +3723,17 @@
608 vx_uninterruptible_inc(prev);
610 deactivate_task(prev, rq);
611 +#ifdef CONFIG_CHOPSTIX
612 + /* An uninterruptible process just yielded. Record the current jiffie */
613 + if (prev->state & TASK_UNINTERRUPTIBLE) {
614 + prev->last_interrupted=jiffies;
616 + /* An interruptible process just yielded, or it got preempted.
617 + * Mark it as interruptible */
618 + else if (prev->state & TASK_INTERRUPTIBLE) {
619 + prev->last_interrupted=INTERRUPTIBLE;
625 @@ -3765,6 +3810,40 @@
627 prev->timestamp = prev->last_ran = now;
629 +#ifdef CONFIG_CHOPSTIX
630 + /* Run only if the Chopstix module so decrees it */
632 + prev->last_ran_j = jiffies;
633 + if (next->last_interrupted!=INTERRUPTIBLE) {
634 + if (next->last_interrupted!=RUNNING) {
635 + diff = (jiffies-next->last_interrupted);
636 + sampling_reason = 0;/* BLOCKING */
639 + diff = jiffies-next->last_ran_j;
640 + sampling_reason = 1;/* PREEMPTION */
643 + if (diff >= HZ/10) {
644 + struct event event;
645 + struct event_spec espec;
646 + struct pt_regs *regs;
647 + regs = task_pt_regs(current);
649 + espec.reason = sampling_reason;
650 + event.event_data=&espec;
652 + espec.pc=regs->eip;
653 + event.event_type=2;
654 + /* index in the event array currently set up */
655 + /* make sure the counters are loaded in the order we want them to show up*/
656 + (*rec_event)(&event, diff);
659 + /* next has been elected to run */
660 + next->last_interrupted=0;
663 sched_info_switch(prev, next);
664 if (likely(prev != next)) {
665 next->timestamp = next->last_ran = now;
666 @@ -4664,6 +4743,7 @@
668 read_unlock(&tasklist_lock);
672 if ((current->euid != p->euid) && (current->euid != p->uid) &&
673 !capable(CAP_SYS_NICE))
674 @@ -5032,6 +5112,7 @@
675 jiffies_to_timespec(p->policy == SCHED_FIFO ?
676 0 : task_timeslice(p), &t);
677 read_unlock(&tasklist_lock);
679 retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;
682 @@ -7275,3 +7356,20 @@
687 +#ifdef CONFIG_CHOPSTIX
688 +void (*rec_event)(void *,unsigned int) = NULL;
690 +/* To support safe calling from asm */
691 +asmlinkage void rec_event_asm (struct event *event_signature_in, unsigned int count) {
692 + struct pt_regs *regs;
693 + struct event_spec *es = event_signature_in->event_data;
694 + regs = task_pt_regs(current);
695 + event_signature_in->task=current;
697 + event_signature_in->count=1;
698 + (*rec_event)(event_signature_in, count);
700 +EXPORT_SYMBOL(rec_event);
701 +EXPORT_SYMBOL(in_sched_functions);
703 diff -Nurb linux-2.6.22-580/mm/memory.c linux-2.6.22-590/mm/memory.c
704 --- linux-2.6.22-580/mm/memory.c 2009-04-08 16:36:17.000000000 -0400
705 +++ linux-2.6.22-590/mm/memory.c 2009-04-08 16:37:10.000000000 -0400
708 #include <linux/swapops.h>
709 #include <linux/elf.h>
710 +#include <linux/arrays.h>
712 #ifndef CONFIG_NEED_MULTIPLE_NODES
713 /* use the per-pgdat data instead for discontigmem - mbligh */
714 @@ -2601,6 +2602,15 @@
718 +extern void (*rec_event)(void *,unsigned int);
721 + unsigned long dcookie;
723 + unsigned char reason;
728 * By the time we get here, we already hold the mm semaphore
730 @@ -2630,6 +2640,24 @@
734 +#ifdef CONFIG_CHOPSTIX
736 + struct event event;
737 + struct event_spec espec;
738 + struct pt_regs *regs;
740 + regs = task_pt_regs(current);
741 + pc = regs->eip & (unsigned int) ~4095;
743 + espec.reason = 0; /* alloc */
744 + event.event_data=&espec;
745 + event.task = current;
747 + event.event_type=5;
748 + (*rec_event)(&event, 1);
752 return handle_pte_fault(mm, vma, address, pte, pmd, write_access);
755 diff -Nurb linux-2.6.22-580/mm/slab.c linux-2.6.22-590/mm/slab.c
756 --- linux-2.6.22-580/mm/slab.c 2009-04-08 16:36:17.000000000 -0400
757 +++ linux-2.6.22-590/mm/slab.c 2009-04-08 16:37:10.000000000 -0400
758 @@ -110,11 +110,13 @@
759 #include <linux/fault-inject.h>
760 #include <linux/rtmutex.h>
761 #include <linux/reciprocal_div.h>
762 +#include <linux/arrays.h>
764 #include <asm/cacheflush.h>
765 #include <asm/tlbflush.h>
766 #include <asm/page.h>
770 * DEBUG - 1 for kmem_cache_create() to honour; SLAB_RED_ZONE & SLAB_POISON.
771 * 0 for faster, smaller code (especially in the critical paths).
776 +extern void (*rec_event)(void *,unsigned int);
779 + unsigned long dcookie;
781 + unsigned char reason;
787 @@ -3443,6 +3453,19 @@
788 local_irq_restore(save_flags);
789 objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
791 +#ifdef CONFIG_CHOPSTIX
792 + if (rec_event && objp) {
793 + struct event event;
794 + struct event_spec espec;
796 + espec.reason = 0; /* alloc */
797 + event.event_data=&espec;
798 + event.task = current;
800 + event.event_type=5;
801 + (*rec_event)(&event, cachep->buffer_size);
807 @@ -3549,12 +3572,26 @@
808 * Release an obj back to its cache. If the obj has a constructed state, it must
809 * be in this state _before_ it is released. Called with disabled ints.
811 -static inline void __cache_free(struct kmem_cache *cachep, void *objp)
812 +static inline void __cache_free(struct kmem_cache *cachep, void *objp, void *caller)
814 struct array_cache *ac = cpu_cache_get(cachep);
817 - objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
818 + objp = cache_free_debugcheck(cachep, objp, caller);
819 + #ifdef CONFIG_CHOPSTIX
820 + if (rec_event && objp) {
821 + struct event event;
822 + struct event_spec espec;
824 + espec.reason = 1; /* free */
825 + event.event_data=&espec;
826 + event.task = current;
828 + event.event_type=4;
829 + (*rec_event)(&event, cachep->buffer_size);
833 vx_slab_free(cachep);
835 if (cache_free_alien(cachep, objp))
836 @@ -3651,16 +3688,19 @@
837 __builtin_return_address(0));
839 EXPORT_SYMBOL(kmem_cache_alloc_node);
841 static __always_inline void *
842 __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
844 struct kmem_cache *cachep;
848 cachep = kmem_find_general_cachep(size, flags);
849 if (unlikely(cachep == NULL))
851 - return kmem_cache_alloc_node(cachep, flags, node);
852 + ret = kmem_cache_alloc_node(cachep, flags, node);
857 #ifdef CONFIG_DEBUG_SLAB
858 @@ -3696,6 +3736,7 @@
861 struct kmem_cache *cachep;
864 /* If you want to save a few bytes .text space: replace
866 @@ -3705,9 +3746,10 @@
867 cachep = __find_general_cachep(size, flags);
868 if (unlikely(cachep == NULL))
870 - return __cache_alloc(cachep, flags, caller);
872 + ret = __cache_alloc(cachep, flags, caller);
877 #ifdef CONFIG_DEBUG_SLAB
878 void *__kmalloc(size_t size, gfp_t flags)
879 @@ -3723,10 +3765,17 @@
880 EXPORT_SYMBOL(__kmalloc_track_caller);
883 +#ifdef CONFIG_CHOPSTIX
884 +void *__kmalloc(size_t size, gfp_t flags)
886 + return __do_kmalloc(size, flags, __builtin_return_address(0));
889 void *__kmalloc(size_t size, gfp_t flags)
891 return __do_kmalloc(size, flags, NULL);
894 EXPORT_SYMBOL(__kmalloc);
897 @@ -3792,7 +3841,7 @@
899 local_irq_save(flags);
900 debug_check_no_locks_freed(objp, obj_size(cachep));
901 - __cache_free(cachep, objp);
902 + __cache_free(cachep, objp,__builtin_return_address(0));
903 local_irq_restore(flags);
905 EXPORT_SYMBOL(kmem_cache_free);
906 @@ -3817,7 +3866,7 @@
907 kfree_debugcheck(objp);
908 c = virt_to_cache(objp);
909 debug_check_no_locks_freed(objp, obj_size(c));
910 - __cache_free(c, (void *)objp);
911 + __cache_free(c, (void *)objp,__builtin_return_address(0));
912 local_irq_restore(flags);
914 EXPORT_SYMBOL(kfree);