mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mikael Pettersson <mikpe@user.it.uu.se>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: module changes
Date: Tue, 18 Feb 2003 16:56:11 +0100	[thread overview]
Message-ID: <15954.22427.557293.353363@gargle.gargle.HOWL> (raw)
In-Reply-To: <20030218072006.4C6502C054@lists.samba.org>

Rusty Russell writes:
 > In message <20030217213221.3103.qmail@eklektix.com> you write:
 > > I had a quick question: is the inability to declare per-CPU variables in
 > > modules going to be permanent?
 > 
 > <sigh>
 > 
 > I'd really like to fix it, but that's *hard*.
 > 
 > <think think think, ask Paulus>
 > 
 > There might be a neater way, and there's definitely a more
 > space-efficient way, but this is a start (the wastage is small as long
 > as there are only a few per-cpu vars, as there are at the moment).
 > 
 > Rusty.
 > --
 >   Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
 > 
 > Name: per-cpu support inside modules
 > Author: Rusty Russell
 > Status: Tested on 2.5.62
 > 
 > D: This adds percpu support for modules.  A module cannot have more
 > D: percpu data than the base kernel does (on my kernel 5636 bytes).

This limitation is quite horrible.

Does the implementation have to be perfect? The per_cpu API can easily
be simulated using good old NR_CPUS arrays:

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,8) && !defined(MODULE)
#include <linux/percpu.h>	/* why doesn't this work for modules? */
#else
/* Simulate per_cpu() for older kernels or modular builds. */
#define DEFINE_PER_CPU(type, name) \
	__typeof__(type) name[NR_CPUS] __cacheline_aligned
#define per_cpu(var, cpu)	((var)[(cpu)])
#endif

Yes it wastes space. Big deal. Rather that than arbitrary limitations.

/Mikael

  reply	other threads:[~2003-02-18 15:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030217213221.3103.qmail@eklektix.com>
2003-02-18  7:19 ` Rusty Russell
2003-02-18 15:56   ` Mikael Pettersson [this message]
2003-02-18 16:05     ` John Levon
2003-02-18 22:24     ` Rusty Russell
2003-02-19  3:51       ` Andrew Morton
2003-02-19  4:28         ` Rusty Russell
2003-02-19 12:52       ` Mikael Pettersson
2003-02-20  0:15         ` Rusty Russell

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=15954.22427.557293.353363@gargle.gargle.HOWL \
    --to=mikpe@user.it.uu.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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

all inboxes | Powered by JetHome®