Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1316109imc; Mon, 11 Mar 2019 10:59:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZS8qS6IYTgFEfVWd1XOP70VZHepcVCEZtCtfDREaT6PTpUZ8sbCP0trM9lkoQ1lrPR4te X-Received: by 2002:a63:ee55:: with SMTP id n21mr1654932pgk.211.1552327198274; Mon, 11 Mar 2019 10:59:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552327198; cv=none; d=google.com; s=arc-20160816; b=u2cSVZ5tW60nyxZw0YcaA1+baHyHw9smyOGTTEiqIW1IBNiZwiGh0veloxr6VrLKqk 5nMs1GqK6eWxzyZYVyaHWONp1ZZwCtjmgqZ0TimV+3aKBeI8xNK9QvjtFsD18AQMLrF5 JI98udwRJ7/feR+jcmbMbi2t5fJ4w4GRlTslys5Qk/yE/QDXHF2EX7G9ZeqYa5gBxMQ/ FCdMOBN+tQzW4/D2IF7iAgKFV2wLz8dk16N7z/YESWEkPFEXTXttnXUihVX/Hxw0h5OR 6xsFdJsJDTbM935iNo93c8629KvKrjemU/XGngZqIJdGjJ4yx4HICR31Df58DrJRc0Sd Kiug== 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=lZbqJGcehzWALMFqEAIgOL6VaUXLq07JaNLa0MQD3UE=; b=ll3gl1SmIPTkEoV2SsedL7ocN9PiUW3ISbTXlM6QYqh4FACW6+Q8+GVQyi+7dA/Y3z b2oEOHArUzD9vn+U6XGiE1MPvtReIeR5d7MyFu9tvPsMUDexPedZjHtZ/IlBhGXOZo3L Z3LoR9Y7XNqRXWVfOb4XQLbvnUHpDt3bPeWp/29ut2jv3f4Q7BLfN01PZYwX7+xAQRju 1hN276GSb9m7Xbn+imM/DPE2V299+YrsPZ3UVjKWa4Fsy13gLOH1Wn8WIi9yGZ8sszAg 9IsXwW2valDyGSUup6FiSB67SVajgMbR6jTI3y/RWpivBXeHWAoQfy49dLWdX9k3kQiv 4Y9Q== 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 34si5197723pgs.553.2019.03.11.10.59.42; Mon, 11 Mar 2019 10:59:58 -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 S1728220AbfCKR5G (ORCPT + 99 others); Mon, 11 Mar 2019 13:57:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728191AbfCKR5F (ORCPT ); Mon, 11 Mar 2019 13:57:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 96AD1307CDEA; Mon, 11 Mar 2019 17:57:04 +0000 (UTC) Received: from krava (ovpn-204-107.brq.redhat.com [10.40.204.107]) by smtp.corp.redhat.com (Postfix) with SMTP id E2AD35DD8D; Mon, 11 Mar 2019 17:57:01 +0000 (UTC) Date: Mon, 11 Mar 2019 18:57:00 +0100 From: Jiri Olsa To: Song Liu Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, kernel-team@fb.com, peterz@infradead.org, acme@redhat.com, jolsa@kernel.org, namhyung@kernel.org Subject: Re: [PATCH v7 perf,bpf 14/15] perf: introduce side band thread Message-ID: <20190311175700.GD19721@krava> References: <20190307175810.249857-1-songliubraving@fb.com> <20190307175810.249857-15-songliubraving@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190307175810.249857-15-songliubraving@fb.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 11 Mar 2019 17:57:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 07, 2019 at 09:58:09AM -0800, Song Liu wrote: SNIP > +static void *perf_evlist__poll_thread(void *arg) > +{ > + struct perf_evlist *evlist = arg; > + int i; > + > + while (!(evlist->thread.done)) { > + perf_evlist__poll(evlist, 1000); > + > + for (i = 0; i < evlist->nr_mmaps; i++) { > + struct perf_mmap *map = &evlist->mmap[i]; > + union perf_event *event; > + > + if (perf_mmap__read_init(map)) > + continue; > + while ((event = perf_mmap__read_event(map)) != NULL) { > + struct perf_evsel *evsel = perf_evlist__event2evsel(evlist, event); > + > + if (evsel && evsel->side_band.cb) > + evsel->side_band.cb(event, evsel->side_band.data); > + else > + pr_warning("cannot locate proper evsel for the side band event\n"); > + > + perf_mmap__consume(map); > + } > + perf_mmap__read_done(map); > + } shouldn't you drain the map before leaving? SNIP > +out_delete_evlist: > + perf_evlist__delete(evlist); > + evlist = NULL; > + return -1; > +} > + > +void perf_evlist__stop_sb_thread(struct perf_evlist *evlist) > +{ > + if (!evlist) > + return; > + evlist->thread.done = 1; > + pthread_join(evlist->thread.th, NULL); > + perf_evlist__exit(evlist); > + evlist = NULL; I think the interface is ok, but please let this function undo whatever perf_evlist__start_sb_thread did, so disable and close events and cleanup maps thanks, jirka