lkml.org 
[lkml]   [2002]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC] Templates and tweaks (for size performance and more)
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;
.
-
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/

\
 
 \ /
  Last update: 2005-03-22 13:30    [W:0.150 / U:0.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site