linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH 2/3] kernel-shark: Change the mechanism of the multi-threaded search
Date: Fri, 24 Apr 2020 16:12:46 -0400	[thread overview]
Message-ID: <20200424161246.4d9f22b8@gandalf.local.home> (raw)
In-Reply-To: <20200330161723.29816-3-y.karadz@gmail.com>


After applying this patch, I was hitting a lockup with this file:

http://rostedt.org/private/trace-all.dat.xz

By selecting "Event" and searching for "sched" it would hang at %87

I found the bug below.

On Mon, 30 Mar 2020 19:17:22 +0300
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com> wrote:

> --- a/kernel-shark/src/KsModels.cpp
> +++ b/kernel-shark/src/KsModels.cpp
> @@ -52,22 +52,25 @@ size_t KsFilterProxyModel::_search(int column,
>  				   const QString &searchText,
>  				   search_condition_func cond,
>  				   QList<int> *matchList,
> +				   int step,
>  				   int first, int last,
>  				   QProgressBar *pb,
>  				   QLabel *l,
> +				   int *lastRowSearched,
>  				   bool notify)
>  {
>  	int index, row, nRows(last - first + 1);
> -	int pbCount(1);
> +	int milestone(1), pbCount(1);
>  	QString item;
>  
>  	if (nRows > KS_PROGRESS_BAR_MAX)
> -		pbCount = nRows / (KS_PROGRESS_BAR_MAX - _searchProgress);
> +		milestone = pbCount = nRows / (KS_PROGRESS_BAR_MAX - step -
> +					       _searchProgress);
>  	else
>  		_searchProgress = KS_PROGRESS_BAR_MAX - nRows;
>  
>  	/* Loop over the items of the proxy model. */
> -	for (index = first; index <= last; ++index) {
> +	for (index = first; index <= last; index += step) {
>  		/*
>  		 * Use the index of the proxy model to retrieve the value
>  		 * of the row number in the base model.
> @@ -78,17 +81,23 @@ size_t KsFilterProxyModel::_search(int column,
>  			matchList->append(row);
>  
>  		if (_searchStop) {
> -			if (notify) {
> -				_searchProgress = KS_PROGRESS_BAR_MAX;
> +			if (lastRowSearched)
> +				*lastRowSearched = index;
> +
> +			if (notify)
>  				_pbCond.notify_one();
> -			}
>  
>  			break;
>  		}
>  
>  		/* Deal with the Progress bar of the seatch. */
> -		if ((index - first) % pbCount == 0) {
> +		if ((index - first) > milestone) {

Changing the above to:

		if ((index - first) >= milestone) {

fixes it.

> +			milestone += pbCount;
>  			if (notify) {
> +				/*
> +				 * This is a multi-threaded search. Notify
> +				 * the main thread to update the progress bar.
> +				 */
>  				std::lock_guard<std::mutex> lk(_mutex);
>  				++_searchProgress;
>  				_pbCond.notify_one();
> @@ -100,6 +109,7 @@ size_t KsFilterProxyModel::_search(int column,
>  
>  				if (l)
>  					l->setText(QString(" %1").arg(matchList->count()));
> +
>  				QApplication::processEvents();
>  			}
>  		}


 Otherwise it looks like it leaves out the final update and the
code hangs here:

	/* Start all other threads. */
	for (int r = 1; r < nThreads; ++r)
		maps.push_back(std::async(lamSearchMap,
					  startFrom + r,
					  false)); // notify = false

	while (_searchFSM.getState() == search_state_t::InProgress_s &&
	       _proxyModel.searchProgress() < KS_PROGRESS_BAR_MAX - nThreads) {
		std::unique_lock<std::mutex> lk(_proxyModel._mutex);
		_proxyModel._pbCond.wait(lk);

< It's stuck above >

		_searchFSM.setProgress(_proxyModel.searchProgress());
		QApplication::processEvents();
	}


-- Steve


  reply	other threads:[~2020-04-24 20:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 16:17 [PATCH 0/3] Have "stop" button for multi-threaded searches Yordan Karadzhov (VMware)
2020-03-30 16:17 ` [PATCH 1/3] kernel-shark: Simplify the search methods in class KsTraceViewer Yordan Karadzhov (VMware)
2020-03-30 16:17 ` [PATCH 2/3] kernel-shark: Change the mechanism of the multi-threaded search Yordan Karadzhov (VMware)
2020-04-24 20:12   ` Steven Rostedt [this message]
2020-04-27 14:44     ` Yordan Karadzhov (VMware)
2020-04-27 19:18       ` Steven Rostedt
2020-05-01  2:56         ` Steven Rostedt
2020-05-02  1:03           ` Steven Rostedt
2020-05-02 18:48             ` Yordan Karadzhov
2020-05-02 18:47           ` Yordan Karadzhov
2020-03-30 16:17 ` [PATCH 3/3] kernel-shark: Make the "stop search" button always visible Yordan Karadzhov (VMware)

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=20200424161246.4d9f22b8@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=y.karadz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).