Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1245531ybi; Tue, 16 Jul 2019 11:52:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVIBI9ABkhpLDj9R1flJn/kyHgBMkhEXiA6fxR1eLBrlSwB6NYpLv9J0jNsd5DdlyEHiLm X-Received: by 2002:a63:d34c:: with SMTP id u12mr20767548pgi.114.1563303128221; Tue, 16 Jul 2019 11:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563303128; cv=none; d=google.com; s=arc-20160816; b=akiVz6rX2ZQairDsQ1+0I2Y59Rf1/QNYggey2MPR92LQZ9IiBDOzWWikEHFbzvKEQM QFtfdVO7jD3dRdF7v2QfXhohxtTJUNAj0JzRp9xABc+V17DZcx64zO2rex6Vc5eU1I0+ pTtinL38wESGX/OgEawkXxQ4DbThtJUbK15aiNw6PLMsl9Rk6QM+VNfIgTllr9bimt9b 5pSEv1waEH8gOmwDXFXCYpWh0RqvlShkKNw3Xrzqe9CawOegXgZzyaJKX5kT3DM6bL6Y Go1Pg41mxY36mKDGtSCmafYyZHWfeNql9Oqv1k4YFGiz//aCgM5Agz7zbd6cbrjbxR24 +n5w== 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=I3eRYibeoQehmMKtTdehZx5shEh6xz2X8+qA77bSphY=; b=tDPx+QlL0up0QpXzi6zM4CvxEmt6Kqu+6bID10e5KQMtsaoSZ1ZDkfjPv85s9IyXdK rsw15OZ5Mzmcp+7EKV7AZ0PEK+Vx/o0DKpKE2Rwrm3PjydcL5dKW1WB6UWqriJBo6dQz KlXU6CSHGfITwxQLn+xMmi09XSnPhxmOwyDu/EQZjO30odpKoZyTbrNZpxJhZXh3FuSI ju484GywR310eHIPSFC/4wUrZw+Cb+UY8J9xP2MPgMd9V9j8f7JHnPRklQ3CMzDVTFrc FdfokDEUlI1CuVsj5xT0XdYhxsd3U6aHHyavqOYUs0aq/WA2BMIeMDiJuBybAR7GZbyj gDlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tQVTe9x8; 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 h9si19800861pgp.435.2019.07.16.11.51.51; Tue, 16 Jul 2019 11:52:08 -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=tQVTe9x8; 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 S2388486AbfGPSuH (ORCPT + 99 others); Tue, 16 Jul 2019 14:50:07 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:36636 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388432AbfGPSuH (ORCPT ); Tue, 16 Jul 2019 14:50:07 -0400 Received: by mail-qt1-f194.google.com with SMTP id z4so20716882qtc.3 for ; Tue, 16 Jul 2019 11:50:06 -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=I3eRYibeoQehmMKtTdehZx5shEh6xz2X8+qA77bSphY=; b=tQVTe9x86Mh+zED3O2osHru75jkgx3tW0LvGAKXT5kFmAzrkF4A/ZQRpK2Qf2v4YRM KqxA73e6Dklm4xOehNmekawW6aXvPU6JAKdKWVIjslixy6zmZ54kIFC4MAm+1nSGcH/8 mdeCK5yz/VSzRgY19RDZuGMXLqe+/7eAFw9wM4AUOCjQkzj85WUIjH+4ZSmF3TeN2vGD Pp8mEi0IAv28uU108mkGpoP4B1j3z5A0+SNm8IgPR9xtFl3cEQV+raMEk7irrjXqDy/U YExXR0xm5sAyhYxLFS1634VHFiaPSP9E0DS/rA1a6G2giEF7iNAXncAGRc9OtnTCGQ/8 2TbA== 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=I3eRYibeoQehmMKtTdehZx5shEh6xz2X8+qA77bSphY=; b=Oh+MBQC/ZtnskIqYLuTTgTyZmgw1OBzkfogINdlH30WVDUKeky4plVnn3dErez9fRv mCK5TA26l5mf+6708J0qbBkvIYxQwlxANiBfnxziH7nGlDDEhj4k8mWB9qE2MI2CiTny p4LtKjRtR3/6ZMukC2cB+Hlw4iYuDRKOl6bbbVxLCAGfT1wALONo3xsSmAWUZ9hnBx2U uG/5CXaviCBlvhDHvzdqa5lrwIa1FOrHshSTDgaDEPn6cVr8ggkv58xsZil5xOrDDzE/ HOl7HkHkvrU0VqZ5xVwlRVZTwlmQJPg+E8ehEN35n5wbifHpGXu6PdSHxWODs57Mt9Cv 8vjg== X-Gm-Message-State: APjAAAUyyKMYIbncBiEAsi7oFl5esPB/F0oUAlXUWtxl2WHiG/9k4SC6 PfEtZgbP3RpzplX910ZVYzcJLSlp X-Received: by 2002:ac8:5297:: with SMTP id s23mr24649595qtn.230.1563303006084; Tue, 16 Jul 2019 11:50:06 -0700 (PDT) Received: from quaco.ghostprotocols.net ([190.15.121.82]) by smtp.gmail.com with ESMTPSA id c74sm10313485qke.128.2019.07.16.11.50.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 16 Jul 2019 11:50:05 -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 79EA440340; Tue, 16 Jul 2019 15:49:59 -0300 (-03) Date: Tue, 16 Jul 2019 15:49:59 -0300 To: Alexey Budankov , Jiri Olsa Cc: 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: <20190716184959.GG3624@kernel.org> References: <4d839e1b-9c48-89c4-9702-a12217420611@linux.intel.com> <20190714154932.GC16802@krava> <389a8b98-1d53-6fe3-ff56-0789c0841292@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <389a8b98-1d53-6fe3-ff56-0789c0841292@linux.intel.com> 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 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 - :) So, Jiri, Acked-by? - Arnaldo