public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Cc: Andi Kleen <andi@firstfloor.org>,
	jbaron@redhat.com, rostedt@goodmis.com,
	linux-kernel@vger.kernel.org, mingo@elte.hu, hpa@zytor.com,
	tglx@linutronix.de, roland@redhat.com, rth@redhat.com,
	mhiramat@redhat.com, avi@redhat.com, davem@davemloft.net,
	vgoyal@redhat.com, sam@ravnborg.org, tony@bakeyournoodle.com,
	Andi Kleen <ak@linux.intel.com>
Subject: Re: [PATCH 2/2] Rewrite jump_label.c to use binary search
Date: Wed, 22 Sep 2010 13:57:33 +0200	[thread overview]
Message-ID: <20100922115729.GA5336@nowhere> (raw)
In-Reply-To: <20100922113114.GA14179@Krystal>

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.


  parent reply	other threads:[~2010-09-22 11:57 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 10:08 [PATCH 1/2] Add for_each_module iterator function Andi Kleen
2010-09-22 10:08 ` [PATCH 2/2] Rewrite jump_label.c to use binary search Andi Kleen
2010-09-22 11:31   ` Mathieu Desnoyers
2010-09-22 11:56     ` Andi Kleen
2010-09-22 12:04       ` Andi Kleen
2010-09-22 15:02         ` Mathieu Desnoyers
2010-09-22 15:07           ` Mathieu Desnoyers
2010-09-22 15:43             ` Jason Baron
2010-09-22 15:28           ` Jason Baron
2010-09-22 19:19             ` Mathieu Desnoyers
2010-09-22 13:46       ` Jason Baron
2010-09-22 18:14       ` Jason Baron
2010-09-22 11:57     ` Frederic Weisbecker [this message]
2010-09-22 16:12   ` H. Peter Anvin
2010-09-22 19:43     ` Mathieu Desnoyers
2010-09-22 20:06       ` H. Peter Anvin
2010-09-22 20:41         ` Mathieu Desnoyers
2010-09-22 20:54           ` H. Peter Anvin
2010-09-22 12:25 ` [PATCH 1/2] Add for_each_module iterator function Thomas Gleixner
2010-09-22 12:52   ` Andi Kleen
2010-09-22 14:03   ` Mathieu Desnoyers

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=20100922115729.GA5336@nowhere \
    --to=fweisbec@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=avi@redhat.com \
    --cc=davem@davemloft.net \
    --cc=hpa@zytor.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.com \
    --cc=rth@redhat.com \
    --cc=sam@ravnborg.org \
    --cc=tglx@linutronix.de \
    --cc=tony@bakeyournoodle.com \
    --cc=vgoyal@redhat.com \
    /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