public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Alexey Dobriyan <adobriyan@sw.ru>
Cc: rusty@rustcorp.com.au, pmarques@grupopie.com,
	linux-kernel@vger.kernel.org, devel@openvz.org
Subject: Re: [PATCH 5/5] Fix race between cat /proc/slab_allocators and rmmod
Date: Tue, 3 Apr 2007 17:08:27 -0700	[thread overview]
Message-ID: <20070403170827.a32f97f1.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070402150316.GE6735@localhost.sw.ru>

On Mon, 2 Apr 2007 19:03:16 +0400
Alexey Dobriyan <adobriyan@sw.ru> wrote:

> +int lookup_module_symbol_attrs(unsigned long addr, unsigned long *size,
> +			unsigned long *offset, char *modname, char *name)
> +{
> +	struct module *mod;
> +
> +	mutex_lock(&module_mutex);
> +	list_for_each_entry(mod, &modules, list) {
> +		if (within(addr, mod->module_init, mod->init_size) ||
> +		    within(addr, mod->module_core, mod->core_size)) {
> +			const char *sym;
> +
> +			sym = get_ksymbol(mod, addr, size, offset);
> +			if (!sym)
> +				goto out;
> +			if (modname)
> +				strlcpy(modname, mod->name, MODULE_NAME_LEN + 1);
> +			if (name)
> +				strlcpy(name, sym, KSYM_NAME_LEN + 1);
> +			mutex_unlock(&module_mutex);
> +			return 0;
> +		}
> +	}
> +out:
> +	mutex_unlock(&module_mutex);
> +	return -ERANGE;
> +}
> +

The functions lookup_symbol_name() and lookup_symbol_attrs() are quite
general and are likely to be used for other applications in the future.

Could we please pick better names for them?  The names you've chosen are
far too general-sounding - we have a lot of different types of "symbol" in
the kernel!  Perhaps module_lookup_symbol_attrs() and
kallsyms_lookup_symbol() and kallsyms_lookup_attrs() or something.  But
something prefixed with kallsyms_ and module_.

Also, as these general-use functions are exported to all of vmlinux, a little
bit of documentation for them would be good.


      parent reply	other threads:[~2007-04-04  0:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-02 15:03 [PATCH 5/5] Fix race between cat /proc/slab_allocators and rmmod Alexey Dobriyan
2007-04-02 23:09 ` Rusty Russell
2007-04-02 23:23   ` Andrew Morton
2007-04-04  0:08 ` Andrew Morton [this message]

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=20070403170827.a32f97f1.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adobriyan@sw.ru \
    --cc=devel@openvz.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmarques@grupopie.com \
    --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