trap "destroy" SIGINT SIGTERM
lttng enable-channel -k chan1 --subbuf-size=8M >/dev/null
-lttng enable-event -s $SESSION_NAME -k sched_switch,block_rq_complete,block_rq_issue,block_bio_remap,block_bio_backmerge,netif_receive_skb,net_dev_xmit,sched_process_fork,sched_process_exec,lttng_statedump_process_state,lttng_statedump_file_descriptor,lttng_statedump_block_device,writeback_pages_written,mm_vmscan_wakeup_kswapd,mm_page_free,mm_page_alloc,block_dirty_buffer,irq_handler_entry,irq_handler_exit,softirq_entry,softirq_exit,softirq_raise -c chan1 >/dev/null
+
+# events that always work
+lttng enable-event -s $SESSION_NAME -k sched_switch,block_rq_complete,block_rq_issue,block_bio_remap,block_bio_backmerge,netif_receive_skb,net_dev_xmit,sched_process_fork,sched_process_exec,lttng_statedump_process_state,lttng_statedump_file_descriptor,lttng_statedump_block_device,mm_vmscan_wakeup_kswapd,mm_page_free,mm_page_alloc,block_dirty_buffer,irq_handler_entry,irq_handler_exit,softirq_entry,softirq_exit,softirq_raise -c chan1 >/dev/null
[[ $? != 0 ]] && exit 2
+
+# events that might fail on specific kernels and that are not mandatory
+lttng enable-event -s $SESSION_NAME -k writeback_pages_written -c chan1 >/dev/null 2>&1
+[[ $? != 0 ]] && echo "Warning: Optional event writeback_pages_written could not be enabled, everything will still work"
+
lttng enable-event -s $SESSION_NAME -k -c chan1 --syscall -a >/dev/null
[[ $? != 0 ]] && exit 2
# if you want to add Perf counters, do something like that :