Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp40620pxj; Wed, 9 Jun 2021 15:56:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUVsEzmRkti8Kr5G3CnDolNUxO7pOoT7C1VJWmEcOr5xnSnbH1Pb0SkCbiVP+LyjvSBBCX X-Received: by 2002:a05:6402:1d06:: with SMTP id dg6mr1619991edb.132.1623279411696; Wed, 09 Jun 2021 15:56:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623279411; cv=none; d=google.com; s=arc-20160816; b=YZXm+OF+Ni1JGihAUKRg/DRouhn3dNkt/Lo0ZY9IAU7U3SLeQ6kdHtGA6VcXEHIqMP FY8q3mqWuu7INJKpfDx8SJT8l0V9D9RR8sq1XuShUUP0GPNtgpwjbXGT1C/1d7or60SZ +jnkoIEj295o9AGjsPf/4LejMDo+supfee6j2LgTo8q0rdwuGbuajX+SE41L8i9p0CHa 6rCZpLXekw4Ds9m4J+OPWzbaX882mXNP4Bh9S0vUszV5mRngH1Cf0/Y+tZ7Jk267Es0I 62xGFbbJX5vWmwCryC/ZpxeTSL33PdEOWJy4zYV8rD8B8RAglim4IzSxY29/XADhIoLw /Rnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=8MSqYylR/ClWK2tbw4XHVsBk6QIun8xemFhmgATk+Yg=; b=BohB4iRZLAD5lu0wu+QLogqpdguXUGZlGCnOHRt6wrzVr5J+XPs/hEZq7R9IMpjk7V r6P9uMtz6fgQRFfjoV+7236uTX2UJurBkECmdPacMZBKaOdABswv7mnAMC72NZDwfEuk 0rriKz7qiKSY0RIPgtfG5Pv/7v+J0mhDzQc7tPjAVpHtp8vhhGd4bR5O+ED/Vf1LWaid BOrjrzvF0Ts3odZBTDPLD8PxKooRE8c3ssRTVIYwinv5uS2Wq22Xv9tvlKgkWhj8/6Qz vUt+194LGeiK8nD56tBdR2qz9Is+1cGgpAlAdvugshjGTl0aabbheggA0/SMmUzWBP2Y xVCQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si755698ejr.495.2021.06.09.15.56.28; Wed, 09 Jun 2021 15:56:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbhFIW4s (ORCPT + 99 others); Wed, 9 Jun 2021 18:56:48 -0400 Received: from mail-lj1-f172.google.com ([209.85.208.172]:46791 "EHLO mail-lj1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbhFIW4s (ORCPT ); Wed, 9 Jun 2021 18:56:48 -0400 Received: by mail-lj1-f172.google.com with SMTP id e11so1910581ljn.13; Wed, 09 Jun 2021 15:54:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8MSqYylR/ClWK2tbw4XHVsBk6QIun8xemFhmgATk+Yg=; b=BBQL9gxmTGJqQjKfmTK3PafZOR1HfYIC+x+vOgU2W4/eg8QAQvwD3Dm0GJfb37jcuo rpSjFfy55u/KCAJOfNmpryqWnNGptqCVAp/zPTTuXrBJ05uCIdTJZFwN+F/F3jjzSHGE ghfxGx9b3dNGzExGReNW6/BiNc0yaAmZK40goT9eg7l+BuQPAi14hvNxDqnszrp1i2JF HI7oeOs+pH1tOWp8UWWvS2TDuF3LWQIMYs083nHm90trlCNB8kQPdGiW1Cl561IMD1cQ 6L5CvYJc68F5pXUC6sNvEOsHq3niZRUv7Di4MiXzZY4PbZkGvd30muf79m9A1tgXUh3e lE3g== X-Gm-Message-State: AOAM530RLvXl6D/AEAcsIFF/692HqcEWlub8h3V4Daa9TPShR5zKW/p5 lDzuLyCLab7lQNF9a1y/xfxg2wYOI9ZK6kRH8dI= X-Received: by 2002:a2e:a795:: with SMTP id c21mr1501932ljf.26.1623279275739; Wed, 09 Jun 2021 15:54:35 -0700 (PDT) MIME-Version: 1.0 References: <3b297a17f935d2a00bfa74afbbf064b01fe83607.camel@gmail.com> In-Reply-To: <3b297a17f935d2a00bfa74afbbf064b01fe83607.camel@gmail.com> From: Namhyung Kim Date: Wed, 9 Jun 2021 15:54:23 -0700 Message-ID: Subject: Re: [PATCH v6 03/20] perf record: Introduce thread local variable To: Riccardo Mancini Cc: Alexey Bayduraev , Jiri Olsa , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Andi Kleen , Adrian Hunter , Alexander Antonov , Alexei Budankov , linux-perf-users , Ian Rogers , Arnaldo Carvalho de Melo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Riccardo, On Thu, Jun 3, 2021 at 3:56 PM Riccardo Mancini wrote: > > Hi, > > thank you very much for your work for adding threading capabilites to perf > record. > I did some testing on your entire patchset, especially checking for memory > issues using ASan. This is just the first of a couple of emails to point out > some issues I found. > I will also do additional tests in the future. > > On Wed, 2021-05-26 at 13:52 +0300, Alexey Bayduraev wrote: > SNIP > > @@ -2220,18 +2275,20 @@ static int __cmd_record(struct record *rec, int argc, > > const char **argv) > > goto out_child; > > } > > > > - if (!quiet) > > - fprintf(stderr, "[ perf record: Woken up %ld times to write data > > ]\n", waking); > > - > > if (target__none(&rec->opts.target)) > > record__synthesize_workload(rec, true); > > > > out_child: > > + record__stop_threads(rec, &waking); > > +out_free_threads: > > record__free_thread_data(rec); > > evlist__finalize_ctlfd(rec->evlist); > > record__mmap_read_all(rec, true); > > record__aio_mmap_read_sync(rec); > > record__mmap_read_all should be moved before record__free_thread_data since it > uses the thread_data that's just been freed. > Furthermore, record__mmap_read_all should also be moved before the > out_free_threads label, since it cannot be called unless record__start_threads > succeeded, otherwise thread would be NULL and will cause a segfault (it happens > if there is an error somewhere else in perf, for example). > > In my tests the following order works, but it should be double checked for > possible side-effects of this order change. > > out_child: > record__stop_threads(rec, &waking); > record__mmap_read_all(rec, true); > out_free_threads: > record__free_thread_data(rec); > evlist__finalize_ctlfd(rec->evlist); > record__aio_mmap_read_sync(rec); I wonder how it worked before.. maybe we should place record__free_thread_data() far below. Thanks, Namhyung