rcu.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
To: "paulmck@kernel.org" <paulmck@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
	"rcu@vger.kernel.org" <rcu@vger.kernel.org>,
	"mathieu.desnoyers@efficios.com" <mathieu.desnoyers@efficios.com>,
	"jiangshanlai@gmail.com" <jiangshanlai@gmail.com>
Subject: Re: Question about list_sort() RCU version.
Date: Tue, 16 Jun 2020 23:21:56 +0000	[thread overview]
Message-ID: <BYAPR04MB49657ED94E122D33B9C53403869D0@BYAPR04MB4965.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20200616222933.GH2723@paulmck-ThinkPad-P72

On 6/16/20 3:29 PM, Paul E. McKenney wrote:
> If you want things sorted, why not a search tree?  Or, depending on the
> purpose of the sorting, a hash table?
That was my first question but the way code is written right not which 
uses linked list and then it calls list_sort() which is not a ideal data 
structure to start with.
> 
> It actually is kind-of sort-of possible to do an in-place sort of a
> linked list in the presence of readers, but the simpler ways of doing
> this are not at all pretty.  Or efficient while the sort is in progress.
> 
That is what I felt after reading a code and I'm not an expert in this 
area.
> o	Find the largest element in the yet-to-be-sorted portion of
> 	the list.  Pull that largest element to the front of the list
> 	as follows:
> 
> 	o	Set its ->next pointer to reference the first
> 		element of the list.  (Yes, the list is now
> 		looped, and readers looking for later elements
> 		will follow that loop.  Readers must do loop
> 		detection, and restart their traversal after
> 		momentarily exiting their read-side critical
> 		sections.)
> 
> 	o	Set the header pointer to reference the element
> 		being moved.  The list is still looped.
> 
> 	o	Wait for a grace period.  This is why looping
> 		readers must momentarily exit their read-side
> 		critical sections.
> 
> 	o	Make the moved item's predecessor point to the
> 		moved item's successor.
> 
> o	Repeat until the list is sorted.
> 
> Another approach is similar to Steven's suggestion, but uses a
> separate set of pointers to do the sorting, then switches the
> readers to the sorted set.  This allows better sorting algorithms
> to be used.
> 
This is the most easy approach with high memory usage.

> But why not just insert each element into its proper place in the list
> to start with?  If the list is too long for this to be efficient, you
> most likely should be using some other data structure.
> 
Agree, again not my design, and after these emails I do have questions 
on the data structure since with an efficient data structure set of the
items are also be cached that will furthermore improve the performance 
given that size of the ids is cacheline friendly.

> 						Thanx, Paul

Thanks again everyone for replying promptly and in detailed manner.

      reply	other threads:[~2020-06-16 23:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 20:17 Question about list_sort() RCU version Chaitanya Kulkarni
2020-06-16 20:24 ` Mathieu Desnoyers
2020-06-16 20:45   ` Chaitanya Kulkarni
2020-06-16 21:47 ` Steven Rostedt
2020-06-16 22:26   ` Chaitanya Kulkarni
2020-06-16 22:29   ` Paul E. McKenney
2020-06-16 23:21     ` Chaitanya Kulkarni [this message]

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=BYAPR04MB49657ED94E122D33B9C53403869D0@BYAPR04MB4965.namprd04.prod.outlook.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=paulmck@kernel.org \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /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).