Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp830786ybi; Wed, 17 Jul 2019 05:35:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyua3xdYrl5D3UUcnl5sfPnYLazLB0JwR0ZIJqtKKok3JwoLYVO8yHg8SMDZHxMf55Q/hDS X-Received: by 2002:a63:d950:: with SMTP id e16mr42475592pgj.271.1563366948008; Wed, 17 Jul 2019 05:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563366948; cv=none; d=google.com; s=arc-20160816; b=LUazwHxV7swcBB5iUPpvGGmpsUz81HGGEjL84+G/cfm0cjBgYmTwljMleNP/ZG4dCz FciLINh1I/Vuv6zwfEuF4b9N7WMk8t3+cs7PphWp42hYqh1VhCqwkSLc0hecEtg0Ql6d Ui1MfxG/tCc0DUpOm+vUlLsh9TvOBuSdsU0hyAhipzscgwkq5rD0Y20mRHAMlpdNk7fv 9C96zkYESmOuoRhtpT7+236sOfyUsANo8JFvPY7q5PNbOun1o+b1QC0O4JJkjinKsAoc YzXfKXCNijzCKvIg+4ljg1ujaHgsJ10YTyxtd3Dj7FG4oW5BCcwBHsbyfVuE++CjLiVS ZI5A== 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:date:from:dkim-signature; bh=ZqYh4q54kojj7QiJfPRmhlfESpvMsxeKfpaJ0TM5c9g=; b=Qm6duiDl6q9EYQkzcFDQyNTYimheUGzenXGhAMwLXxvUl4tumbeKRj0VpkGXc4Gu6b Wl1NdNXHhRD4GyShOLalX/8i1O/+v1A+GwuLHyOK0gv64GRAJFOkA/MWgFAQ0ZZ/L1lD hPMiSGxhh1M++H1d4oD0i+INFieTLurJYnYOi8exNSxA9vsU+sGT1ImuKSz+noy++Z74 AxC4BufrkSNv65e2+9205vASm3NDOwR+ycjesLarzWabI5rFWTkrYyOLgKOVZDIP2et4 iLcwAWqGr9hyWMztzHN/88TMYANoNPJj3G6YurH51/4bAmdnTwsaxTHmiwi2DxD/YWAv 4brw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ljflD3SN; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p33si22436135pgb.0.2019.07.17.05.35.31; Wed, 17 Jul 2019 05:35:47 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ljflD3SN; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfGQMe4 (ORCPT + 99 others); Wed, 17 Jul 2019 08:34:56 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:41289 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbfGQMe4 (ORCPT ); Wed, 17 Jul 2019 08:34:56 -0400 Received: by mail-qt1-f196.google.com with SMTP id d17so23048916qtj.8 for ; Wed, 17 Jul 2019 05:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ZqYh4q54kojj7QiJfPRmhlfESpvMsxeKfpaJ0TM5c9g=; b=ljflD3SNDjjnDWAYDgUdP8KOBtTfYHumT1qFYTHZ9XtbeS9bRWK/9MC643KzSBB4W3 YIDLpkr9yRhIBfTZY+udyhcKbOe0XwgMRoFeQMArdcpO/kaO1EhP4SleRqQyKeZLt8y8 2KgGJyf8MDVRs/hCN4e7RvIQ45KBD22NqHiUJtUd480+8D7MjH36KEFVRMfccR75EZ66 0vSLrohdrwZi++3wU95iDLIVSxbsD0VqT1jZ+ZCMw9+hvFem99iFDtZ87utMqzgQS2jn 4ls+ygSP6JL+rnzVcmSxsJRvlw8RzY1u+CY2tbxXYyb2ZgWF+/kJ5vLFLCcUfvqYuzGg HzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ZqYh4q54kojj7QiJfPRmhlfESpvMsxeKfpaJ0TM5c9g=; b=DXdDyBjS/Y9xEO4hORncU7NqDYYYVsQ0Zzo9ICCJUWlBOK/jo+du5MDvmBGkiZRWRW x1+oZCP51VSiM6peW9icQs29VnsisH0bs/tgcUOB6R4gFEZWYF7AdtqSH65beEXlpmjG FdtRT41jzf5wJbYceLwbNggmBneIl5+45SgRz2Ro/gA2KtmqwvYyRnD2gjQDpEuR+PFw ixgM9rrSg3uH450bYCwxcJkAZLVB1QWHhgYOMGuLJlRg3FMfBe1ab+kP/f/JL0xNFDwm f+4v0P1iHsh0XGxZ8o8S0lJBZTB2egp9JvQCtWHP6xtpJCLHSbXmzGf4B+A0oPRsl6dx 1LMQ== X-Gm-Message-State: APjAAAUhPSmF473Zdo7YRHBCZXnascT+jFHkbzu6oigsks9KaduXO/EQ Fjh+qiSrQ5nGYDS+jI17KjuilFli X-Received: by 2002:ac8:3f55:: with SMTP id w21mr27686420qtk.217.1563366895281; Wed, 17 Jul 2019 05:34:55 -0700 (PDT) Received: from quaco.ghostprotocols.net ([179.97.35.11]) by smtp.gmail.com with ESMTPSA id g2sm9838275qkm.31.2019.07.17.05.34.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 05:34:53 -0700 (PDT) From: Arnaldo Carvalho de Melo X-Google-Original-From: Arnaldo Carvalho de Melo Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id D20A240340; Wed, 17 Jul 2019 09:34:50 -0300 (-03) Date: Wed, 17 Jul 2019 09:34:50 -0300 To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , 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: <20190717123450.GA24063@kernel.org> References: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> <20190714154932.GC16802@krava> <389a8b98-1d53-6fe3-ff56-0789c0841292@linux.intel.com> <20190716184959.GG3624@kernel.org> <20190716205930.GF28722@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190716205930.GF28722@krava> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Jul 16, 2019 at 10:59:30PM +0200, Jiri Olsa escreveu: > 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, applied. - Arnaldo