Received: by 10.223.164.202 with SMTP id h10csp241556wrb; Thu, 9 Nov 2017 05:45:17 -0800 (PST) X-Google-Smtp-Source: ABhQp+QshNgZiwNYTaSC0W6EXb2SGXfLZ9f8WwGoub7XHmbIVvnIbSG/+hSK/Nmr0d2BKeKAS2CR X-Received: by 10.98.49.196 with SMTP id x187mr523345pfx.171.1510235116884; Thu, 09 Nov 2017 05:45:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510235116; cv=none; d=google.com; s=arc-20160816; b=eOSynApOsfCm8qjHqB+pO/Lkmo+55xXpcRe1w30wizkvOCqLcrYV63VCLStgyt+B6k tS6azp3ADnajC+HpzweqO0AoNWpEc6tHqT9un3c/yUST1/xwZjjE+JubJg+OhL2qWtAc BZeB/mUKJILDpPbKMRDQEcDUhQITpQfHzZJ6MAEygg661v+/qDVdL/IJ+4WDFRxdPoue 9ERi+BrVNPHToS3NbVHejzVSwxpnycUcYvYo6hFtNfh3eFsue88TvuQ/P3IF+gJvEkcl 0QRQI2uFD30q1bYH+cuy281vCBPWYovf3bWYyWIP96tXeJANF9S2qbk6/2a+sxgqyYSr XIHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=mvKMJSJr36Rl/K6W/7J/8jJa0+KssN8EAh1sTaLdasg=; b=EGOYzY2DCFUeGWXMKk1ngOzX3BExauowK0kFxcnmYq2u87BtAlLTBbIf9Au0lCUMoE o3Et2MuUBZtgo6vgp42RNQP+JcoyugD5k4c/DTCWytOybhXvbq+8Zt5RWjuX8tgWJad9 1AB3cxpPXRfiKDtlv0YJ9KrnDdzGgRtfYi3WZkxpxuLTeIowbnXWMChGIPnLdiFirohe WPNMat5upmYcpU1z0e6aUyEwDrZrp8Bea39OzZG/S1RIhdXza90FSM4F6nymVtFhTa0H +6TRzXJu1wT60+NXIWeUGVDwDOZvpqo950so3GZjks6X5K+OtO3/R0rPQS/BCaSKS5+7 Z4vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a1si6479044pld.230.2017.11.09.05.45.05; Thu, 09 Nov 2017 05:45:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754789AbdKINo2 (ORCPT + 80 others); Thu, 9 Nov 2017 08:44:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38160 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754264AbdKINo0 (ORCPT ); Thu, 9 Nov 2017 08:44:26 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6BA3FC054C29; Thu, 9 Nov 2017 13:44:26 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 9853160CA5; Thu, 9 Nov 2017 13:44:24 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 9 Nov 2017 14:44:26 +0100 (CET) Date: Thu, 9 Nov 2017 14:44:23 +0100 From: Oleg Nesterov To: Yonghong Song Cc: mingo@kernel.org, tglx@linutronix.de, peterz@infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org, netdev@vger.kernel.org, ast@fb.com, kernel-team@fb.com Subject: Re: [PATCH] uprobes/x86: emulate push insns for uprobe on x86 Message-ID: <20171109134423.GA8746@redhat.com> References: <20171109080155.359718-1-yhs@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171109080155.359718-1-yhs@fb.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 09 Nov 2017 13:44:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/09, Yonghong Song wrote: > > This patch extends the emulation to "push " > insns. These insns are typical in the beginning > of the function. For example, bcc > in https://github.com/iovisor/bcc repo provides > tools to measure funclantency, detect memleak, etc. > The tools will place uprobes in the beginning of > function and possibly uretprobes at the end of function. > This patch is able to reduce the trap overhead for > uprobe from 2 to 1. OK. but to be honest I do not like the implementation, please see below. > +enum uprobe_insn_t { > + UPROBE_BRANCH_INSN = 0, > + UPROBE_PUSH_INSN = 1, > +}; > + > struct uprobe_xol_ops; > > struct arch_uprobe { > @@ -42,6 +47,7 @@ struct arch_uprobe { > }; > > const struct uprobe_xol_ops *ops; > + enum uprobe_insn_t insn_class; Why? I'd suggest to leave branch_xol_ops alone and add the new push_xol_ops{}, the code will look much simpler. The only thing they can share is branch_post_xol_op() which is just regs->sp += sizeof_long(); return -ERESTART; I think a bit of code duplication would be fine in this case. And. Do you really need ->post_xol() method to emulate "push"? Why we can't simply execute it out-of-line if copy_to_user() fails? branch_post_xol_op() is needed because we can't execute "call" out-of-line, we need to restart and try again if copy_to_user() fails, but I don not understand why it is needed to emulate "push". Oleg. From 1583574831236519975@xxx Thu Nov 09 08:04:04 +0000 2017 X-GM-THRID: 1583574831236519975 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread