mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Ken Helias <kenhelias@web.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, Ken Helias <kenhelias@firemail.de>,
	Dipankar Sarma <dipankar@in.ibm.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Oleg Nesterov <oleg@redhat.com>, Dave Jones <davej@redhat.com>
Subject: Re: [PATCH 03/13] list: Add list_add_(before|after) macros
Date: Fri, 6 Jun 2014 12:51:35 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.1406061242370.16010@eggly.anvils> (raw)
In-Reply-To: <1402076072-4044-3-git-send-email-kenhelias@web.de>

On Fri, 6 Jun 2014, Ken Helias wrote:
> From: Ken Helias <kenhelias@firemail.de>
> 
> Many places in the code uses list_add_tail/list_add to insert an entry
> before/after another entry. This confuses the reader because these are usually
> used to add an item to a list_head and not an entry. hlist already have
> functions to do the same which makes the code a lot more readable. It would be
> a lot easier to understand when all places use a self explaining function name
> instead of misusing other functions.

I'll express my opinion: perhaps it's widely shared, perhaps it is not.

I think a patch like this (and the subsequent conversions) is unhelpful
churn.

The Linux struct list_head is designed and intended to be used for both
head and entry, and introducing aliases to make unnecessary distinctions
just hinders development instead of helping it.

If the reader is confused at first, I hope the reader will soon learn,
without needing to rely on aliases such as these.

Hugh

> 
> Signed-off-by: Ken Helias <kenhelias@firemail.de>
> Cc: Dipankar Sarma <dipankar@in.ibm.com>
> Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> Cc: Oleg Nesterov <oleg@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Ken Helias <kenhelias@firemail.de>
> Cc: Dave Jones <davej@redhat.com>
> ---
>  include/linux/list.h    | 22 ++++++++++++++++++++++
>  include/linux/rculist.h | 38 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 60 insertions(+)
> 
> diff --git a/include/linux/list.h b/include/linux/list.h
> index ab43d01..5ea0eca 100644
> --- a/include/linux/list.h
> +++ b/include/linux/list.h
> @@ -76,6 +76,28 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
>  	__list_add(new, head->prev, head);
>  }
>  
> +/**
> + * list_add_after
> + * @n: new entry to be added
> + * @prev: the existing element to add the new element after.
> + *
> + * Description:
> + * Adds the specified element to the specified list
> + * after the specified node.
> + */
> +#define list_add_after(n, prev) list_add(n, prev)
> +
> +/**
> + * list_add_before
> + * @n: new entry to be added
> + * @next:  the existing element to add the new element before.
> + *
> + * Description:
> + * Adds the specified element to the specified list
> + * before the specified node.
> + */
> +#define list_add_before(n, next) list_add_tail(n, next)
> +
>  /*
>   * Delete a list entry by making the prev/next entries
>   * point to each other.
> diff --git a/include/linux/rculist.h b/include/linux/rculist.h
> index 648773f..eec274d 100644
> --- a/include/linux/rculist.h
> +++ b/include/linux/rculist.h
> @@ -103,6 +103,44 @@ static inline void list_add_tail_rcu(struct list_head *new,
>  }
>  
>  /**
> + * list_add_after_rcu
> + * @n: new entry to be added
> + * @prev: the existing element to add the new element after.
> + *
> + * Description:
> + * Adds the specified element to the specified list
> + * after the specified node while permitting racing traversals.
> + *
> + * The caller must take whatever precautions are necessary
> + * (such as holding appropriate locks) to avoid racing
> + * with another list-mutation primitive, such as list_add_rcu()
> + * or list_del_rcu(), running on this same list.
> + * However, it is perfectly legal to run concurrently with
> + * the _rcu list-traversal primitives, such as
> + * list_for_each_entry_rcu().
> + */
> +#define list_add_after_rcu(n, next) list_add_rcu(n, next)
> +
> +/**
> + * list_add_before_rcu
> + * @n: new entry to be added
> + * @next:  the existing element to add the new element before.
> + *
> + * Description:
> + * Adds the specified element to the specified list
> + * before the specified node while permitting racing traversals.
> + *
> + * The caller must take whatever precautions are necessary
> + * (such as holding appropriate locks) to avoid racing
> + * with another list-mutation primitive, such as list_add_tail_rcu()
> + * or list_del_rcu(), running on this same list.
> + * However, it is perfectly legal to run concurrently with
> + * the _rcu list-traversal primitives, such as
> + * list_for_each_entry_rcu().
> + */
> +#define list_add_before_rcu(n, next) list_add_tail_rcu(n, next)
> +
> +/**
>   * list_del_rcu - deletes entry from list without re-initialization
>   * @entry: the element to delete from the list.
>   *
> -- 
> 2.0.0

  reply	other threads:[~2014-06-06 19:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 17:34 [PATCHv2 01/13] list: Use argument hlist_add_after names from rcu variant Ken Helias
2014-06-06 17:34 ` [PATCHv2 02/13] list: Fix order of arguments for hlist_add_after(_rcu) Ken Helias
2014-06-06 17:34 ` [PATCH 03/13] list: Add list_add_(before|after) macros Ken Helias
2014-06-06 19:51   ` Hugh Dickins [this message]
2014-06-07 13:34     ` Christoph Hellwig
2014-06-06 17:34 ` [PATCH 04/13] metag: dma: Use " Ken Helias
2014-06-06 17:34 ` [PATCH 05/13] powerpc: " Ken Helias
2014-06-06 17:34 ` [PATCH 06/13] EDAC: " Ken Helias
2014-06-06 17:34 ` [PATCH 07/13] PCI: " Ken Helias
2014-06-06 17:34 ` [PATCH 08/13] mac80211: " Ken Helias
2014-06-06 17:34 ` [PATCH 09/13] jfs: " Ken Helias
2014-06-06 17:34 ` [PATCH 10/13] xhci: " Ken Helias
2014-06-06 17:34 ` [PATCH 11/13] iscsi-target: " Ken Helias
2014-06-06 17:34 ` [PATCH 12/13] s390: " Ken Helias
2014-06-06 17:34 ` [PATCH 13/13] staging: tidspbridge: " Ken Helias

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=alpine.LSU.2.11.1406061242370.16010@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=davej@redhat.com \
    --cc=dipankar@in.ibm.com \
    --cc=kenhelias@firemail.de \
    --cc=kenhelias@web.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=paulmck@linux.vnet.ibm.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

all inboxes | Powered by JetHome®