From patchwork Mon Jul 31 10:40:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9871563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C5284602F0 for ; Mon, 31 Jul 2017 10:41:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B44FB28572 for ; Mon, 31 Jul 2017 10:41:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A65F62857D; Mon, 31 Jul 2017 10:41:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 502D328572 for ; Mon, 31 Jul 2017 10:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=W6E8/8iF+tcoSWKeROtSYnDkh3doltw/ObdOypZ0wIE=; b=pIjqfiuWSFqHp1eat2Pg+fkoty InYsNsBaZa6lFJihpsbEwUTn9h4FVoTmVn8CzES4frNKo/G+//kvI76sb/Blp861GQGeiKWY0BbpA xb/tyEHl/UcG0Tq2ZvRXfaNIVqOPPiQvzyuh4QHmGlne941ghbwcYbr5r8ikBzutc9ZsqcG48FASy OQNA65zHPg0HHBtfWOegamzPgL2vLxZtSr1tyo+PXZ6K+teb6Kory+vAI9a/9Q8T+IHh0x+oF+PD0 f+2vdNRIGe2OAeSeRkGqejw2zBHGsXTyJNy0TtXxuDyyAy4unnYwmy6MowLhOX7SMM9C8eUJQpmfP 5umiiq7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dc894-0005GL-I8; Mon, 31 Jul 2017 10:41:54 +0000 Received: from mail-io0-f181.google.com ([209.85.223.181]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dc88f-0004jP-Ta for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2017 10:41:31 +0000 Received: by mail-io0-f181.google.com with SMTP id g35so76769103ioi.3 for ; Mon, 31 Jul 2017 03:41:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=CgaQ6rxlTr9cJ5uPKTFvylq0vI3R3GtnIWBbgBt5TfU=; b=A4VehGJRXxhN6gHjqC5YMkGr3XA9+c9kRgZcozxTMMuzu8yeapwNjpSO9cAisuIkn8 rCqzeGYfIaRn630+tUWR35nX7/UHHR6AAGuDCi3G0ML5cG9zJqgCu05AI2fkFOKspKHw ZHuoNTuIHNpy+rXm2Z5gMJmDsJMm59vjn0eDoZACPdeGyvPuuvCafe/vMuTHNDLvMH5p tggDEzurrc5pd8jpDHv3URxpCzMrcUCWPqngfPLvtjWQNucXQWCqzlypE6/juThJ4diA MAKArzl4vVJvLaGecOkHV1lJRgnc322cwKQJlyJ7w41dqffWslgT6pW5fg14bvxV1JGS Enog== X-Gm-Message-State: AIVw113elUpRq5S5kRcSo/5lpH5PFWv+6Bt7Owx3zwnM6AAOlHxTPkjw Z80LCNaBdsAI3TT+JfMqeg== X-Received: by 10.107.8.208 with SMTP id h77mr19694268ioi.69.1501497668289; Mon, 31 Jul 2017 03:41:08 -0700 (PDT) Received: from localhost ([171.50.171.30]) by smtp.gmail.com with ESMTPSA id d9sm686963iod.71.2017.07.31.03.41.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Jul 2017 03:41:07 -0700 (PDT) From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin Subject: [PATCH v3 1/5] hw_breakpoint: Add step_needed event attribute Date: Mon, 31 Jul 2017 16:10:29 +0530 Message-Id: <1d7ca935857f93bd09c82a2ff57a53e373211b7e.1501496603.git.panand@redhat.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170731_034129_995687_22DDAD84 X-CRM114-Status: GOOD ( 12.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Pratyush Anand , will.deacon@arm.com, linux-kernel@vger.kernel.org, takahiro.akashi@linaro.org, huawei.libin@huawei.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Architecture like ARM64 currently allows to use default hw breakpoint single step handler only to perf. However, some other users like few systemtap tests or kernel test in samples/hw_breakpoint/data_breakpoint.c can also work with default step handler implementation. Therefore, this patch introduces a flag 'step_needed' in struct hw_perf_event, so that arch specific code(specially on arm64) can make a decision to enable single stepping. Any architecture which is not using this field will not have any side effect. Signed-off-by: Pratyush Anand --- include/linux/hw_breakpoint.h | 6 ++++++ include/linux/perf_event.h | 6 ++++++ kernel/events/core.c | 2 ++ 3 files changed, 14 insertions(+) diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index 0464c85e63fd..b9ac9629bf74 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -38,6 +38,12 @@ static inline int hw_breakpoint_type(struct perf_event *bp) return bp->attr.bp_type; } +static inline bool +hw_breakpoint_needs_single_step(struct perf_event *bp) +{ + return bp->hw.step_needed; +} + static inline unsigned long hw_breakpoint_len(struct perf_event *bp) { return bp->attr.bp_len; diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index 24a635887f28..7da951f94b47 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -233,6 +233,12 @@ struct hw_perf_event { */ u64 freq_time_stamp; u64 freq_count_stamp; + /* + * A HW breakpoint user can either have it's own step handling + * mechanism or it can use default step handling meachanism defined + * by arch code. Set step_needed to use default mechanism. + */ + int step_needed; #endif }; diff --git a/kernel/events/core.c b/kernel/events/core.c index 6c4e523dc1e2..66ce5574e778 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -9444,9 +9444,11 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu, } else if (is_write_backward(event)){ event->overflow_handler = perf_event_output_backward; event->overflow_handler_context = NULL; + event->hw.step_needed = 1; } else { event->overflow_handler = perf_event_output_forward; event->overflow_handler_context = NULL; + event->hw.step_needed = 1; } perf_event__state_init(event);