linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [patch 11/20] hlist: Add hlist_is_last_node() helper
@ 2016-06-13 10:41 George Spelvin
  0 siblings, 0 replies; 3+ messages in thread
From: George Spelvin @ 2016-06-13 10:41 UTC (permalink / raw)
  To: tglx; +Cc: linux, linux-kernel

Shouldn't this function be called hlist_is_only_node()?

hlist_is_last_node would be simply !n->next, as "last" doesn't
imply the lack of others.

I understand how the name might make sense in the context of removing
entries from the list, but in other contexts, it's confusing.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch 11/20] hlist: Add hlist_is_last_node() helper
  2016-06-13  8:40 ` [patch 11/20] hlist: Add hlist_is_last_node() helper Thomas Gleixner
@ 2016-06-13 10:27   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-06-13 10:27 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Zijlstra, Paul E. McKenney, Eric Dumazet,
	Frederic Weisbecker, Chris Mason, Arjan van de Ven, rt



On 13/06/2016 10:40, Thomas Gleixner wrote:
>  /*
> + * Check whether the node is the last node of the head without
> + * accessing head.
> + */
> +static inline bool hlist_is_last_node(struct hlist_node *n,
> +				      struct hlist_head *h)
> +{
> +	return !n->next && n->pprev == &h->first;
> +}

Perhaps hlist_is_only_node, or hlist_is_singular_node (which is ugly but
matches list_is_singular)?  last_node seems to check only for !n->next.

Thanks,

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch 11/20] hlist: Add hlist_is_last_node() helper
  2016-06-13  8:40 [patch 00/20] timer: Refactor the timer wheel Thomas Gleixner
@ 2016-06-13  8:40 ` Thomas Gleixner
  2016-06-13 10:27   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2016-06-13  8:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Paul E. McKenney, Eric Dumazet,
	Frederic Weisbecker, Chris Mason, Arjan van de Ven, rt

[-- Attachment #1: hlist--Add-hlist_is_last_node-helper.patch --]
[-- Type: text/plain, Size: 780 bytes --]

Required to figure out whether the entry is the last one in the hlist.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/list.h |   10 ++++++++++
 1 file changed, 10 insertions(+)

Index: b/include/linux/list.h
===================================================================
--- a/include/linux/list.h
+++ b/include/linux/list.h
@@ -679,6 +679,16 @@ static inline bool hlist_fake(struct hli
 }
 
 /*
+ * Check whether the node is the last node of the head without
+ * accessing head.
+ */
+static inline bool hlist_is_last_node(struct hlist_node *n,
+				      struct hlist_head *h)
+{
+	return !n->next && n->pprev == &h->first;
+}
+
+/*
  * Move a list from one list head to another. Fixup the pprev
  * reference of the first entry if it exists.
  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-13 10:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 10:41 [patch 11/20] hlist: Add hlist_is_last_node() helper George Spelvin
  -- strict thread matches above, loose matches on Subject: below --
2016-06-13  8:40 [patch 00/20] timer: Refactor the timer wheel Thomas Gleixner
2016-06-13  8:40 ` [patch 11/20] hlist: Add hlist_is_last_node() helper Thomas Gleixner
2016-06-13 10:27   ` Paolo Bonzini

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).