Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4206304ybi; Mon, 15 Jul 2019 05:33:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpwlq0J0aw86Sv+FeBaLVWqqAWNO2ze4VkawvCsDSRZdgP7f9nxVz4wUyG9VXAKyPKCp0B X-Received: by 2002:a17:902:a409:: with SMTP id p9mr28459501plq.218.1563193991822; Mon, 15 Jul 2019 05:33:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563193991; cv=none; d=google.com; s=arc-20160816; b=u3Y+LqbSczDr8zymSl/TPzTRCgbAEuDKyvvsqnKvp6S88YA6Okypz5xmDc8LoMdczi YFGvV1dnmMJJCG68qq/3slCyKnQoSecyk46yxDySA3UNPmCbbJOsUZOb29SrZKDCOu06 aKKNsXrnnDeTU3mP7Y1y6u4QOkBpkW205zHvPVuWhEXLYtZmEHoxp1vO0MX/eF2tqiUt KWfavRkEUv9g0L0t5vzsJGCOvgqdLK8gDXxtYJp5HXzf6mMggu9yg18urDzImoAIXaPp xq5+GyX/hG+yfj5qr9wVLZwCckvSHpJh7PJ4EJ1jdUJUuT+NZM1CwFUHujQPwkDZhAyU eAhA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=yNtNI09elTNsZPp5ui6+djATRoFwNM7xoceWlZ0evYo=; b=F+PmPOeWa4o2m2JsnCd4ybuQh9cNV0UNlezRN6o/1mbt5oBI2PAnMdZjPm8yQ/uW9P WxRTAky5CBT22vNfMO8Q+etWRBJt3EQOg7Uk3Az2AqMZ45trJL1Xgb2WUD50q+N2iCqs OzQ5dy2rAxHCv35hGkHvYK/n8nMd4YDFFfZvPe1BE/vx3Zq4OHwTKFWYD/zezXWikbDs otXvrp+6DAuFodbOo4hKCXBM+B6NfoLbUTasGsc36yJcypMYbVCN+e2v2/bTE+Osz6bF Tan64vghVgqtYaqKWa8dkX1XrsreeIFwf1Xl9shlgy4PsPmNFNU653qRecqm3HX0uzKP 1pLg== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j37si15846304plb.58.2019.07.15.05.32.52; Mon, 15 Jul 2019 05:33:11 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730089AbfGOMa3 (ORCPT + 99 others); Mon, 15 Jul 2019 08:30:29 -0400 Received: from mga12.intel.com ([192.55.52.136]:28483 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728933AbfGOMa3 (ORCPT ); Mon, 15 Jul 2019 08:30:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jul 2019 05:30:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,493,1557212400"; d="scan'208";a="175080825" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 15 Jul 2019 05:30:28 -0700 Received: from [10.125.252.236] (abudanko-mobl.ccr.corp.intel.com [10.125.252.236]) by linux.intel.com (Postfix) with ESMTP id C8488580372; Mon, 15 Jul 2019 05:30:25 -0700 (PDT) Subject: Re: [PATCH v1] perf session: fix loading of compressed data split across adjacent records To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> <20190714154932.GC16802@krava> From: Alexey Budankov Organization: Intel Corp. Message-ID: <389a8b98-1d53-6fe3-ff56-0789c0841292@linux.intel.com> Date: Mon, 15 Jul 2019 15:30:24 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20190714154932.GC16802@krava> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 - :) ~Alexey > > otherwise it lookgs good to me > > thanks, > jirka >