[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100922115729.GA5336@nowhere>
Date: Wed, 22 Sep 2010 13:57:33 +0200
From: Frederic Weisbecker <fweisbec@...il.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: Andi Kleen <andi@...stfloor.org>, jbaron@...hat.com,
rostedt@...dmis.com, linux-kernel@...r.kernel.org, mingo@...e.hu,
hpa@...or.com, tglx@...utronix.de, roland@...hat.com,
rth@...hat.com, mhiramat@...hat.com, avi@...hat.com,
davem@...emloft.net, vgoyal@...hat.com, sam@...nborg.org,
tony@...eyournoodle.com, Andi Kleen <ak@...ux.intel.com>
Subject: Re: [PATCH 2/2] Rewrite jump_label.c to use binary search
On Wed, Sep 22, 2010 at 07:31:14AM -0400, Mathieu Desnoyers wrote:
> > -static struct jump_label_entry *add_jump_label_entry(jump_label_t key, int nr_entries, struct jump_entry *table)
> > +void patch_jump_table(unsigned long key, enum jump_label_type type,
> > + struct jump_entry *start, struct jump_entry *stop)
> > {
> > - struct hlist_head *head;
> > - struct jump_label_entry *e;
> > - u32 hash;
> > -
> > - e = get_jump_label_entry(key);
> > - if (e)
> > - return ERR_PTR(-EEXIST);
> > -
> > - e = kmalloc(sizeof(struct jump_label_entry), GFP_KERNEL);
> > - if (!e)
> > - return ERR_PTR(-ENOMEM);
> > -
> > - hash = jhash((void *)&key, sizeof(jump_label_t), 0);
> > - head = &jump_label_table[hash & (JUMP_LABEL_TABLE_SIZE - 1)];
> > - e->key = key;
> > - e->table = table;
> > - e->nr_entries = nr_entries;
> > - INIT_HLIST_HEAD(&(e->modules));
> > - hlist_add_head(&e->hlist, head);
> > - return e;
> > + struct jump_entry *entry = search_jump_table(start, stop, key);
> > + if (!entry)
> > + return;
> > + while (entry > start && entry[-1].key == key)
> > + entry--;
>
> OK, I like the way it handles patching of multiple entries with the same
> key at once. Sorting really makes sense here.
>
> > + for (; entry < stop && entry->key == key; entry++)
> > + if (kernel_text_address(entry->code))
>
> This does not work for modules I'm afraid, only for the core kernel. You
> should test for __module_text_address() somewhere.
No, look:
int kernel_text_address(unsigned long addr)
{
if (core_kernel_text(addr))
return 1;
return is_module_text_address(addr);
}
> Dumb question: why do you need this test at all ?
I wonder about that too.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists