From patchwork Fri Jul 1 01:53:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 71278 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp55881qgy; Thu, 30 Jun 2016 18:55:39 -0700 (PDT) X-Received: by 10.66.139.230 with SMTP id rb6mr27383948pab.101.1467338139020; Thu, 30 Jun 2016 18:55:39 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yn6si1328395pac.1.2016.06.30.18.55.38; Thu, 30 Jun 2016 18:55:39 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752017AbcGABzD (ORCPT + 30 others); Thu, 30 Jun 2016 21:55:03 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:52683 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751713AbcGABzB (ORCPT ); Thu, 30 Jun 2016 21:55:01 -0400 Received: from 172.24.1.137 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CEE17372; Fri, 01 Jul 2016 09:54:22 +0800 (CST) Received: from [127.0.0.1] (10.111.66.109) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Fri, 1 Jul 2016 09:54:10 +0800 Subject: Re: 'perf test backward' failing with older kernels, should Skip To: Arnaldo Carvalho de Melo References: <20160630210052.GE5324@kernel.org> CC: He Kuang , Jiri Olsa , "Linux Kernel Mailing List" From: "Wangnan (F)" Message-ID: <5775CD34.6030107@huawei.com> Date: Fri, 1 Jul 2016 09:53:56 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160630210052.GE5324@kernel.org> X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.5775CD4F.0018, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: efcc9d1bbdee7da31323e1cb8dccff23 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/7/1 5:00, Arnaldo Carvalho de Melo wrote: > Hi Wang, > > I booted a machine with the f24 distro kernel and the backward > ring buffer test started FAILing, when it should've noticed that the > kernel doesn't support it and Skip instead: > > [root@jouet ~]# perf test -v backward > 45: Test backward reading from ring buffer : > --- start --- > > mmap size 1052672B > Unexpected counter: sample_count=0, comm_count=0 > ---- end ---- > Test backward reading from ring buffer: FAILED! > [root@jouet ~]# > I didn't test it on old kernel, but I tested it by forcing sys_perf_event_open return -EINVAL when attr->backward is true by following patch: pid, cpus->map[cpu], 'perf test' skips this test. Let me switch to an old kernel and try again... Oops... It does FAILED... Seems the code I use to emulate old kernel is wrong. I should set errno to EINVAL and make FD(...) = -1. I agree with your patch. Thank you for pointing it out. > Ok, so I think the patch below should do the trick, is that right? With it > I get: > > [root@jouet ~]# perf test backward > 45: Test backward reading from ring buffer : Skip > [root@jouet ~]# > > diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c > index e70313fac5a5..0731b0bf9552 100644 > --- a/tools/perf/tests/backward-ring-buffer.c > +++ b/tools/perf/tests/backward-ring-buffer.c > @@ -118,8 +118,10 @@ int test__backward_ring_buffer(int subtest __maybe_unused) > perf_evlist__config(evlist, &opts, NULL); > > /* Set backward bit, ring buffer should be writing from end */ > - evlist__for_each_entry(evlist, evsel) > + evlist__for_each_entry(evlist, evsel) { > + evsel->overwrite = true; > evsel->attr.write_backward = 1; > + } > > err = perf_evlist__open(evlist); > if (err < 0) { diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1d8f2bb..3e91c63 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1418,6 +1418,9 @@ retry_open: pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx\n", pid, cpus->map[cpu], group_fd, flags); + if (evsel->attr.write_backward) + FD(evsel, cpu, thread) = -EINVAL; + else FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr,