All of lore.kernel.org
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: raz ben yehuda <raziebe@gmail.com>
Cc: riel@redhat.com, mingo@elte.hu, peterz@infradead.org,
	wiseman@macs.biu.ac.il, lkml <linux-kernel@vger.kernel.org>
Subject: Re: Subject:[ PATCH 001:003] OFFSCHED CORE
Date: Wed, 26 Aug 2009 00:29:58 -0700	[thread overview]
Message-ID: <m163cbm3rd.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <1250983786.5688.23.camel@raz> (raz ben yehuda's message of "Sun\, 23 Aug 2009 02\:29\:46 +0300")

raz ben yehuda <raziebe@gmail.com> writes:

> 		OFFSCHED support.
>
> . A callback invoked just before halting the processor.
> . SMP alternative work-around. we do not run smp alternatives if we are
>    left with a single processor.
> . A set of utilities used by the offsched driver.

Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>


Cpu hotunplug is mostly broken when it comes to irqs.
Building on and extending broken code is just asking for trouble,
especially for out of tree code.

> process.c |  109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> smpboot.c |   13 +++++--
> 2 files changed, 118 insertions(+), 4 deletions(-)
>
> Signed-off-by: raziebe@gmail.com
> ---
> diff -X 2.6.30-offsched/Documentation/dontdiff -urN tmp/linux-2.6.30/arch/x86/kernel/process.c 2.6.30-offsched/arch/x86/kernel/process.c
> --- tmp/linux-2.6.30/arch/x86/kernel/process.c	2009-06-10 06:05:27.000000000 +0300
> +++ 2.6.30-offsched/arch/x86/kernel/process.c	2009-08-21 22:02:44.000000000 +0300
> @@ -613,3 +613,112 @@
>  }
>  early_param("idle", idle_setup);
>  
> +#ifdef CONFIG_HOTPLUG_CPU
> +struct hotplug_cpu{
> +	long flags;
> +	void (*hotplug_cpu_dead)(void);
> +};
> +
> +static long 	offsched_services;
> +
> +#define CPU_OFFSCHED		31
> +#define CPU_OFFSCHED_KMEM	30
> +#define SERVICE_TIMER		01
> +#define SERVICE_NAPI		02
> +
> +DEFINE_PER_CPU(struct hotplug_cpu, offschedcpu);
> +
> +void unregister_offsched(int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	cpu->hotplug_cpu_dead = NULL;
> +	clear_bit(CPU_OFFSCHED, &cpu->flags);
> +}
> +EXPORT_SYMBOL_GPL(unregister_offsched);
> +
> +int is_offsched(int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	return test_bit(CPU_OFFSCHED, &cpu->flags);
> +}
> +EXPORT_SYMBOL_GPL(is_offsched);
> +
> +int is_offsched_kmem(int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	return test_bit(CPU_OFFSCHED_KMEM, &cpu->flags);
> +}
> +EXPORT_SYMBOL_GPL(is_offsched_kmem);
> +
> +void set_offsched_kmem(int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	set_bit(CPU_OFFSCHED_KMEM, &cpu->flags);
> +}
> +EXPORT_SYMBOL_GPL(set_offsched_kmem);
> +
> +void unset_offsched_kmem(int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	clear_bit(CPU_OFFSCHED_KMEM, &cpu->flags);
> +}
> +EXPORT_SYMBOL_GPL(unset_offsched_kmem);
> +
> +int register_offsched(void (*offsched_callback)(void), int cpuid)
> +{
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	if (is_offsched(cpuid))
> +		return -1;
> +	cpu->hotplug_cpu_dead = offsched_callback;
> +	set_bit(CPU_OFFSCHED, &cpu->flags);
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(register_offsched);
> +
> +void run_offsched(void)
> +{
> +	int cpuid = raw_smp_processor_id();
> +	struct hotplug_cpu *cpu = &per_cpu(offschedcpu, cpuid);
> +	cpu->hotplug_cpu_dead();
> +}
> +
> +int  offsched_is_napi_avail(void)
> +{
> +	return SERVICE_NAPI & offsched_services;
> +}
> +
> +int (*offsched_rule)(void *);
> +EXPORT_SYMBOL(offsched_rule);
> +/*
> +* if we a have filter than apply filter.
> +* return 0 if packet should go to kernel
> +* return 1 if packet should go to offsched.
> +*/
> +int offsched_pkt(void *s)
> +{
> +	if (offsched_rule)
> +		return offsched_rule(s);
> +	return 0;
> +}
> +
> +void offsched_register_napi(void)
> +{
> +	offsched_services |= SERVICE_NAPI;
> +}
> +EXPORT_SYMBOL_GPL(offsched_register_napi);
> +
> +void offsched_unregister_napi(void)
> +{
> +	offsched_services &= ~SERVICE_NAPI;
> +}
> +EXPORT_SYMBOL_GPL(offsched_unregister_napi);
> +
> +/*
> + * napi scheudule is called in offsched context.
> +*/
> +void offsched_napi_schedule(void *n)
> +{
> +
> +}
> +
> +#endif
> diff -X 2.6.30-offsched/Documentation/dontdiff -urN tmp/linux-2.6.30/arch/x86/kernel/smpboot.c 2.6.30-offsched/arch/x86/kernel/smpboot.c
> --- tmp/linux-2.6.30/arch/x86/kernel/smpboot.c	2009-06-10 06:05:27.000000000 +0300
> +++ 2.6.30-offsched/arch/x86/kernel/smpboot.c	2009-07-25 13:59:19.000000000 +0300
> @@ -39,6 +39,8 @@
>   *	Glauber Costa		:	i386 and x86_64 integration
>   */
>  
> +#define DEBUG
> +
>  #include <linux/init.h>
>  #include <linux/smp.h>
>  #include <linux/module.h>
> @@ -686,8 +688,8 @@
>  	};
>  
>  	INIT_WORK(&c_idle.work, do_fork_idle);
> -
> -	alternatives_smp_switch(1);
> +	if (!is_offsched(cpu))
> +		alternatives_smp_switch(1);
>  
>  	c_idle.idle = get_idle_for_cpu(cpu);
>  
> @@ -1283,8 +1285,9 @@
>  	for (i = 0; i < 10; i++) {
>  		/* They ack this in play_dead by setting CPU_DEAD */
>  		if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
> -			printk(KERN_INFO "CPU %d is now offline\n", cpu);
> -			if (1 == num_online_cpus())
> +			printk(KERN_INFO "CPU %d is now offline %s\n", cpu,
> +				is_offsched(cpu) ? "and OFFSCHED" : "");
> +			if (1 == num_online_cpus() && !is_offsched(cpu))
>  				alternatives_smp_switch(0);
>  			return;
>  		}
> @@ -1313,6 +1316,8 @@
>  void native_play_dead(void)
>  {
>  	play_dead_common();
> +	if (is_offsched(raw_smp_processor_id()))
> +		run_offsched();
>  	wbinvd_halt();
>  }
>  
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

  reply	other threads:[~2009-08-26  7:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-22 23:29 Subject:[ PATCH 001:003] OFFSCHED CORE raz ben yehuda
2009-08-26  7:29 ` Eric W. Biederman [this message]
2009-08-26 10:51   ` raz ben yehuda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m163cbm3rd.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=raziebe@gmail.com \
    --cc=riel@redhat.com \
    --cc=wiseman@macs.biu.ac.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.