Re: [PATCH] enable/disable profiling via proc/sysctl

From: William Lee Irwin III
Date: Mon Jun 27 2005 - 12:21:16 EST


On Mon, Jun 27, 2005 at 03:13:13PM +0300, Levent Serinol wrote:
> +#ifdef CONFIG_SMP
> +int remove_hash_tables(void)
> +{
> + int cpu;
> +
> +
> + for_each_online_cpu(cpu) {
> + struct page *page;
> +
> + if (per_cpu(cpu_profile_hits, cpu)[0]) {
> + page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[0]);
> + per_cpu(cpu_profile_hits, cpu)[0] = NULL;
> + __free_page(page);
> + }
> + if (per_cpu(cpu_profile_hits, cpu)[1]) {
> + page = virt_to_page(per_cpu(cpu_profile_hits, cpu)[1]);
> + per_cpu(cpu_profile_hits, cpu)[1] = NULL;
> + __free_page(page);
> + }
> + }
> + return -1;

Big problem. Timer interrupts can be firing while this is in progress.
The reason for profile_nop() is so that the code I have running during
timer interrupts (protected by local_irq_save()) runs to completion,
where it will afterward discover the flags or variables set to updated
states. You'll probably have to add more (e.g. memory barriers) since
you can tolerate less once you're dynamically allocating and freeing etc.


On Mon, Jun 27, 2005 at 03:13:13PM +0300, Levent Serinol wrote:
> @@ -560,7 +668,11 @@ static int __init create_proc_profile(vo
> return 0;
> entry->proc_fops = &proc_profile_operations;
> entry->size = (1+prof_len) * sizeof(atomic_t);
> - hotcpu_notifier(profile_cpu_callback, 0);
> +#ifdef CONFIG_HOTPLUG_CPU
> + register_cpu_notifier(&profile_cpu_notifier);
> +#endif
> + profile_params[0] = prof_on;
> + profile_params[1] = prof_shift;
> return 0;
> }
> module_init(create_proc_profile);

hotcpu_notifier() is there to avoid the #ifdef; you shouldn't need to
rearrange that.

Anyway, just keep fixing it up. There should be a few more after this.


-- wli
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/