Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933501Ab3DIOUz (ORCPT ); Tue, 9 Apr 2013 10:20:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55169 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760602Ab3DIOUw (ORCPT ); Tue, 9 Apr 2013 10:20:52 -0400 Date: Tue, 9 Apr 2013 16:16:15 +0200 From: Oleg Nesterov To: Srikar Dronamraju Cc: Anton Arapov , LKML , Josh Stone , Frank Eigler , Peter Zijlstra , Ingo Molnar , Ananth N Mavinakayanahalli , adrian.m.negreanu@intel.com, Torsten.Polle@gmx.de Subject: Re: [PATCH v1 2/9] uretprobes: Reserve the first slot in xol_vma for trampoline Message-ID: <20130409141615.GB20577@redhat.com> References: <1365004839-21982-1-git-send-email-anton@redhat.com> <1365004839-21982-3-git-send-email-anton@redhat.com> <20130407114441.GB2186@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130407114441.GB2186@linux.vnet.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1715 Lines: 55 On 04/07, Srikar Dronamraju wrote: > > * Anton Arapov [2013-04-03 18:00:32]: > > > Allocate trampoline page, as the very first one in uprobed > > task xol area, and fill it with breakpoint opcode. > > > > Also introduce get_trampoline_vaddr() helper, to wrap the > > trampoline address extraction from area->vaddr. That removes > > confusion and eases the debug experience in case ->vaddr > > notion will be changed. > > > > v1 changes: > > * rework get_trampoline_vaddr() helper. > > * init xol_area->slot_count. > > > > Signed-off-by: Anton Arapov > > Acked-by: Srikar Dronamraju Thanks! > > +static unsigned long get_trampoline_vaddr(void) > > +{ > > + struct xol_area *area; > > + unsigned long trampoline_vaddr = -1; > > + > > + area = current->mm->uprobes_state.xol_area; > > + smp_read_barrier_depends(); > > check: do we need this barrier? In theory yes. For example, we do not want the false positive in handle_swbp() which does if (bp_vaddr == get_trampoline_vaddr()) handler_uretprobe(); In theory we can race with another thread which initializes area (in particular area->vaddr) and then sets uprobes_state.xol_area = area in xol_add_vma(). If we see ->xol_area != NULL we must ensure that we read the correct value of area->vaddr, so we need a barrier. In short. Please note get_xol_area()->smp_read_barrier_depends(), get_trampoline_vaddr() needs it for the same reason. Oleg. -- 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/