Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752225AbdI0Lo5 (ORCPT ); Wed, 27 Sep 2017 07:44:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58378 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750854AbdI0Lo4 (ORCPT ); Wed, 27 Sep 2017 07:44:56 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80F1A7E425 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=jolsa@redhat.com Date: Wed, 27 Sep 2017 13:44:52 +0200 From: Jiri Olsa To: kan.liang@intel.com Cc: acme@kernel.org, peterz@infradead.org, mingo@redhat.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, lukasz.odzioba@intel.com, ak@linux.intel.com Subject: Re: [PATCH RFC V3 3/5] perf top: implement multithreading for perf_event__synthesize_threads Message-ID: <20170927114452.GA29254@krava> References: <1506370988-56587-1-git-send-email-kan.liang@intel.com> <1506370988-56587-4-git-send-email-kan.liang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1506370988-56587-4-git-send-email-kan.liang@intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 27 Sep 2017 11:44:56 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1144 Lines: 45 On Mon, Sep 25, 2017 at 01:23:06PM -0700, kan.liang@intel.com wrote: SNIP > + > +int perf_event__synthesize_threads(struct perf_tool *tool, > + perf_event__handler_t process, > + struct machine *machine, > + bool mmap_data, > + unsigned int proc_map_timeout, > + unsigned int nr_threads_synthesize) > +{ > + struct synthesize_threads_arg *args = NULL; > + pthread_t *synthesize_threads = NULL; > + char proc_path[PATH_MAX]; > + struct dirent **dirent; > + int num_per_thread; > + int m, n, i, j; > + int thread_nr; > + int base = 0; > + int err = -1; > + > + > + if (machine__is_default_guest(machine)) > + return 0; > + > + snprintf(proc_path, sizeof(proc_path), "%s/proc", machine->root_dir); > + n = scandir(proc_path, &dirent, 0, alphasort); > + if (n < 0) > + return err; > + > + thread_nr = nr_threads_synthesize; > + if (thread_nr <= 0) > + thread_nr = 1; given the number of callers with 'nr_threads_synthesize == 1', could you just make it the special case in here, like: if (thread_nr == 1) return __perf_event__synthesize_threads looks like all the args are ready at this time thanks, jirka