Skip to content

Commit

Permalink
DEBUG percpu-recount: Crude printk dumps
Browse files Browse the repository at this point in the history
It should not be too noisy since only cgroups use the confirm_kill
callback hence percpu_ref_call_confirm_rcu() should only run once per
css.

Signed-off-by: Michal Koutný <mkoutny@suse.com>
  • Loading branch information
Werkov committed May 26, 2022
1 parent ef13021 commit ebd2282
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions kernel/cgroup/cgroup.c
Expand Up @@ -5552,7 +5552,9 @@ static void css_killed_work_fn(struct work_struct *work)

do {
offline_css(css);
trace_printk("%p pre-put %lu\n", css, atomic_long_read(&css->refcnt.data->count));
css_put(css);
trace_printk("%p post-put %lu\n", css, atomic_long_read(&css->refcnt.data->count));
/* @css can't go away while we're holding cgroup_mutex */
css = css->parent;
} while (css && atomic_dec_and_test(&css->online_cnt));
Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/trace.c
Expand Up @@ -134,7 +134,7 @@ cpumask_var_t __read_mostly tracing_buffer_mask;
* Set 2 if you want to dump the buffer of the CPU that triggered oops
*/

enum ftrace_dump_mode ftrace_dump_on_oops;
enum ftrace_dump_mode ftrace_dump_on_oops = DUMP_ALL;

/* When set, tracing will stop when a WARN*() is hit */
int __disable_trace_on_warning;
Expand Down
6 changes: 5 additions & 1 deletion lib/percpu-refcount.c
Expand Up @@ -152,15 +152,19 @@ static void percpu_ref_call_confirm_rcu(struct rcu_head *rcu)
struct percpu_ref_data, rcu);
struct percpu_ref *ref = data->ref;

trace_printk("pre-conf %lu\n", atomic_long_read(&data->count));
data->confirm_switch(ref);
data->confirm_switch = NULL;
trace_printk("post-conf %lu\n", atomic_long_read(&data->count));
wake_up_all(&percpu_ref_switch_waitq);

if (!data->allow_reinit)
__percpu_ref_exit(ref);

trace_printk("pre-put %lu\n", atomic_long_read(&data->count));
/* drop ref from percpu_ref_switch_to_atomic() */
percpu_ref_put(ref);
trace_printk("post-put %lu\n", atomic_long_read(&data->count));
}

static void percpu_ref_switch_to_atomic_rcu(struct rcu_head *rcu)
Expand All @@ -176,7 +180,7 @@ static void percpu_ref_switch_to_atomic_rcu(struct rcu_head *rcu)
for_each_possible_cpu(cpu)
count += *per_cpu_ptr(percpu_count, cpu);

pr_debug("global %lu percpu %lu\n",
trace_printk("global %lu percpu %lu\n",
atomic_long_read(&data->count), count);

/*
Expand Down

0 comments on commit ebd2282

Please sign in to comment.