Re: [RFC PATCH 1/2] add 99memdebug-ko dracut module

Dave Young
2016-11-04T08:23:28Z

Hi Xunlei,

> > If change the logic a bit, it will be clear:
> >
> > is_trace_prepared()
> > {
> > this function only check if tracing is enabled and events matched.
> > }
> >
> > prepare_trace()
> > {
> > enable and prepare trace
> > }
> >
> > parse_trace_data()
> > {
> >
> > }
> >
> > if is_trace_prepared == true; then
> > parse_trace_data
> > else
> > prepare_trace
> > fi
> >
> > So in cmdline hook is_trace_prepared is false so the script only prepare
> > trace and enable tracing, in latter hooks it will parse trace data.
> >
> > But there should be another function to disable trace before pivot root.
>
> OK
>
> We should find a neat way to disable the trace function, what do you think the following way?
> Change show_memstats() and make_trace_mem() as follows:
> make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
> ... ...
> make_trace_mem "hook pre-pivot" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
> make_trace_mem "hook pre-pivot" '4+:komemfinish' # cleanup trace used by showkomem after use.
>
> show_memstats()
> ... ...
>
> + komem)
> + showkomem
> + ;;
> + komemfinish)
> + # disable trace after use.
> + showkomem finish
> + ;;
> esac
>

Hmm, I'm not sure it is worth, maybe add a function like
cleanup_trace_mem() is enough and we can add it just before cleanup
hook which is designed for cleanup purpose, cleanup hook is sourced
after pre-pivot so that it will still work for adding trace in any
pre-pivot scripts.

Thanks
Dave