Received: by 10.223.164.221 with SMTP id h29csp668948wrb; Wed, 1 Nov 2017 03:33:59 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Tz9vSE6tDrcNgLrWmz4Lqw4wLkdIjX0uiHxclXh+PN/jJaMRuwyFImVlxKON0FAIohos76 X-Received: by 10.99.160.71 with SMTP id u7mr5540140pgn.22.1509532439835; Wed, 01 Nov 2017 03:33:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509532439; cv=none; d=google.com; s=arc-20160816; b=RKB8Zg6ljw6zE+vA8qRyTLgTKntcyVxnla+qEzMBtaqr/8R8aAM7sv/Yk29GKNAx6c KkVUNZ/0RcUsainMcDYYjt894a40p9euGo4OnK4aaxDfSd3JEWlfDZlY+r+J4nLf3uYr OPlFuBEpecQpUVzTQ6PTGT2S2pUJI3dfbbYi9AnTdEzm5QZivvfG59k1aoKPkl/nQxgU TEZ31BAdCZAQflUfubkVuXGSyeZ0f2W6M5qMiOYQ3Hw7/YtL2rRViz7nqSD9tqzVB4oH T/NgPQFDGGWXt3DeQ9UTq1gpkcvMmMoWAgKDWcXheLc2RlDe4N7KZek39vT4lpmr1IG6 4q+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=GPfvPwXzweWGV6/6cIghcKhM6gzDWH1pWksSfn2gWM0=; b=L5QegOqYxn4JLAsNQAKuaOrsTvRX0cTS0UP/+zJ+NYoTvLZI08dzNYNyk3CarrWkRU mv0ECCW8BPLjW0Oa1zsIlnCWPzQO4aRfzgpRlRCZ1q9Xc0sBVr5+hiTXNM6YwacQrsVh cf3X6SHJhb4et58Rt04bvrauj6b1GVHFNnf8wzCZ+aoFSdMIiVwx1/FTzPLYPzRJemWW 0scI9frApSa4H+8UYAz8qZyWkoToMOaTt36JrIml1wLkE83Hy7xmbo0eRtqbPAFnHcUi +HLEfFrFc/aTMmaKbL9qcXWrpIwk7Y/AdoTDzJJe+dXzyrzXKffeaYq0Z5//6SxmSEfN XOEw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si438681pgb.465.2017.11.01.03.33.45; Wed, 01 Nov 2017 03:33:59 -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 S932115AbdKAKdG (ORCPT + 99 others); Wed, 1 Nov 2017 06:33:06 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9925 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752058AbdKAKdF (ORCPT ); Wed, 1 Nov 2017 06:33:05 -0400 Received: from 172.30.72.59 (EHLO DGGEMS408-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DKC74975; Wed, 01 Nov 2017 18:33:00 +0800 (CST) Received: from [127.0.0.1] (10.111.194.139) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Wed, 1 Nov 2017 18:32:57 +0800 Subject: Re: [PATCH 1/2] perf mmap: Fix perf backward recording To: Namhyung Kim References: <20171101055327.141281-1-wangnan0@huawei.com> <20171101055327.141281-2-wangnan0@huawei.com> <20171101094929.GB25146@danjae.aot.lge.com> CC: , , , , From: "Wangnan (F)" Message-ID: Date: Wed, 1 Nov 2017 18:32:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <20171101094929.GB25146@danjae.aot.lge.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.194.139] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.59F9A2DF.00A8,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 0d161d64bdde9e4f8b274cbbea18d420 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/11/1 17:49, Namhyung Kim wrote: > Hi, > > On Wed, Nov 01, 2017 at 05:53:26AM +0000, Wang Nan wrote: >> perf record backward recording doesn't work as we expected: it never >> overwrite when ring buffer full. >> >> Test: >> >> (Run a busy printing python task background like this: >> >> while True: >> print 123 >> >> send SIGUSR2 to perf to capture snapshot.) [SNIP] >> >> Signed-off-by: Wang Nan >> --- >> tools/perf/util/evlist.c | 8 +++++++- >> 1 file changed, 7 insertions(+), 1 deletion(-) >> >> diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c >> index c6c891e..4c5daba 100644 >> --- a/tools/perf/util/evlist.c >> +++ b/tools/perf/util/evlist.c >> @@ -799,22 +799,28 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, >> } >> >> static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, >> - struct mmap_params *mp, int cpu_idx, >> + struct mmap_params *_mp, int cpu_idx, >> int thread, int *_output, int *_output_backward) >> { >> struct perf_evsel *evsel; >> int revent; >> int evlist_cpu = cpu_map__cpu(evlist->cpus, cpu_idx); >> + struct mmap_params *mp; >> >> evlist__for_each_entry(evlist, evsel) { >> struct perf_mmap *maps = evlist->mmap; >> + struct mmap_params rdonly_mp; >> int *output = _output; >> int fd; >> int cpu; >> >> + mp = _mp; >> if (evsel->attr.write_backward) { >> output = _output_backward; >> maps = evlist->backward_mmap; >> + rdonly_mp = *_mp; >> + rdonly_mp.prot &= ~PROT_WRITE; >> + mp = &rdonly_mp; >> >> if (!maps) { >> maps = perf_evlist__alloc_mmap(evlist); >> -- > What about this instead (not tested)? > > > diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c > index c6c891e154a6..27ebe355e794 100644 > --- a/tools/perf/util/evlist.c > +++ b/tools/perf/util/evlist.c > @@ -838,6 +838,11 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, > if (*output == -1) { > *output = fd; > > + if (evsel->attr.write_backward) > + mp->prot = PROT_READ; > + else > + mp->prot = PROT_READ | PROT_WRITE; > + If evlist->overwrite is true, PROT_WRITE should be unset even if write_backward is not set. If you want to delay the setting of mp->prot, you need to consider both evlist->overwrite and evsel->attr.write_backward. Then why not removing mp->prot totally, and add a prot argument to perf_mmap__mmap, since prot setting is always decided independently? > if (perf_mmap__mmap(&maps[idx], mp, *output) < 0) > return -1; > } else { > @@ -1058,9 +1063,7 @@ int perf_evlist__mmap_ex(struct perf_evlist *evlist, unsigned int pages, > struct perf_evsel *evsel; > const struct cpu_map *cpus = evlist->cpus; > const struct thread_map *threads = evlist->threads; > - struct mmap_params mp = { > - .prot = PROT_READ | (overwrite ? 0 : PROT_WRITE), > - }; > + struct mmap_params mp; > > if (!evlist->mmap) > evlist->mmap = perf_evlist__alloc_mmap(evlist); The 'overwrite' argument in perf_evlist__mmap_ex() controls evlist->overwrite. Thank you. From 1582856934106290327@xxx Wed Nov 01 09:53:24 +0000 2017 X-GM-THRID: 1582841972981207976 X-Gmail-Labels: Inbox,Category Forums