Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757271AbbGGMqe (ORCPT ); Tue, 7 Jul 2015 08:46:34 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:34953 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756857AbbGGMq1 (ORCPT ); Tue, 7 Jul 2015 08:46:27 -0400 Date: Tue, 7 Jul 2015 14:46:23 +0200 From: Anton Arapov To: Oleg Nesterov Cc: Ananth Mavinakayanahalli , David Long , Denys Vlasenko , "Frank Ch. Eigler" , Ingo Molnar , Jan Willeke , Jim Keniston , Mark Wielaard , Pratyush Anand , Srikar Dronamraju , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 02/11] uprobes: Introduce free_ret_instance() Message-ID: <20150707124623.GB5946@troglodyte.intinfra.com> References: <20150707012210.GA7466@redhat.com> <20150707012239.GA7497@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150707012239.GA7497@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2609 Lines: 87 On Tue, Jul 07, 2015 at 03:22:39AM +0200, Oleg Nesterov wrote: > We can simplify uprobe_free_utask() and handle_uretprobe_chain() > if we add a simple helper which does put_uprobe/kfree and returns > the ->next return_instance. > > Signed-off-by: Oleg Nesterov > Acked-by: Srikar Dronamraju Acked-by: Anton Arapov > --- > kernel/events/uprobes.c | 27 +++++++++++++-------------- > 1 files changed, 13 insertions(+), 14 deletions(-) > > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c > index a9847b4..d8c702f 100644 > --- a/kernel/events/uprobes.c > +++ b/kernel/events/uprobes.c > @@ -1378,6 +1378,14 @@ unsigned long uprobe_get_trap_addr(struct pt_regs *regs) > return instruction_pointer(regs); > } > > +static struct return_instance *free_ret_instance(struct return_instance *ri) > +{ > + struct return_instance *next = ri->next; > + put_uprobe(ri->uprobe); > + kfree(ri); > + return next; > +} > + > /* > * Called with no locks held. > * Called in context of a exiting or a exec-ing thread. > @@ -1385,7 +1393,7 @@ unsigned long uprobe_get_trap_addr(struct pt_regs *regs) > void uprobe_free_utask(struct task_struct *t) > { > struct uprobe_task *utask = t->utask; > - struct return_instance *ri, *tmp; > + struct return_instance *ri; > > if (!utask) > return; > @@ -1394,13 +1402,8 @@ void uprobe_free_utask(struct task_struct *t) > put_uprobe(utask->active_uprobe); > > ri = utask->return_instances; > - while (ri) { > - tmp = ri; > - ri = ri->next; > - > - put_uprobe(tmp->uprobe); > - kfree(tmp); > - } > + while (ri) > + ri = free_ret_instance(ri); > > xol_free_insn_slot(t); > kfree(utask); > @@ -1770,7 +1773,7 @@ handle_uretprobe_chain(struct return_instance *ri, struct pt_regs *regs) > static bool handle_trampoline(struct pt_regs *regs) > { > struct uprobe_task *utask; > - struct return_instance *ri, *tmp; > + struct return_instance *ri; > bool chained; > > utask = current->utask; > @@ -1792,11 +1795,7 @@ static bool handle_trampoline(struct pt_regs *regs) > handle_uretprobe_chain(ri, regs); > > chained = ri->chained; > - put_uprobe(ri->uprobe); > - > - tmp = ri; > - ri = ri->next; > - kfree(tmp); > + ri = free_ret_instance(ri); > utask->depth--; > > if (!chained) > -- > 1.5.5.1 > -- 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/