Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1372386ybi; Tue, 16 Jul 2019 14:00:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6uGZ4zZ2Z7LQPVoVEZiW9qfmlgKbUqrVMuI1QdCpr5olHpPMaxKxSvS2Luw8dgETahQjW X-Received: by 2002:a63:ee04:: with SMTP id e4mr12209767pgi.53.1563310827613; Tue, 16 Jul 2019 14:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563310827; cv=none; d=google.com; s=arc-20160816; b=WYSqghjXy2PxSX/hGxhVSczoGBkfJplOfk3DCrHmiRDc/tKkkLgzfCfmErKE7eun53 9IzaNgYyAZcQKK0cZUQDGOHlOfZG6b8mCbH8Lx+wyppQFiMGNoy/NQulMRvbg5PpJyUj daYGuwdMrgy8I1pV1mBxTIFaZerVQFE8AP3sCzpzTowIs1ADnFkUqHoRasm8C3frlOIg oeOvXqnfszNe2d36HVzsQtR05aurjB++dQ8Oh28H4SSZ61vUqy5ud6RW4Wkw3qjvY05G a5HiLLTek6j09/sRHWV2z4PgAmuwPVJ1UgknOj75TKi7Spx4F4qTBno1nRzAuJi2hzpJ hovw== 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; bh=gw8/QM2TF2i3x/LXbO1QaXnh7zIHBgbEX/tRiPTqctE=; b=XMqA04hHHaafE6xe/QizNQhBY1BP8GbTLTsU51XvVst+eUiQAp69C7NPazJsdkHc+J WIALOzO6lfuYtCdREhQPSt5zO3xDUTLNpPHbVAPoEYc3QtMGI4qNUuwvSh/YOoLTQSxm tBvnRNmots4HE51Uogy7GQBu9Y9LGdwspnkrP5dukaEvQg6MjGkRJoDB70wfCKVs/YQw 6jxFLAfSer1CflL8hUzw5KzSOSHkmsIWAk5MFqJ5eaRUhtjUff17wwtybZT4LotizOrJ W7mt0yRiQGqA0adnWNjhbWdK886KDmz6E9EcjiX6/EPpCtHKlQptv1jOuZLjeAFs3MIe p4Eg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci19si19721102plb.165.2019.07.16.14.00.09; Tue, 16 Jul 2019 14:00:27 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388837AbfGPU7f (ORCPT + 99 others); Tue, 16 Jul 2019 16:59:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42676 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728781AbfGPU7e (ORCPT ); Tue, 16 Jul 2019 16:59:34 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BD16308424C; Tue, 16 Jul 2019 20:59:34 +0000 (UTC) Received: from krava (ovpn-204-33.brq.redhat.com [10.40.204.33]) by smtp.corp.redhat.com (Postfix) with SMTP id 5E5D060A9F; Tue, 16 Jul 2019 20:59:31 +0000 (UTC) Date: Tue, 16 Jul 2019 22:59:30 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Alexey Budankov , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel Subject: Re: [PATCH v1] perf session: fix loading of compressed data split across adjacent records Message-ID: <20190716205930.GF28722@krava> References: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> <20190714154932.GC16802@krava> <389a8b98-1d53-6fe3-ff56-0789c0841292@linux.intel.com> <20190716184959.GG3624@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190716184959.GG3624@kernel.org> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 16 Jul 2019 20:59:34 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 16, 2019 at 03:49:59PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Jul 15, 2019 at 03:30:24PM +0300, Alexey Budankov escreveu: > > On 14.07.2019 18:49, Jiri Olsa wrote: > > > On Tue, Jul 09, 2019 at 05:48:14PM +0300, Alexey Budankov wrote: > > > > > > SNIP > > > > > >> decomp->file_pos = file_offset; > > >> + decomp->mmap_len = mmap_len; > > >> decomp->head = 0; > > >> > > >> - if (decomp_last) { > > >> - decomp_last_rem = decomp_last->size - decomp_last->head; > > >> + if (decomp_last_rem) { > > >> memcpy(decomp->data, &(decomp_last->data[decomp_last->head]), decomp_last_rem); > > >> decomp->size = decomp_last_rem; > > >> } > > >> @@ -61,7 +67,7 @@ static int perf_session__process_compressed_event(struct perf_session *session, > > >> decomp_size = zstd_decompress_stream(&(session->zstd_data), src, src_size, > > >> &(decomp->data[decomp_last_rem]), decomp_len - decomp_last_rem); > > >> if (!decomp_size) { > > >> - munmap(decomp, sizeof(struct decomp) + decomp_len); > > >> + munmap(decomp, mmap_len); > > >> pr_err("Couldn't decompress data\n"); > > >> return -1; > > >> } > > >> @@ -255,15 +261,15 @@ static void perf_session__delete_threads(struct perf_session *session) > > >> static void perf_session__release_decomp_events(struct perf_session *session) > > >> { > > >> struct decomp *next, *decomp; > > >> - size_t decomp_len; > > >> + size_t mmap_len; > > >> next = session->decomp; > > >> - decomp_len = session->header.env.comp_mmap_len; > > >> do { > > >> decomp = next; > > >> if (decomp == NULL) > > >> break; > > >> next = decomp->next; > > >> - munmap(decomp, decomp_len + sizeof(struct decomp)); > > >> + mmap_len = decomp->mmap_len; > > >> + munmap(decomp, mmap_len); > > > > > > what's the need for extra mmap_len variable in here? > > > could you just use decomp->mmap_len directly? > > > > To avoid reference to the object being deallocated. > > Plain munmap(), yes - :) well it's passed as value, so should be ok, anyway I was just curious, if I'm not missing something else.. it's ok ;-) > > So, Jiri, Acked-by? yep ;-) Acked-by: Jiri Olsa thanks, jirka > > - Arnaldo