From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>,
Peter Zijlstra <peterz@infradead.org>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <anton@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 7/7] uprobes: _register() should always do register_for_each_vma(true)
Date: Thu, 13 Dec 2012 15:56:39 +0530 [thread overview]
Message-ID: <20121213102639.GB29086@linux.vnet.ibm.com> (raw)
In-Reply-To: <20121123202817.GA18907@redhat.com>
* Oleg Nesterov <oleg@redhat.com> [2012-11-23 21:28:17]:
> To support the filtering uprobe_register() should do
> register_for_each_vma(true) every time the new consumer comes,
> we need to install the previously nacked breakpoints.
>
> Note:
> - uprobes_mutex[] should die, what is actually protects is
> alloc_uprobe().
>
> - UPROBE_RUN_HANDLER should die too, obviously it can't work
> unless uprobe has a single consumer. The consumer should
> serialize with _register/_unregister itself. Or this flag
> should live in uprobe_consumer->state.
>
> - Perhaps we can do some optimizations later. For example, if
> filter_chain() never returns false uprobe can record this
> fact and avoid the unnecessary register_for_each_vma().
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> ---
> kernel/events/uprobes.c | 31 +++++++++++++------------------
> 1 files changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 7c98671..c80507d 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -482,16 +482,12 @@ static void handler_chain(struct uprobe *uprobe, struct pt_regs *regs)
> up_read(&uprobe->consumer_rwsem);
> }
>
> -/* Returns the previous consumer */
> -static struct uprobe_consumer *
> -consumer_add(struct uprobe *uprobe, struct uprobe_consumer *uc)
> +static void consumer_add(struct uprobe *uprobe, struct uprobe_consumer *uc)
> {
> down_write(&uprobe->consumer_rwsem);
> uc->next = uprobe->consumers;
> uprobe->consumers = uc;
> up_write(&uprobe->consumer_rwsem);
> -
> - return uc->next;
> }
>
> /*
> @@ -820,9 +816,15 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
> return err;
> }
>
> -static int __uprobe_register(struct uprobe *uprobe)
> +static int __uprobe_register(struct uprobe *uprobe, struct uprobe_consumer *uc)
> {
> - return register_for_each_vma(uprobe, true);
> + int err;
> +
> + consumer_add(uprobe, uc);
> + err = register_for_each_vma(uprobe, true);
> + if (!err) /* TODO: pointless unless the first consumer */
> + set_bit(UPROBE_RUN_HANDLER, &uprobe->flags);
> + return err;
> }
>
> static void __uprobe_unregister(struct uprobe *uprobe, struct uprobe_consumer *uc)
> @@ -867,21 +869,14 @@ int uprobe_register(struct inode *inode, loff_t offset, struct uprobe_consumer *
> if (offset > i_size_read(inode))
> return -EINVAL;
>
> - ret = 0;
> + ret = -ENOMEM;
> mutex_lock(uprobes_hash(inode));
> uprobe = alloc_uprobe(inode, offset);
> -
> - if (!uprobe) {
> - ret = -ENOMEM;
> - } else if (!consumer_add(uprobe, uc)) {
> - ret = __uprobe_register(uprobe);
> - if (ret) {
> + if (uprobe) {
> + ret = __uprobe_register(uprobe, uc);
> + if (ret)
> __uprobe_unregister(uprobe, uc);
> - } else {
> - set_bit(UPROBE_RUN_HANDLER, &uprobe->flags);
> - }
> }
> -
> mutex_unlock(uprobes_hash(inode));
> if (uprobe)
> put_uprobe(uprobe);
> --
> 1.5.5.1
>
prev parent reply other threads:[~2012-12-13 10:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-23 20:27 [PATCH 0/7] uprobes: register/unregister preparations for filtering Oleg Nesterov
2012-11-23 20:28 ` [PATCH 1/7] uprobes: Move __set_bit(UPROBE_SKIP_SSTEP) into alloc_uprobe() Oleg Nesterov
2012-12-10 5:56 ` Srikar Dronamraju
2012-11-23 20:28 ` [PATCH 2/7] uprobes: Kill the "uprobe != NULL" check in uprobe_unregister() Oleg Nesterov
2012-12-10 6:00 ` Srikar Dronamraju
2012-11-23 20:28 ` [PATCH 3/7] uprobes: Kill the pointless inode/uc checks in register/unregister Oleg Nesterov
2012-12-10 6:19 ` Srikar Dronamraju
2012-12-10 19:12 ` Oleg Nesterov
2012-12-13 10:35 ` Srikar Dronamraju
2012-12-13 13:15 ` Oleg Nesterov
2012-12-13 14:08 ` Srikar Dronamraju
2012-12-13 14:12 ` Srikar Dronamraju
2012-11-23 20:28 ` [PATCH 4/7] uprobes: Kill uprobe_consumer->filter() Oleg Nesterov
2012-12-10 12:02 ` Srikar Dronamraju
2012-11-23 20:28 ` [PATCH 5/7] uprobes: Introduce filter_chain() Oleg Nesterov
2012-11-24 16:08 ` Oleg Nesterov
2012-12-10 12:04 ` Srikar Dronamraju
2012-11-23 20:28 ` [PATCH 6/7] uprobes: _unregister() should always do register_for_each_vma(false) Oleg Nesterov
2012-11-23 20:28 ` [PATCH 7/7] uprobes: _register() should always do register_for_each_vma(true) Oleg Nesterov
2012-12-13 10:26 ` Srikar Dronamraju [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=20121213102639.GB29086@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=ananth@in.ibm.com \
--cc=anton@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).