Received: by 10.223.176.5 with SMTP id f5csp3281048wra; Thu, 1 Feb 2018 13:56:45 -0800 (PST) X-Google-Smtp-Source: AH8x227M3m6fUtJP9zqk4PMDQ5uvHTjG4y8NdZNqW3AMfaZEIQ8LOjk786bXzfQO6E2DypLhrb/D X-Received: by 2002:a17:902:64d6:: with SMTP id y22-v6mr33219047pli.444.1517522204895; Thu, 01 Feb 2018 13:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517522204; cv=none; d=google.com; s=arc-20160816; b=B0p1wmbBnxl+kVZTciLp8vC8ojPbnv7zs6wCvKxr5YTAby/YU7lI9Yob7hQgNoZO9B krhQPFAM/GrKrsh68zxf7ytWLcxq14s257WIivxQQpfYOJQRV+UNdtEzLjfUgUf/803f Mi8Xn+fxx4Nwzt1qA80Hv8DEzqao/6dX+/yE7IXqiwE4CnPruq/CtHpdkiQIJswmMxT3 6unYx2UeMnHz/GZbYdYZv/nbve/BC7nVeynDI2gY2XII+Bn5R3wYgk1EJ3IBR/P5s/Sf AEbu0zMbWKlAjYev5yPbRK2yreXjPUrHuXwIvX8gdOC1Gj6EOP2C4vpIrahPLKRCbbjs mL2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:arc-authentication-results; bh=IQbGVkQ5FzfnsMziViDBMVbKy4sjBWQG4Fip3aOmSqs=; b=CBp4+vRCsUjhleqqpinrBQE9nKdcBmhkcyu3d2bzeKVxYWLm2GMpDioCfoc4LHbAgh d/8tcv084ClBZ0Hcx4im7A1tnx/w8RsaFwlwTWKHB7BF6zrk3NcPRJ7OJhlQPLgnwRFU 4YqIJEaywk3vUHurEm54ysXmv7IxBaxD95KxX24mwZ++Xfarv4LPiFW0WoIbw3tM1GMX xPPGsfDSXe8AB80yCpdiEDV35M1yFCbkctVyeO7A1nbEc2XzXPC2P67EE3v+knSfaI99 K3IXMqDTslc3AQjJRvmfNBrVzV873CRV14A60RMXtL0C4pPUnXIk7sEDk7uBHabc1ueu 8Shw== 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 d4-v6si411674plr.414.2018.02.01.13.56.30; Thu, 01 Feb 2018 13:56:44 -0800 (PST) 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 S1752020AbeBAVz5 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 1 Feb 2018 16:55:57 -0500 Received: from mga05.intel.com ([192.55.52.43]:57076 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730AbeBAVzw (ORCPT ); Thu, 1 Feb 2018 16:55:52 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Feb 2018 13:55:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,444,1511856000"; d="scan'208";a="24234122" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 01 Feb 2018 13:55:52 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Feb 2018 13:55:52 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 1 Feb 2018 13:55:52 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.145]) by shsmsx102.ccr.corp.intel.com ([169.254.2.124]) with mapi id 14.03.0319.002; Fri, 2 Feb 2018 05:55:49 +0800 From: "Liang, Kan" To: Arnaldo Carvalho de Melo CC: "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "wangnan0@huawei.com" , "jolsa@kernel.org" , "namhyung@kernel.org" , "ak@linux.intel.com" , "yao.jin@linux.intel.com" Subject: RE: [PATCH V5 02/17] perf mmap: fix: recalculate size for overwrite mode. Thread-Topic: [PATCH V5 02/17] perf mmap: fix: recalculate size for overwrite mode. Thread-Index: AQHTkKNt+7LbeQSb0USJiFMkktoFcKOPnliAgACOXpA= Date: Thu, 1 Feb 2018 21:55:50 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F0775381C4E7@SHSMSX103.ccr.corp.intel.com> References: <1516310792-208685-1-git-send-email-kan.liang@intel.com> <1516310792-208685-3-git-send-email-kan.liang@intel.com> <20180201212313.GD4835@kernel.org> In-Reply-To: <20180201212313.GD4835@kernel.org> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDVmZTBlNmItOTcwOC00M2JhLWFkMGQtNWNmMTJkOTg4ZWNiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6InF6RldRYVNRRlNrU1phOTJaSXA1ZTZvQTFLQ1RDb0ZnV0NxR1NNK1VjRTQ9In0= x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Em Thu, Jan 18, 2018 at 01:26:17PM -0800, kan.liang@intel.com escreveu: > > From: Kan Liang > > > > In perf_mmap__push(), the 'size' need to be recalculated, otherwise > > the invalid data might be pushed to the record in overwrite mode. > > > > The issue is introduced by commit 7fb4b407a124 ("perf mmap: Don't > > discard prev in backward mode"). > > In these cases, please add the Fixes tag, like: > > Fixes: 7fb4b407a124 ("perf mmap: Don't discard prev in backward mode") > > I'm doing it this time. > Thanks. I'll be careful next time. Thanks, Kan > Thanks, > > - Arnaldo > > > When the ringbuffer is full in overwrite mode, backward_rb_find_range > > will be called to recalculate the 'start' and 'end'. The 'size' needs > > to be recalculated accordingly. > > > > Unconditionally recalculate the 'size', not just for full ringbuffer > > in overwrite mode. Because, > > - There is no harmful to recalculate the 'size' for other cases. > > - The code of calculating 'start' and 'end' will be factored out later. > > The new function does not need to return 'size'. > > > > Signed-off-by: Kan Liang > > --- > > tools/perf/util/mmap.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/tools/perf/util/mmap.c b/tools/perf/util/mmap.c index > > 05076e6..97cf4fa 100644 > > --- a/tools/perf/util/mmap.c > > +++ b/tools/perf/util/mmap.c > > @@ -302,6 +302,8 @@ int perf_mmap__push(struct perf_mmap *md, > bool overwrite, > > return -1; > > } > > > > + size = end - start; > > + > > if ((start & md->mask) + size != (end & md->mask)) { > > buf = &data[start & md->mask]; > > size = md->mask + 1 - (start & md->mask); > > -- > > 2.5.5