From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932376AbbKCSYS (ORCPT ); Tue, 3 Nov 2015 13:24:18 -0500 Received: from mail.kernel.org ([198.145.29.136]:55184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755784AbbKCSYP (ORCPT ); Tue, 3 Nov 2015 13:24:15 -0500 Date: Tue, 3 Nov 2015 15:24:11 -0300 From: Arnaldo Carvalho de Melo To: "Wangnan (F)" Cc: Namhyung Kim , ast@plumgrid.com, brendan.d.gregg@gmail.com, a.p.zijlstra@chello.nl, daniel@iogearbox.net, dsahern@gmail.com, hekuang@huawei.com, jolsa@kernel.org, lizefan@huawei.com, masami.hiramatsu.pt@hitachi.com, paulus@samba.org, linux-kernel@vger.kernel.org, pi3orama@163.com, xiakaixu@huawei.com Subject: Re: [PATCH 10/31] perf test: Enforce LLVM test for BPF test Message-ID: <20151103182411.GT21609@kernel.org> References: <1444826502-49291-1-git-send-email-wangnan0@huawei.com> <1444826502-49291-11-git-send-email-wangnan0@huawei.com> <20151014154842.GC4085@danjae.kornet> <561F94EE.2060503@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <561F94EE.2060503@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Oct 15, 2015 at 07:58:38PM +0800, Wangnan (F) escreveu: > >>+void test__llvm_prepare(void) > >>+{ > >>+ p_test_llvm__bpf_result = mmap(NULL, SHARED_BUF_INIT_SIZE, > >>+ PROT_READ | PROT_WRITE, > >>+ MAP_SHARED | MAP_ANONYMOUS, -1, 0); > >>+ if (!p_test_llvm__bpf_result) > >It should check MAP_FAILED instead. > > > > Fixed by this way: Can you please try refreshing this patchset on top of what is now in acme/perf/core? Also why do we need those struct test->{prepare,cleanup} pointers? You introduced it and then, on the next patch that touches 'perf test' and uses test__llvm_{prepare,cleanup} you call them directly, which I think should be enough, i.e. keep them as functions to call from inside the test called from run_test(), right? - Arnaldo > diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c > index e722e8a..25ddeaf 100644 > --- a/tools/perf/tests/llvm.c > +++ b/tools/perf/tests/llvm.c > @@ -199,12 +199,15 @@ void test__llvm_prepare(void) > > for (i = 0; llvm_testcases[i].source; i++) { > struct test_llvm__bpf_result *result; > + void *p; > > - result = mmap(NULL, SHARED_BUF_INIT_SIZE, > - PROT_READ | PROT_WRITE, > - MAP_SHARED | MAP_ANONYMOUS, -1, 0); > - if (!result) > + p = mmap(NULL, SHARED_BUF_INIT_SIZE, > + PROT_READ | PROT_WRITE, > + MAP_SHARED | MAP_ANONYMOUS, -1, 0); > + if (p == MAP_FAILED) > return; > + > + result = p; > memset((void *)result, '\0', SHARED_BUF_INIT_SIZE); > > llvm_testcases[i].result = result; > > Thank you.