public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Heiko.Carstens@de.ibm.com
To: Anton Blanchard <anton@linuxcare.com.au>
Cc: Pavel Machek <pavel@suse.cz>, Alan Cox <alan@lxorguk.ukuu.org.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: CPU attachent and detachment in a running Linux system
Date: Thu, 21 Dec 2000 14:16:58 +0100	[thread overview]
Message-ID: <C12569BC.0048F80B.00@d12mta01.de.ibm.com> (raw)





Hi,

>> That's a good point and it would probably work for attachment of cpus,
but
>> it won't work for detachment because there are some data structures that
>> need to be updated if a cpu gets detached. For example it would be nice
>> [...]
>> So at least for detaching it would make sense to register functions
which
>> will be called whenever a cpu gets detached.
>I remember someone from SGI had a patch to merge all the per cpu
structures
>together which would make this easier. It would also save bytes especially
>on machines like the e10k where we must have NR_CPUS = 64.

Thanks for your comment, but I thought of an additional kernel parameter
max_dyn_cpus which would limit the maximum number of cpus that are allowed
to run. This way at least the waste of dynamically allocated memory which
depends on smp_num_cpus will be limited. This could be done by replacing
appropriate occurrences of smp_num_cpus with a macro MAX_DYN_CPUS which
could be defined the following way:

#ifdef CONFIG_DYN_CPU
extern volatile int smp_num_cpus; /* smp_num_cpus may change */
extern int max_dyn_cpus;
#define MAX_DYN_CPUS max_dyn_cpus
#else
extern int smp_num_cpus; /* smp_num_cpus won't change */
#define MAX_DYN_CPUS smp_num_cpus
#endif

Comming back to the question on how to realize an interface where per cpu
dependent parts of the kernel could register a function whenever a cpu gets
detached I think the following approach would work fine:

To register a function the following structure would be used:

typedef struct smp_dyncpu_func_s smp_dyncpu_func_t;
struct smp_dyncpu_func_s {
       void (*f)(int);
       smp_dyncpu_func_t *next;
};


The function which would be called when a function needs to be registered
would look like this:

smp_dyncpu_func_t *dyncpu_func; /* NULL */
...
void smp_register_dyncpu_func(smp_dyncpu_func_t *func)
{
       func->next = dyncpu_func;
       dyncpu_func = func;
       return;
}


And finally every part of the kernel that needs to register a function
which would be used to clean up per cpu data structures would have some
additional code added which would look like this:

static smp_dyncpu_func_t smp_cleanup_func;
...
void local_dyncpu_handler(int killed_cpu){...}
...
static int __init local_dyncpu_init(void)
{
       smp_cleanup_func.f = &local_dyncpu_handler;
       smp_register_dyncpu_func(&smp_cleanup_func);
       return 0;
}
...
__initcall(local_dyncpu_init);

Thinking of modules which may have also per cpu structures there could
be a second function which allows to unregister prior registered
functions.

So what do you think of this approach? I would appreciate any comments
on this.

Best regards,
Heiko


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

             reply	other threads:[~2000-12-21 18:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-21 13:16 Heiko.Carstens [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-12-18  8:00 CPU attachent and detachment in a running Linux system Heiko.Carstens
2000-12-18 19:34 ` ferret
2000-12-21  3:21 ` Anton Blanchard
2000-12-12  6:42 Heiko.Carstens
2000-12-12 12:32 ` Alan Cox
2000-12-15 22:31 ` Pavel Machek
2000-12-11 18:48 Per Jessen
2000-12-11 14:03 Heiko.Carstens
2000-12-11 18:11 ` Matthew D. Pitts
2000-12-11 20:37 ` J . A . Magallon

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=C12569BC.0048F80B.00@d12mta01.de.ibm.com \
    --to=heiko.carstens@de.ibm.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=anton@linuxcare.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox