From patchwork Tue Jan 5 09:00:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 7953271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9F0EB9F38D for ; Tue, 5 Jan 2016 09:02:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1A3E20396 for ; Tue, 5 Jan 2016 09:02:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D709D202E6 for ; Tue, 5 Jan 2016 09:02:13 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGNU9-0001nc-Cf; Tue, 05 Jan 2016 09:00:57 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aGNU6-0001dZ-7S for linux-arm-kernel@lists.infradead.org; Tue, 05 Jan 2016 09:00:54 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id C76088E75B; Tue, 5 Jan 2016 09:00:33 +0000 (UTC) Received: from krava.brq.redhat.com (dhcp-1-139.brq.redhat.com [10.34.1.139]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id u0590UxN020189; Tue, 5 Jan 2016 04:00:31 -0500 Date: Tue, 5 Jan 2016 10:00:30 +0100 From: Jiri Olsa To: Wang Nan Subject: Re: [RFC PATCH] arm64: perf test: Improbe bp_signal Message-ID: <20160105090030.GC2192@krava.brq.redhat.com> References: <20160104165535.GI1616@arm.com> <1451969880-14877-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1451969880-14877-1-git-send-email-wangnan0@huawei.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160105_010054_355024_75C5C21E X-CRM114-Status: GOOD ( 14.23 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pi3orama@163.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , takahiro.akashi@linaro.org, Jiri Olsa , guohanjun@huawei.com, fengguang.wu@intel.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Jan 05, 2016 at 04:58:00AM +0000, Wang Nan wrote: SNIP > + * - SIGUSR1 is delivered -> overflows_2 == 1 (nested signal) > + * - sig_handler_2 return > + * - sig_handler return > + * - fd3 event watchpoint hit -> count3 == 1 (wp and bp in one insn) > + * - SIGIO is delivered -> overflows == 2 > + * - fd2 event breakpoint hit -> count2 == 2 > + * - SIGUSR1 is delivered -> overflows_2 == 2 > + * - sig_handler_2 return > + * - sig_handler return > + * - fd3 event watchpoint hit -> count3 == 2 (standalone wp) > + * - SIGIO is delivered -> overflows = 3 > + * - fd2 event breakpoint hit -> count2 == 3 > + * - SIGUSR1 is delivered -> overflows_2 == 3 > + * - sig_handler_2 return > + * - sig_handler return > * > * The test case check following error conditions: > * - we get stuck in signal handler because of debug > @@ -152,11 +229,13 @@ int test__bp_signal(int subtest __maybe_unused) > * > */ > > - fd1 = bp_event(test_function, 1); > - fd2 = bp_event(sig_handler, 0); > + fd1 = bp_event(__test_function, 1); > + fd2 = __xp_event(true, sig_handler, 1, SIGUSR1); > + fd3 = wp_event((void *)&the_var, 1); > spent some time to figure this out.. would attached change be more readable? thanks, jirka diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c index 0bc4f76c22ca..e5349616ac3f 100644 --- a/tools/perf/tests/bp_signal.c +++ b/tools/perf/tests/bp_signal.c @@ -99,7 +99,7 @@ static void sig_handler(int signum __maybe_unused, } } -static int __xp_event(bool is_bp, void *addr, int setup_signal, int signal) +static int __event(bool is_x, void *addr, int signal) { struct perf_event_attr pe; int fd; @@ -109,7 +109,7 @@ static int __xp_event(bool is_bp, void *addr, int setup_signal, int signal) pe.size = sizeof(struct perf_event_attr); pe.config = 0; - pe.bp_type = is_bp ? HW_BREAKPOINT_X : HW_BREAKPOINT_W; + pe.bp_type = is_x ? HW_BREAKPOINT_X : HW_BREAKPOINT_W; pe.bp_addr = (unsigned long) addr; pe.bp_len = sizeof(long); @@ -128,25 +128,23 @@ static int __xp_event(bool is_bp, void *addr, int setup_signal, int signal) return TEST_FAIL; } - if (setup_signal) { - fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC); - fcntl(fd, F_SETSIG, signal); - fcntl(fd, F_SETOWN, getpid()); - } + fcntl(fd, F_SETFL, O_RDWR|O_NONBLOCK|O_ASYNC); + fcntl(fd, F_SETSIG, signal); + fcntl(fd, F_SETOWN, getpid()); ioctl(fd, PERF_EVENT_IOC_RESET, 0); return fd; } -static int bp_event(void *addr, int setup_signal) +static int bp_event(void *addr, int signal) { - return __xp_event(true, addr, setup_signal, SIGIO); + return __event(true, addr, signal); } -static int wp_event(void *addr, int setup_signal) +static int wp_event(void *addr, int signal) { - return __xp_event(false, addr, setup_signal, SIGIO); + return __event(false, addr, signal); } static long long bp_count(int fd) @@ -229,9 +227,9 @@ int test__bp_signal(int subtest __maybe_unused) * */ - fd1 = bp_event(__test_function, 1); - fd2 = __xp_event(true, sig_handler, 1, SIGUSR1); - fd3 = wp_event((void *)&the_var, 1); + fd1 = bp_event(__test_function, SIGIO); + fd2 = bp_event(sig_handler, SIGUSR1); + fd3 = wp_event((void *)&the_var, SIGIO); ioctl(fd1, PERF_EVENT_IOC_ENABLE, 0); ioctl(fd2, PERF_EVENT_IOC_ENABLE, 0);