From: Andrew Morton <akpm@digeo.com>
To: Tom Rini <trini@kernel.crashing.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC] Templates and tweaks (for size performance and more)
Date: Thu, 07 Nov 2002 11:27:25 -0800 [thread overview]
Message-ID: <3DCABE9D.F71530DB@digeo.com> (raw)
In-Reply-To: 20021107190910.GC6164@opus.bloom.county
Tom Rini wrote:
>
> Comments?
You missed this little fella:
text data bss dec hex filename
1735 1120 131104 133959 20b47 kernel/pid.o
Have a controversial patch which takes it to:
text data bss dec hex filename
1614 1120 2080 4814 12ce kernel/pid.o
include/linux/pid.h | 1 +
kernel/pid.c | 24 +++++++++++++-----------
2 files changed, 14 insertions(+), 11 deletions(-)
--- 25/kernel/pid.c~unbloat-pid Sun Oct 27 23:43:15 2002
+++ 25-akpm/kernel/pid.c Sun Oct 27 23:43:15 2002
@@ -22,11 +22,13 @@
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/init.h>
+#include <linux/hash.h>
#include <linux/bootmem.h>
-#define PIDHASH_SIZE 4096
-#define pid_hashfn(nr) ((nr >> 8) ^ nr) & (PIDHASH_SIZE - 1)
-static struct list_head pid_hash[PIDTYPE_MAX][PIDHASH_SIZE];
+#define PIDHASH_SHIFT 8
+#define PIDHASH_SIZE (1 << PIDHASH_SHIFT)
+#define pid_hashfn(nr, type) hash_long(nr * PIDTYPE_MAX + type, PIDHASH_SHIFT)
+static struct list_head pid_hash[PIDHASH_SIZE];
int pid_max = PID_MAX_DEFAULT;
int last_pid;
@@ -146,12 +148,12 @@ failure:
inline struct pid *find_pid(enum pid_type type, int nr)
{
- struct list_head *elem, *bucket = &pid_hash[type][pid_hashfn(nr)];
+ struct list_head *elem, *bucket = &pid_hash[pid_hashfn(nr, type)];
struct pid *pid;
__list_for_each(elem, bucket) {
pid = list_entry(elem, struct pid, hash_chain);
- if (pid->nr == nr)
+ if (pid->nr == nr && pid->type == type)
return pid;
}
return NULL;
@@ -173,11 +175,12 @@ int attach_pid(task_t *task, enum pid_ty
else {
pid = &task->pids[type].pid;
pid->nr = nr;
+ pid->type = type;
atomic_set(&pid->count, 1);
INIT_LIST_HEAD(&pid->task_list);
pid->task = task;
get_task_struct(task);
- list_add(&pid->hash_chain, &pid_hash[type][pid_hashfn(nr)]);
+ list_add(&pid->hash_chain, &pid_hash[pid_hashfn(nr, type)]);
}
list_add_tail(&task->pids[type].pid_chain, &pid->task_list);
task->pids[type].pidptr = pid;
@@ -260,7 +263,7 @@ void switch_exec_pids(task_t *leader, ta
void __init pidhash_init(void)
{
- int i, j;
+ int i;
/*
* Allocate PID 0, and hash it via all PID types:
@@ -269,9 +272,8 @@ void __init pidhash_init(void)
set_bit(0, pidmap_array->page);
atomic_dec(&pidmap_array->nr_free);
- for (i = 0; i < PIDTYPE_MAX; i++) {
- for (j = 0; j < PIDHASH_SIZE; j++)
- INIT_LIST_HEAD(&pid_hash[i][j]);
+ for (i = 0; i < ARRAY_SIZE(pid_hash); i++)
+ INIT_LIST_HEAD(&pid_hash[i]);
+ for (i = 0; i < PIDTYPE_MAX; i++)
attach_pid(current, i, 0);
- }
}
--- 25/include/linux/pid.h~unbloat-pid Sun Oct 27 23:43:15 2002
+++ 25-akpm/include/linux/pid.h Sun Oct 27 23:43:15 2002
@@ -13,6 +13,7 @@ enum pid_type
struct pid
{
int nr;
+ enum pid_type type;
atomic_t count;
struct task_struct *task;
struct list_head task_list;
.
next prev parent reply other threads:[~2002-11-07 19:20 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-07 19:09 [RFC] Templates and tweaks (for size performance and more) Tom Rini
2002-11-07 19:27 ` Andrew Morton [this message]
2002-11-07 19:33 ` Tom Rini
2002-11-07 19:44 ` Andrew Morton
2002-11-07 19:54 ` Tom Rini
2002-11-07 21:03 ` Russell King
2002-11-07 21:08 ` Russell King
2002-11-07 22:10 ` Tom Rini
2002-11-07 23:57 ` Tom Rini
2002-11-07 22:06 ` Tom Rini
2002-11-08 0:29 ` Russell King
2002-11-08 0:37 ` Tom Rini
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=3DCABE9D.F71530DB@digeo.com \
--to=akpm@digeo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=trini@kernel.crashing.org \
/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.