adding the patch file too
[linux-2.6.git] / linux-2.6-590-chopstix-intern.patch
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  2008-04-30 09:29:26.000000000 -0400
3 +++ linux-2.6.22-590/arch/i386/Kconfig  2008-04-30 09:29:41.000000000 -0400
4 @@ -1217,6 +1217,14 @@
5  
6  source "arch/i386/oprofile/Kconfig"
7  
8 +config CHOPSTIX
9 +       bool "Chopstix (PlanetLab)"
10 +       depends on MODULES && OPROFILE
11 +       help
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".
15 +
16  config KPROBES
17         bool "Kprobes (EXPERIMENTAL)"
18         depends on KALLSYMS && EXPERIMENTAL && MODULES
19 diff -Nurb linux-2.6.22-580/block/ll_rw_blk.c linux-2.6.22-590/block/ll_rw_blk.c
20 --- linux-2.6.22-580/block/ll_rw_blk.c  2008-04-30 09:29:21.000000000 -0400
21 +++ linux-2.6.22-590/block/ll_rw_blk.c  2008-04-30 09:29:41.000000000 -0400
22 @@ -30,6 +30,7 @@
23  #include <linux/cpu.h>
24  #include <linux/blktrace_api.h>
25  #include <linux/fault-inject.h>
26 +#include <linux/arrays.h>
27  
28  /*
29   * for max sense size
30 @@ -3102,6 +3103,13 @@
31  
32  #endif /* CONFIG_FAIL_MAKE_REQUEST */
33  
34 +extern void (*rec_event)(void *,unsigned int);
35 +struct event_spec {
36 +       unsigned long pc;
37 +       unsigned long dcookie;
38 +       unsigned count;
39 +       unsigned char reason;
40 +};
41  /**
42   * generic_make_request: hand a buffer to its device driver for I/O
43   * @bio:  The bio describing the location in memory and on the device.
44 @@ -3220,7 +3228,23 @@
45                                 goto end_io;
46                         }
47                 }
48 -
49 +#ifdef CONFIG_CHOPSTIX
50 +               if (rec_event) {
51 +                       struct event event;
52 +                       struct event_spec espec;
53 +                       unsigned long eip;
54 +                       
55 +                       espec.reason = 0;/*request */
56 +
57 +                       eip = bio->bi_end_io;
58 +                       event.event_data=&espec;
59 +                       espec.pc=eip;
60 +                       event.event_type=3; 
61 +                       /* index in the event array currently set up */
62 +                       /* make sure the counters are loaded in the order we want them to show up*/ 
63 +                       (*rec_event)(&event, bio->bi_size);
64 +               }
65 +#endif
66                 ret = q->make_request_fn(q, bio);
67         } while (ret);
68  }
69 diff -Nurb linux-2.6.22-580/drivers/oprofile/cpu_buffer.c linux-2.6.22-590/drivers/oprofile/cpu_buffer.c
70 --- linux-2.6.22-580/drivers/oprofile/cpu_buffer.c      2007-07-08 19:32:17.000000000 -0400
71 +++ linux-2.6.22-590/drivers/oprofile/cpu_buffer.c      2008-04-30 09:29:41.000000000 -0400
72 @@ -21,6 +21,7 @@
73  #include <linux/oprofile.h>
74  #include <linux/vmalloc.h>
75  #include <linux/errno.h>
76 +#include <linux/arrays.h>
77   
78  #include "event_buffer.h"
79  #include "cpu_buffer.h"
80 @@ -143,6 +144,17 @@
81                 b->head_pos = 0;
82  }
83  
84 +#ifdef CONFIG_CHOPSTIX
85 +
86 +struct event_spec {
87 +       unsigned int pc;
88 +       unsigned long dcookie;
89 +       unsigned count;
90 +};
91 +
92 +extern void (*rec_event)(void *,unsigned int);
93 +#endif
94 +
95  static inline void
96  add_sample(struct oprofile_cpu_buffer * cpu_buf,
97             unsigned long pc, unsigned long event)
98 @@ -151,6 +163,7 @@
99         entry->eip = pc;
100         entry->event = event;
101         increment_head(cpu_buf);
102 +
103  }
104  
105  static inline void
106 @@ -241,8 +254,28 @@
107  {
108         int is_kernel = !user_mode(regs);
109         unsigned long pc = profile_pc(regs);
110 +       int res=0;
111  
112 +#ifdef CONFIG_CHOPSTIX
113 +       if (rec_event) {
114 +               struct event esig;
115 +               struct event_spec espec;
116 +               esig.task = current;
117 +               espec.pc=pc;
118 +               espec.count=1;
119 +               esig.event_data=&espec;
120 +               esig.event_type=event; /* index in the event array currently set up */
121 +                                       /* make sure the counters are loaded in the order we want them to show up*/ 
122 +               (*rec_event)(&esig, 1);
123 +       }
124 +       else {
125         oprofile_add_ext_sample(pc, regs, event, is_kernel);
126 +       }
127 +#else
128 +       oprofile_add_ext_sample(pc, regs, event, is_kernel);
129 +#endif
130 +
131 +
132  }
133  
134  void oprofile_add_pc(unsigned long pc, int is_kernel, unsigned long event)
135 diff -Nurb linux-2.6.22-580/fs/bio.c linux-2.6.22-590/fs/bio.c
136 --- linux-2.6.22-580/fs/bio.c   2007-07-08 19:32:17.000000000 -0400
137 +++ linux-2.6.22-590/fs/bio.c   2008-04-30 09:29:41.000000000 -0400
138 @@ -27,6 +27,7 @@
139  #include <linux/workqueue.h>
140  #include <linux/blktrace_api.h>
141  #include <scsi/sg.h>           /* for struct sg_iovec */
142 +#include <linux/arrays.h>
143  
144  #define BIO_POOL_SIZE 2
145  
146 @@ -47,6 +48,7 @@
147         struct kmem_cache *slab;
148  };
149  
150 +
151  /*
152   * if you change this list, also change bvec_alloc or things will
153   * break badly! cannot be bigger than what you can fit into an
154 @@ -999,6 +1001,14 @@
155         }
156  }
157  
158 +struct event_spec {
159 +       unsigned long pc;
160 +       unsigned long dcookie;
161 +       unsigned count;
162 +       unsigned char reason;
163 +};
164 +
165 +extern void (*rec_event)(void *,unsigned int);
166  /**
167   * bio_endio - end I/O on a bio
168   * @bio:       bio
169 @@ -1028,6 +1038,24 @@
170         bio->bi_size -= bytes_done;
171         bio->bi_sector += (bytes_done >> 9);
172  
173 +#ifdef CONFIG_CHOPSTIX
174 +               if (rec_event) {
175 +                       struct event event;
176 +                       struct event_spec espec;
177 +                       unsigned long eip;
178 +                       
179 +                       espec.reason = 1;/*response */
180 +
181 +                       eip = bio->bi_end_io;
182 +                       event.event_data=&espec;
183 +                       espec.pc=eip;
184 +                       event.event_type=3; 
185 +                       /* index in the event array currently set up */
186 +                       /* make sure the counters are loaded in the order we want them to show up*/ 
187 +                       (*rec_event)(&event, bytes_done);
188 +               }
189 +#endif
190 +
191         if (bio->bi_end_io)
192                 bio->bi_end_io(bio, bytes_done, error);
193  }
194 diff -Nurb linux-2.6.22-580/fs/exec.c linux-2.6.22-590/fs/exec.c
195 --- linux-2.6.22-580/fs/exec.c  2008-04-30 09:29:26.000000000 -0400
196 +++ linux-2.6.22-590/fs/exec.c  2008-04-30 09:29:41.000000000 -0400
197 @@ -52,6 +52,7 @@
198  #include <linux/audit.h>
199  #include <linux/signalfd.h>
200  #include <linux/vs_memory.h>
201 +#include <linux/dcookies.h>
202  
203  #include <asm/uaccess.h>
204  #include <asm/mmu_context.h>
205 @@ -488,6 +489,12 @@
206  
207         if (!err) {
208                 struct inode *inode = nd.dentry->d_inode;
209 +#ifdef CONFIG_CHOPSTIX
210 +               unsigned long cookie;
211 +               if (!nd.dentry->d_cookie)
212 +                       get_dcookie(nd.dentry, nd.mnt, &cookie);
213 +#endif
214 +
215                 file = ERR_PTR(-EACCES);
216                 if (!(nd.mnt->mnt_flags & MNT_NOEXEC) &&
217                     S_ISREG(inode->i_mode)) {
218 diff -Nurb linux-2.6.22-580/include/linux/arrays.h linux-2.6.22-590/include/linux/arrays.h
219 --- linux-2.6.22-580/include/linux/arrays.h     1969-12-31 19:00:00.000000000 -0500
220 +++ linux-2.6.22-590/include/linux/arrays.h     2008-04-30 09:29:41.000000000 -0400
221 @@ -0,0 +1,36 @@
222 +#ifndef __ARRAYS_H__
223 +#define __ARRAYS_H__
224 +#include <linux/list.h>
225 +
226 +#define SAMPLING_METHOD_DEFAULT 0
227 +#define SAMPLING_METHOD_LOG 1
228 +
229 +/* Every probe has an array handler */
230 +
231 +/* XXX - Optimize this structure */
232 +
233 +extern void (*rec_event)(void *,unsigned int);
234 +struct array_handler {
235 +       struct list_head link;
236 +       unsigned int (*hash_func)(void *);
237 +       unsigned int (*sampling_func)(void *,int,void *);
238 +       unsigned short size;
239 +       unsigned int threshold;
240 +       unsigned char **expcount;
241 +       unsigned int sampling_method;
242 +       unsigned int **arrays;
243 +       unsigned int arraysize;
244 +       unsigned int num_samples[2];
245 +       void **epoch_samples; /* size-sized lists of samples */
246 +       unsigned int (*serialize)(void *, void *);
247 +       unsigned char code[5];
248 +};
249 +
250 +struct event {
251 +       struct list_head link;
252 +       void *event_data;
253 +       unsigned int count;
254 +       unsigned int event_type;
255 +       struct task_struct *task;
256 +};
257 +#endif
258 diff -Nurb linux-2.6.22-580/include/linux/mutex.h linux-2.6.22-590/include/linux/mutex.h
259 --- linux-2.6.22-580/include/linux/mutex.h      2007-07-08 19:32:17.000000000 -0400
260 +++ linux-2.6.22-590/include/linux/mutex.h      2008-04-30 09:45:43.000000000 -0400
261 @@ -53,6 +53,10 @@
262         struct thread_info      *owner;
263         const char              *name;
264         void                    *magic;
265 +#else
266 +#ifdef CONFIG_CHOPSTIX
267 +       struct thread_info      *owner;
268 +#endif
269  #endif
270  #ifdef CONFIG_DEBUG_LOCK_ALLOC
271         struct lockdep_map      dep_map;
272 diff -Nurb linux-2.6.22-580/include/linux/sched.h linux-2.6.22-590/include/linux/sched.h
273 --- linux-2.6.22-580/include/linux/sched.h      2008-04-30 09:29:26.000000000 -0400
274 +++ linux-2.6.22-590/include/linux/sched.h      2008-04-30 09:29:41.000000000 -0400
275 @@ -850,6 +850,10 @@
276  #endif
277         unsigned long sleep_avg;
278         unsigned long long timestamp, last_ran;
279 +#ifdef CONFIG_CHOPSTIX
280 +       unsigned long last_interrupted, last_ran_j;
281 +#endif
282 +
283         unsigned long long sched_time; /* sched_clock time spent running */
284         enum sleep_type sleep_type;
285  
286 diff -Nurb linux-2.6.22-580/kernel/mutex.c linux-2.6.22-590/kernel/mutex.c
287 --- linux-2.6.22-580/kernel/mutex.c     2007-07-08 19:32:17.000000000 -0400
288 +++ linux-2.6.22-590/kernel/mutex.c     2008-04-30 09:29:41.000000000 -0400
289 @@ -18,6 +18,16 @@
290  #include <linux/spinlock.h>
291  #include <linux/interrupt.h>
292  #include <linux/debug_locks.h>
293 +#include <linux/arrays.h>
294 +#undef CONFIG_CHOPSTIX
295 +#ifdef CONFIG_CHOPSTIX
296 +struct event_spec {
297 +       unsigned long pc;
298 +       unsigned long dcookie;
299 +       unsigned count;
300 +       unsigned char reason;
301 +};
302 +#endif
303  
304  /*
305   * In the DEBUG case we are using the "NULL fastpath" for mutexes,
306 @@ -43,6 +53,9 @@
307  __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key)
308  {
309         atomic_set(&lock->count, 1);
310 +#ifdef CONFIG_CHOPSTIX
311 +       lock->owner=NULL;
312 +#endif
313         spin_lock_init(&lock->wait_lock);
314         INIT_LIST_HEAD(&lock->wait_list);
315  
316 @@ -88,6 +101,7 @@
317          * The locking fastpath is the 1->0 transition from
318          * 'unlocked' into 'locked' state.
319          */
320 +
321         __mutex_fastpath_lock(&lock->count, __mutex_lock_slowpath);
322  }
323  
324 @@ -168,6 +182,27 @@
325                 }
326                 __set_task_state(task, state);
327  
328 +#ifdef CONFIG_CHOPSTIX
329 +               if (rec_event) {
330 +                       if (lock->owner) {
331 +                               struct event event;
332 +                               struct event_spec espec;
333 +                               struct task_struct *p = lock->owner->task;
334 +                               /*spin_lock(&p->alloc_lock);*/
335 +                               espec.reason = 0; /* lock */
336 +                               event.event_data=&espec;
337 +                               event.task = p;
338 +                               espec.pc=lock;
339 +                               event.event_type=5; 
340 +                               (*rec_event)(&event, 1);
341 +                               /*spin_unlock(&p->alloc_lock);*/
342 +
343 +                       }
344 +                       else 
345 +                               BUG();
346 +               }
347 +#endif
348 +
349                 /* didnt get the lock, go to sleep: */
350                 spin_unlock_mutex(&lock->wait_lock, flags);
351                 schedule();
352 @@ -177,6 +212,9 @@
353         /* got the lock - rejoice! */
354         mutex_remove_waiter(lock, &waiter, task_thread_info(task));
355         debug_mutex_set_owner(lock, task_thread_info(task));
356 +#ifdef CONFIG_CHOPSTIX
357 +       lock->owner = task_thread_info(task);
358 +#endif
359  
360         /* set it to 0 if there are no waiters left: */
361         if (likely(list_empty(&lock->wait_list)))
362 @@ -202,6 +240,7 @@
363  mutex_lock_nested(struct mutex *lock, unsigned int subclass)
364  {
365         might_sleep();
366 +
367         __mutex_lock_common(lock, TASK_UNINTERRUPTIBLE, subclass);
368  }
369  
370 @@ -211,6 +250,7 @@
371  mutex_lock_interruptible_nested(struct mutex *lock, unsigned int subclass)
372  {
373         might_sleep();
374 +
375         return __mutex_lock_common(lock, TASK_INTERRUPTIBLE, subclass);
376  }
377  
378 @@ -246,6 +286,23 @@
379  
380                 debug_mutex_wake_waiter(lock, waiter);
381  
382 +#ifdef CONFIG_CHOPSTIX
383 +               if (rec_event) {
384 +                       if (lock->owner) {
385 +                               struct event event;
386 +                               struct event_spec espec;
387 +
388 +                               espec.reason = 1; /* unlock */
389 +                               event.event_data=&espec;
390 +                               event.task = lock->owner->task;
391 +                               espec.pc=lock;
392 +                               event.event_type=5; 
393 +                               (*rec_event)(&event, 1);
394 +                       }
395 +                       else 
396 +                               BUG();
397 +               }
398 +#endif
399                 wake_up_process(waiter->task);
400         }
401  
402 diff -Nurb linux-2.6.22-580/kernel/sched.c linux-2.6.22-590/kernel/sched.c
403 --- linux-2.6.22-580/kernel/sched.c     2008-04-30 09:29:26.000000000 -0400
404 +++ linux-2.6.22-590/kernel/sched.c     2008-04-30 09:29:41.000000000 -0400
405 @@ -10,7 +10,7 @@
406   *  1998-11-19 Implemented schedule_timeout() and related stuff
407   *             by Andrea Arcangeli
408   *  2002-01-04 New ultra-scalable O(1) scheduler by Ingo Molnar:
409 - *             hybrid priority-list and round-robin design with
410 + *             hybrid priority-list and round-robin deventn with
411   *             an array-switch method of distributing timeslices
412   *             and per-CPU runqueues.  Cleanups and useful suggestions
413   *             by Davide Libenzi, preemptible kernel bits by Robert Love.
414 @@ -56,6 +56,7 @@
415  
416  #include <asm/tlb.h>
417  #include <asm/unistd.h>
418 +#include <linux/arrays.h>
419  #include <linux/vs_sched.h>
420  #include <linux/vs_cvirt.h>
421  
422 @@ -431,6 +432,7 @@
423  
424  repeat_lock_task:
425         rq = task_rq(p);
426 +
427         spin_lock(&rq->lock);
428         if (unlikely(rq != task_rq(p))) {
429                 spin_unlock(&rq->lock);
430 @@ -1741,6 +1743,10 @@
431          * event cannot wake it up and insert it on the runqueue either.
432          */
433         p->state = TASK_RUNNING;
434 +#ifdef CONFIG_CHOPSTIX
435 +       p->last_interrupted=0;
436 +       p->last_ran_j=jiffies;
437 +#endif
438  
439         /*
440          * Make sure we do not leak PI boosting priority to the child:
441 @@ -3608,6 +3614,7 @@
442  
443  #endif
444  
445 +
446  static inline int interactive_sleep(enum sleep_type sleep_type)
447  {
448         return (sleep_type == SLEEP_INTERACTIVE ||
449 @@ -3617,16 +3624,28 @@
450  /*
451   * schedule() is the main scheduler function.
452   */
453 +
454 +#ifdef CONFIG_CHOPSTIX
455 +extern void (*rec_event)(void *,unsigned int);
456 +struct event_spec {
457 +       unsigned long pc;
458 +       unsigned long dcookie;
459 +       unsigned count;
460 +       unsigned char reason;
461 +};
462 +#endif
463 +
464  asmlinkage void __sched schedule(void)
465  {
466         struct task_struct *prev, *next;
467         struct prio_array *array;
468         struct list_head *queue;
469         unsigned long long now;
470 -       unsigned long run_time;
471 +       unsigned long run_time, diff;
472         int cpu, idx, new_prio;
473         long *switch_count;
474         struct rq *rq;
475 +       int sampling_reason;
476  
477         /*
478          * Test if we are atomic.  Since do_exit() needs to call into
479 @@ -3680,6 +3699,7 @@
480         switch_count = &prev->nivcsw;
481         if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
482                 switch_count = &prev->nvcsw;
483 +
484                 if (unlikely((prev->state & TASK_INTERRUPTIBLE) &&
485                                 unlikely(signal_pending(prev))))
486                         prev->state = TASK_RUNNING;
487 @@ -3689,6 +3709,14 @@
488                                 vx_uninterruptible_inc(prev);
489                         }
490                         deactivate_task(prev, rq);
491 +#ifdef CONFIG_CHOPSTIX
492 +                       if (prev->state & TASK_UNINTERRUPTIBLE) {
493 +                               prev->last_interrupted=jiffies;
494 +                       }
495 +                       else if (prev->state & TASK_INTERRUPTIBLE) {
496 +                               prev->last_interrupted=-1;
497 +                       }
498 +#endif
499                 }
500         }
501  
502 @@ -3765,6 +3793,39 @@
503                 prev->sleep_avg = 0;
504         prev->timestamp = prev->last_ran = now;
505  
506 +#ifdef CONFIG_CHOPSTIX
507 +       /* Run only if the Chopstix module so decrees it */
508 +       if (rec_event) {
509 +               prev->last_ran_j = jiffies;
510 +               if (next->last_interrupted!=-1) {
511 +                       if (next->last_interrupted) {
512 +                               diff = (jiffies-next->last_interrupted);
513 +                               sampling_reason = 0;
514 +                       }
515 +                       else {
516 +                               diff = jiffies-next->last_ran_j;
517 +                               sampling_reason = 1;
518 +                       }
519 +
520 +                       if (diff > HZ/5) {
521 +                               struct event event;
522 +                               struct event_spec espec;
523 +                               unsigned long eip;
524 +
525 +                               espec.reason = sampling_reason;
526 +                               eip = next->thread.esp & 4095;
527 +                               event.event_data=&espec;
528 +                               event.task=next;
529 +                               espec.pc=eip;
530 +                               event.event_type=2; 
531 +                               /* index in the event array currently set up */
532 +                               /* make sure the counters are loaded in the order we want them to show up*/ 
533 +                               (*rec_event)(&event, diff);
534 +                       }
535 +               }
536 +               next->last_interrupted=0;
537 +       }
538 +#endif
539         sched_info_switch(prev, next);
540         if (likely(prev != next)) {
541                 next->timestamp = next->last_ran = now;
542 @@ -4664,6 +4725,7 @@
543         get_task_struct(p);
544         read_unlock(&tasklist_lock);
545  
546 +
547         retval = -EPERM;
548         if ((current->euid != p->euid) && (current->euid != p->uid) &&
549                         !capable(CAP_SYS_NICE))
550 @@ -5032,6 +5094,7 @@
551         jiffies_to_timespec(p->policy == SCHED_FIFO ?
552                                 0 : task_timeslice(p), &t);
553         read_unlock(&tasklist_lock);
554 +
555         retval = copy_to_user(interval, &t, sizeof(t)) ? -EFAULT : 0;
556  out_nounlock:
557         return retval;
558 @@ -7275,3 +7338,9 @@
559  }
560  
561  #endif
562 +
563 +#ifdef CONFIG_CHOPSTIX
564 +void (*rec_event)(void *,unsigned int);
565 +EXPORT_SYMBOL(rec_event);
566 +EXPORT_SYMBOL(in_sched_functions);
567 +#endif
568 diff -Nurb linux-2.6.22-580/mm/slab.c linux-2.6.22-590/mm/slab.c
569 --- linux-2.6.22-580/mm/slab.c  2008-04-30 09:29:26.000000000 -0400
570 +++ linux-2.6.22-590/mm/slab.c  2008-04-30 09:29:41.000000000 -0400
571 @@ -110,11 +110,13 @@
572  #include       <linux/fault-inject.h>
573  #include       <linux/rtmutex.h>
574  #include       <linux/reciprocal_div.h>
575 +#include <linux/arrays.h>
576  
577  #include       <asm/cacheflush.h>
578  #include       <asm/tlbflush.h>
579  #include       <asm/page.h>
580  
581 +
582  /*
583   * DEBUG       - 1 for kmem_cache_create() to honour; SLAB_RED_ZONE & SLAB_POISON.
584   *               0 for faster, smaller code (especially in the critical paths).
585 @@ -249,6 +251,14 @@
586         void *addr;
587  };
588  
589 +extern void (*rec_event)(void *,unsigned int);
590 +struct event_spec {
591 +       unsigned long pc;
592 +       unsigned long dcookie; 
593 +       unsigned count;
594 +       unsigned char reason;
595 +};
596 +
597  /*
598   * struct array_cache
599   *
600 @@ -3443,6 +3453,19 @@
601         local_irq_restore(save_flags);
602         objp = cache_alloc_debugcheck_after(cachep, flags, objp, caller);
603         prefetchw(objp);
604 +#ifdef CONFIG_CHOPSTIX
605 +       if (rec_event && objp) {
606 +               struct event event;
607 +               struct event_spec espec;
608 +
609 +               espec.reason = 0; /* alloc */
610 +               event.event_data=&espec;
611 +               event.task = current;
612 +               espec.pc=caller;
613 +               event.event_type=4; 
614 +               (*rec_event)(&event, cachep->buffer_size);
615 +       }
616 +#endif
617  
618         return objp;
619  }
620 @@ -3549,13 +3572,26 @@
621   * Release an obj back to its cache. If the obj has a constructed state, it must
622   * be in this state _before_ it is released.  Called with disabled ints.
623   */
624 -static inline void __cache_free(struct kmem_cache *cachep, void *objp)
625 +static inline void __cache_free(struct kmem_cache *cachep, void *objp, void *caller)
626  {
627         struct array_cache *ac = cpu_cache_get(cachep);
628  
629         check_irq_off();
630 -       objp = cache_free_debugcheck(cachep, objp, __builtin_return_address(0));
631 +       objp = cache_free_debugcheck(cachep, objp, caller);
632         vx_slab_free(cachep);
633 +#ifdef CONFIG_CHOPSTIX
634 +       if (rec_event && objp) {
635 +               struct event event;
636 +               struct event_spec espec;
637 +
638 +               espec.reason = 1; /* free */
639 +               event.event_data=&espec;
640 +               event.task = current;
641 +               espec.pc=caller;
642 +               event.event_type=4; 
643 +               (*rec_event)(&event, cachep->buffer_size);
644 +       }
645 +#endif
646  
647         if (cache_free_alien(cachep, objp))
648                 return;
649 @@ -3651,16 +3687,19 @@
650                         __builtin_return_address(0));
651  }
652  EXPORT_SYMBOL(kmem_cache_alloc_node);
653 -
654  static __always_inline void *
655  __do_kmalloc_node(size_t size, gfp_t flags, int node, void *caller)
656  {
657         struct kmem_cache *cachep;
658 +       void *ret;
659 +
660  
661         cachep = kmem_find_general_cachep(size, flags);
662         if (unlikely(cachep == NULL))
663                 return NULL;
664 -       return kmem_cache_alloc_node(cachep, flags, node);
665 +       ret = kmem_cache_alloc_node(cachep, flags, node);
666 +       
667 +       return ret;
668  }
669  
670  #ifdef CONFIG_DEBUG_SLAB
671 @@ -3696,6 +3735,7 @@
672                                           void *caller)
673  {
674         struct kmem_cache *cachep;
675 +       void *ret;
676  
677         /* If you want to save a few bytes .text space: replace
678          * __ with kmem_.
679 @@ -3705,9 +3745,10 @@
680         cachep = __find_general_cachep(size, flags);
681         if (unlikely(cachep == NULL))
682                 return NULL;
683 -       return __cache_alloc(cachep, flags, caller);
684 -}
685 +       ret = __cache_alloc(cachep, flags, caller);
686  
687 +       return ret;
688 +}
689  
690  #ifdef CONFIG_DEBUG_SLAB
691  void *__kmalloc(size_t size, gfp_t flags)
692 @@ -3723,10 +3764,17 @@
693  EXPORT_SYMBOL(__kmalloc_track_caller);
694  
695  #else
696 +#ifdef CONFIG_CHOPSTIX
697 +void *__kmalloc(size_t size, gfp_t flags)
698 +{
699 +       return __do_kmalloc(size, flags, __builtin_return_address(0));
700 +}
701 +#else
702  void *__kmalloc(size_t size, gfp_t flags)
703  {
704         return __do_kmalloc(size, flags, NULL);
705  }
706 +#endif
707  EXPORT_SYMBOL(__kmalloc);
708  #endif
709  
710 @@ -3792,7 +3840,7 @@
711  
712         local_irq_save(flags);
713         debug_check_no_locks_freed(objp, obj_size(cachep));
714 -       __cache_free(cachep, objp);
715 +       __cache_free(cachep, objp,__builtin_return_address(0));
716         local_irq_restore(flags);
717  }
718  EXPORT_SYMBOL(kmem_cache_free);
719 @@ -3817,7 +3865,7 @@
720         kfree_debugcheck(objp);
721         c = virt_to_cache(objp);
722         debug_check_no_locks_freed(objp, obj_size(c));
723 -       __cache_free(c, (void *)objp);
724 +       __cache_free(c, (void *)objp,__builtin_return_address(0));
725         local_irq_restore(flags);
726  }
727  EXPORT_SYMBOL(kfree);