Received: by 10.223.176.5 with SMTP id f5csp3254831wra; Thu, 1 Feb 2018 13:25:20 -0800 (PST) X-Google-Smtp-Source: AH8x2248K2JDd0EUJZTjYgZOnOosXRMv5g/ud2Y/Rj/kF/9l6nnvYqOVmFLClKV7Q7ZbfMFyXU1x X-Received: by 10.101.67.193 with SMTP id n1mr29827408pgp.116.1517520320269; Thu, 01 Feb 2018 13:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517520320; cv=none; d=google.com; s=arc-20160816; b=SxTMf56UWqwZYDgLB982wLWMn9Y4nbqkF1OJvzXs/nwEDRtgDFH+ScXNC6mOVp8a2x qYV5EghIKjVxEpKx9g2AX+r417J4xieiMW9crrDPN0Y0mbmE9A+7V9Js6gxKxcx3ve8s vgUMP+2ph9dKfaKV0s29xHd9rOSVE7xOMLFZqAsbxz2Km5D8H4qY2+NerTrWztM1HmbR 5cs/21j6OLuY4CziJ1Od07BxMYum8mSPeF7ZErrZnEZSVhHqZFBbENvrJzZs085Hc5zw 4tMyjBLS2igqZQlTM2EBkmpEpG5oZLAugCXP4eJhGkSX31mchIeyJtPeQqwumKndiMHC tOjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dmarc-filter:arc-authentication-results; bh=hp5sWFGuC15FVs446A1ty/AcXKowXVuIHY+ppCVFa34=; b=Wig7uwqaK1ZdjVDCFCred7BRg/8COBkjZZMSu3XPqYRgII78016k67jtLmuaySmcll PbHIOIjZSojNfrBzsTyAc/KHYWun9SSP2YB4O+rTCpQyFtwiLZHEG7AYpMqnsgSQtVpp NJYkorZ3/yGY1euDI6LZNC+uRtD9IompiyilFzxGSaAk8mzcUzGRPGCrcvA2z5AbTAN/ AmozkAoejamnauT8FtjMtHWQAVss2I8DTd0hke6FNoh+1ihL6oLkgxCgWDsZCxymUlid hn3rU5PGSxwqjrIa3eZsB35ddJXGtsNpUIbNgJqw8xdCeJHXTPH3shPwSPBd6ni8yem1 Mqlg== 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 e5-v6si357170plt.768.2018.02.01.13.25.05; Thu, 01 Feb 2018 13:25:20 -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 S1751941AbeBAVXU (ORCPT + 99 others); Thu, 1 Feb 2018 16:23:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:38666 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751821AbeBAVXQ (ORCPT ); Thu, 1 Feb 2018 16:23:16 -0500 Received: from jouet.infradead.org (179.187.7.150.dynamic.adsl.gvt.net.br [179.187.7.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EDD82217A0; Thu, 1 Feb 2018 21:23:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDD82217A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=acme@kernel.org Received: by jouet.infradead.org (Postfix, from userid 1000) id 69074144EF6; Thu, 1 Feb 2018 18:23:13 -0300 (-03) Date: Thu, 1 Feb 2018 18:23:13 -0300 From: Arnaldo Carvalho de Melo To: kan.liang@intel.com 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. Message-ID: <20180201212313.GD4835@kernel.org> References: <1516310792-208685-1-git-send-email-kan.liang@intel.com> <1516310792-208685-3-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516310792-208685-3-git-send-email-kan.liang@intel.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.9.1 (2017-09-22) 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, - 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