Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3206839ybi; Sun, 14 Jul 2019 08:51:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzv99J+Q9yui7PMlYlknjcUMTbkBx7VxZDy1m2QRaMduUWe8lWm9ZFHbV0hUBpduAosAfqZ X-Received: by 2002:a17:902:82c4:: with SMTP id u4mr23413188plz.196.1563119506882; Sun, 14 Jul 2019 08:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563119506; cv=none; d=google.com; s=arc-20160816; b=bLwlaui+zzelaZ0zyiwwxOFIkDEaZAIniYofnSknOadIyQamBPegc+KlVWrZpeGb4h 2ST1NEZ0x1kQyZn+ZEVU5c6PI17EQ80LSZDWLbdmbU9AY/vqW+Bm3Vvf20ttXhxI+8c7 h9p4wUY5sGXZ/XmbzXDA/cKcu2CUxIVam5Nj+QF/NjVoMG7qdGUcufAU5B4Zd+/MNsTI k61LGJjkkfFm1TcMloGVzThtNnM4S6lZxjw/IdLguWKg2XP9SEVWeAPOwPVFk9GxCqXU YBoYHAXhRqE1/1DRQKrWUJ7w7rn+u8QPYMGgBPL5C6musUHOxU78GMAuFa7wNfUMgVgC sb6w== 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=bWZHQjpSQ7uZPeuc7YTc/CxT4lKEM/DHkNpvmLe7YMs=; b=zLHylcnwH+sZULHHVkU2nS37TZ0O49mTrKNpziwylED59nVnvgEkK8/uaU5VY74f2s Sh+vlQT2m+lA8qwTkM0XbSyJ14bg78qNzdjy2MBW4ccjDOwAVsJZMHdgJyqY0Swl8D99 Vfe91gDpPxIVG8IH+29lACFspLH1JiQrNVXCZH5PZp9kfWeBMzpnoPaSEP2wx4XzkI1X P8WwlDogcH4bHmmeQdJGLY6oVkNmS+pwZrJeSWS4EuIKvFBTT42bF00jUMi5wTExawAS yBoJSA+nD0P3Tp/k/tV38KqLDcPJljxZxHZAbr7l9kigzpCw1cUbqHxUqe0J1BcppL1X glVQ== 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 b22si14048280pjb.82.2019.07.14.08.51.30; Sun, 14 Jul 2019 08:51:46 -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 S1728476AbfGNPtf (ORCPT + 99 others); Sun, 14 Jul 2019 11:49:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55994 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbfGNPtf (ORCPT ); Sun, 14 Jul 2019 11:49:35 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A8F4308FB93; Sun, 14 Jul 2019 15:49:35 +0000 (UTC) Received: from krava (ovpn-204-80.brq.redhat.com [10.40.204.80]) by smtp.corp.redhat.com (Postfix) with SMTP id 9033D5C231; Sun, 14 Jul 2019 15:49:33 +0000 (UTC) Date: Sun, 14 Jul 2019 17:49:32 +0200 From: Jiri Olsa To: Alexey Budankov Cc: Arnaldo Carvalho de Melo , 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: <20190714154932.GC16802@krava> References: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sun, 14 Jul 2019 15:49:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? otherwise it lookgs good to me thanks, jirka