All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bayduraev, Alexey V" <alexey.v.bayduraev@linux.intel.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	Andi Kleen <ak@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Alexander Antonov <alexander.antonov@linux.intel.com>,
	Alexei Budankov <abudankov@huawei.com>,
	Riccardo Mancini <rickyman7@gmail.com>
Subject: Re: [PATCH v12 05/16] perf record: Introduce thread local variable
Date: Mon, 20 Dec 2021 12:49:25 +0300	[thread overview]
Message-ID: <9f8f8b08-04f5-38af-bb03-e86ac8d67d01@linux.intel.com> (raw)
In-Reply-To: <YazXWM7rVdaoF4yX@krava>


On 05.12.2021 18:14, Jiri Olsa wrote:
> On Tue, Nov 23, 2021 at 05:08:01PM +0300, Alexey Bayduraev wrote:
> 
> SNIP
> 
>>  
>> +	if (record__start_threads(rec))
>> +		goto out_free_threads;
>> +
>>  	/*
>>  	 * When perf is starting the traced process, all the events
>>  	 * (apart from group members) have enable_on_exec=1 set,
>> @@ -2122,7 +2175,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>>  	trigger_ready(&switch_output_trigger);
>>  	perf_hooks__invoke_record_start();
>>  	for (;;) {
>> -		unsigned long long hits = rec->samples;
>> +		unsigned long long hits = thread->samples;
>>  
>>  		/*
>>  		 * rec->evlist->bkw_mmap_state is possible to be
>> @@ -2176,8 +2229,8 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>>  
>>  			if (!quiet)
>>  				fprintf(stderr, "[ perf record: dump data: Woken up %ld times ]\n",
>> -					waking);
>> -			waking = 0;
>> +					record__waking(rec));
>> +			thread->waking = 0;
>>  			fd = record__switch_output(rec, false);
>>  			if (fd < 0) {
>>  				pr_err("Failed to switch to new file\n");
>> @@ -2191,20 +2244,24 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>>  				alarm(rec->switch_output.time);
>>  		}
>>  
>> -		if (hits == rec->samples) {
>> +		if (hits == thread->samples) {
>>  			if (done || draining)
>>  				break;
>> -			err = evlist__poll(rec->evlist, -1);
>> +			err = fdarray__poll(&thread->pollfd, -1);
>>  			/*
>>  			 * Propagate error, only if there's any. Ignore positive
>>  			 * number of returned events and interrupt error.
>>  			 */
>>  			if (err > 0 || (err < 0 && errno == EINTR))
>>  				err = 0;
>> -			waking++;
>> +			thread->waking++;
>>  
>> -			if (evlist__filter_pollfd(rec->evlist, POLLERR | POLLHUP) == 0)
>> +			if (fdarray__filter(&thread->pollfd, POLLERR | POLLHUP,
>> +					    record__thread_munmap_filtered, NULL) == 0)
>>  				draining = true;
>> +
>> +			evlist__ctlfd_update(rec->evlist,
>> +				&thread->pollfd.entries[thread->ctlfd_pos]);
> 
> hm, why is this needed? we only switch to record_thread data, right?
> there should not be any processing change

Hi,

This is necessary to propagate ctlfd events from thread->pollfd to rec->evlist
to enable evlist__ctlfd_*() functionality, see [PATCH v12 04/16].
I will add explanations to the description of the patch.

Regards,
Alexey

> 
> jirka
> 
>>  		}
>>  
>>  		if (evlist__ctlfd_process(rec->evlist, &cmd) > 0) {
>> @@ -2258,15 +2315,18 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
>>  	}
>>  
>>  	if (!quiet)
>> -		fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
>> +		fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n",
>> +			record__waking(rec));
>>  
>>  	if (target__none(&rec->opts.target))
>>  		record__synthesize_workload(rec, true);
>>  
>>  out_child:
>> -	evlist__finalize_ctlfd(rec->evlist);
>> +	record__stop_threads(rec);
>>  	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);
>>  
>>  	if (rec->session->bytes_transferred && rec->session->bytes_compressed) {
>> @@ -3158,17 +3218,6 @@ int cmd_record(int argc, const char **argv)
>>  
>>  	symbol__init(NULL);
>>  
>> -	if (rec->opts.affinity != PERF_AFFINITY_SYS) {
>> -		rec->affinity_mask.nbits = cpu__max_cpu();
>> -		rec->affinity_mask.bits = bitmap_zalloc(rec->affinity_mask.nbits);
>> -		if (!rec->affinity_mask.bits) {
>> -			pr_err("Failed to allocate thread mask for %zd cpus\n", rec->affinity_mask.nbits);
>> -			err = -ENOMEM;
>> -			goto out_opts;
>> -		}
>> -		pr_debug2("thread mask[%zd]: empty\n", rec->affinity_mask.nbits);
>> -	}
>> -
>>  	err = record__auxtrace_init(rec);
>>  	if (err)
>>  		goto out;
>> @@ -3313,7 +3362,6 @@ int cmd_record(int argc, const char **argv)
>>  
>>  	err = __cmd_record(&record, argc, argv);
>>  out:
>> -	bitmap_free(rec->affinity_mask.bits);
>>  	evlist__delete(rec->evlist);
>>  	symbol__exit();
>>  	auxtrace_record__free(rec->itr);
>> -- 
>> 2.19.0
>>
> 

  reply	other threads:[~2021-12-20  9:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-23 14:07 [PATCH v12 00/16] Introduce threaded trace streaming for basic perf record operation Alexey Bayduraev
2021-11-23 14:07 ` [PATCH v12 01/16] perf record: Introduce thread affinity and mmap masks Alexey Bayduraev
2021-12-05 15:13   ` Jiri Olsa
2021-12-20 10:37     ` Bayduraev, Alexey V
2021-11-23 14:07 ` [PATCH v12 02/16] tools lib: Introduce fdarray duplicate function Alexey Bayduraev
2021-11-23 14:07 ` [PATCH v12 03/16] perf record: Introduce thread specific data array Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 04/16] perf record: Introduce function to propagate control commands Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 05/16] perf record: Introduce thread local variable Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa
2021-12-20  9:49     ` Bayduraev, Alexey V [this message]
2021-11-23 14:08 ` [PATCH v12 06/16] perf record: Stop threads in the end of trace streaming Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 07/16] perf record: Start threads in the beginning " Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 08/16] perf record: Introduce data file at mmap buffer object Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa
2021-11-23 14:08 ` [PATCH v12 09/16] perf record: Introduce bytes written stats Alexey Bayduraev
2021-12-05 15:14   ` Jiri Olsa
2021-12-06 11:22     ` Bayduraev, Alexey V
2021-11-23 14:08 ` [PATCH v12 10/16] perf record: Introduce compressor at mmap buffer object Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 11/16] perf record: Introduce data transferred and compressed stats Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 12/16] perf record: Introduce --threads command line option Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 13/16] perf record: Extend " Alexey Bayduraev
2021-12-05 15:13   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-12-05 15:14   ` Jiri Olsa
2021-11-23 14:08 ` [PATCH v12 14/16] perf record: Implement compatibility checks Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 15/16] perf session: Load data directory files for analysis Alexey Bayduraev
2021-11-23 14:08 ` [PATCH v12 16/16] perf report: Output data file name in raw trace dump Alexey Bayduraev
2021-12-05 15:15 ` [PATCH v12 00/16] Introduce threaded trace streaming for basic perf record operation Jiri Olsa
2021-12-09 17:56   ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9f8f8b08-04f5-38af-bb03-e86ac8d67d01@linux.intel.com \
    --to=alexey.v.bayduraev@linux.intel.com \
    --cc=abudankov@huawei.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.antonov@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rickyman7@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.