From patchwork Mon Jul 31 10:40:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9871569 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 01163602F0 for ; Mon, 31 Jul 2017 10:42:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E697828572 for ; Mon, 31 Jul 2017 10:42:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB3902857D; Mon, 31 Jul 2017 10:42:33 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE autolearn=unavailable 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 7F1DB28572 for ; Mon, 31 Jul 2017 10:42:33 +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=6vYZL8vOGCDWZ0EhxJ0iqGZUC7K/cfqBb2NpOTxStcw=; b=TfWFhtJenThGAMpMN+P558Ja5m JQi2bfboS6NCgTvkH8hPFQnHVyi5qxikeuNdcG5Nn+g0ne7oZNpl30sEBOIdUgimShPwQIGKQIjFn jzknoPmqosqiZ0jiXKMWaj2FEUHPLRIJyCWD/U44euLQRwZjlLO72/lYkUrslVF8eCBxoCrN9OH7Q gW8k7soTO8PT7HvAxBn3YC1i/STWhx/xnVqhEhn3E0fqjqGp6WUBdkWIXxIBVk7yAR1LpBdKV/DGW nA994WYeM5MMy4X+oiYPa+bqK0Cbv2YQ+MYWXUkfw6XAQQvZDDtKJY4LhiGXMUR0dWlNMPnayN4Nm WAv6XTHg==; 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 1dc89c-0005o8-Ue; Mon, 31 Jul 2017 10:42:28 +0000 Received: from mail-pf0-f177.google.com ([209.85.192.177]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dc88m-0004jc-1u for linux-arm-kernel@lists.infradead.org; Mon, 31 Jul 2017 10:41:47 +0000 Received: by mail-pf0-f177.google.com with SMTP id t86so9594270pfe.2 for ; Mon, 31 Jul 2017 03:41:15 -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=x1Cp87K0vyNuBjg4pfn+DY0kULojR3l5svFulYq+R3U=; b=WG2cRYcS7nGiIaIEHLUkwVBs5f8vsjrDyQnDcfaW5i++J/hncuEx44YTaf0flxiyaB L2XzCyQc+HGClbN6fL3CKmN2JMWAOwrAds/f6EfjyTitfIswJZ6JoAUKz0kx+ySJGmV+ rjpS0YmVDVFdm364Q8SbgLkVTPPKRB9D5GsgU9gvRG6HYF+zR7oZAcTwrn+/RpcT79Cc 5BgB4Oj03vm0Ope+iLZAWe/p9vEBMuMoOqlW4lGHPPhRFZcMG95vPP5HSrrRas8ntIuN Z79rfwiynIm76YcwBJVbmqDI2D9SRToH8epyJL2amw7BWj45Yf3ztHBfc2uXWONzq6n4 SncQ== X-Gm-Message-State: AIVw110yUJsUDKWQ1UylsQQI3X5JtxJS5IBT38223tM6A0ykDyI2zHbe RNqySzYNwYYc7gXvIuWPzg== X-Received: by 10.84.202.163 with SMTP id x32mr16116702pld.99.1501497674565; Mon, 31 Jul 2017 03:41:14 -0700 (PDT) Received: from localhost ([171.50.171.30]) by smtp.gmail.com with ESMTPSA id a63sm2953389pfc.165.2017.07.31.03.41.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Jul 2017 03:41:14 -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 3/5] register_wide_hw_breakpoint(): modify to accept step_needed arg Date: Mon, 31 Jul 2017 16:10:31 +0530 Message-Id: <97ca3a2ba258eda5e0c228f5f7dac1c7c0c4482c.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_034136_547122_1AB5164B X-CRM114-Status: GOOD ( 16.46 ) 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 arch like ARM64 expects 'step_needed = 1' in order to use default single step handler. Therefore, modify register_wide_hw_breakpoint() implementation,so that we can set this field in struct hw_perf_event to be used later by arch specific code. Other arch will not have any affect as they do not use it so far. Signed-off-by: Pratyush Anand --- arch/x86/kernel/kgdb.c | 2 +- include/linux/hw_breakpoint.h | 4 ++-- kernel/events/hw_breakpoint.c | 4 +++- samples/hw_breakpoint/data_breakpoint.c | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c index 8e36f249646e..19b24c50a952 100644 --- a/arch/x86/kernel/kgdb.c +++ b/arch/x86/kernel/kgdb.c @@ -674,7 +674,7 @@ void kgdb_arch_late(void) for (i = 0; i < HBP_NUM; i++) { if (breakinfo[i].pev) continue; - breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL, NULL); + breakinfo[i].pev = register_wide_hw_breakpoint(&attr, NULL, NULL, 0); if (IS_ERR((void * __force)breakinfo[i].pev)) { printk(KERN_ERR "kgdb: Could not allocate hw" "breakpoints\nDisabling the kernel debugger\n"); diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index b9ac9629bf74..8cbc8ded6d50 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -71,7 +71,7 @@ register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr, extern struct perf_event * __percpu * register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, - void *context); + void *context, int step); extern int register_perf_hw_breakpoint(struct perf_event *bp); extern int __register_perf_hw_breakpoint(struct perf_event *bp); @@ -110,7 +110,7 @@ register_wide_hw_breakpoint_cpu(struct perf_event_attr *attr, static inline struct perf_event * __percpu * register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, - void *context) { return NULL; } + void *context, int step) { return NULL; } static inline int register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } static inline int diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 3f8cb1e14588..0dcb175276b2 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -492,13 +492,14 @@ EXPORT_SYMBOL_GPL(unregister_hw_breakpoint); * register_wide_hw_breakpoint - register a wide breakpoint in the kernel * @attr: breakpoint attributes * @triggered: callback to trigger when we hit the breakpoint + * @step: tells if framework can use default arch step handler * * @return a set of per_cpu pointers to perf events */ struct perf_event * __percpu * register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, - void *context) + void *context, int step) { struct perf_event * __percpu *cpu_events, *bp; long err = 0; @@ -512,6 +513,7 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, for_each_online_cpu(cpu) { bp = perf_event_create_kernel_counter(attr, cpu, NULL, triggered, context); + bp->hw.step_needed = step; if (IS_ERR(bp)) { err = PTR_ERR(bp); break; diff --git a/samples/hw_breakpoint/data_breakpoint.c b/samples/hw_breakpoint/data_breakpoint.c index ef7f32291852..f64e59f9fbc6 100644 --- a/samples/hw_breakpoint/data_breakpoint.c +++ b/samples/hw_breakpoint/data_breakpoint.c @@ -60,7 +60,8 @@ static int __init hw_break_module_init(void) attr.bp_len = HW_BREAKPOINT_LEN_4; attr.bp_type = HW_BREAKPOINT_W | HW_BREAKPOINT_R; - sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler, NULL); + sample_hbp = register_wide_hw_breakpoint(&attr, sample_hbp_handler, + NULL, 1); if (IS_ERR((void __force *)sample_hbp)) { ret = PTR_ERR((void __force *)sample_hbp); goto fail;