Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp181469imm; Thu, 31 May 2018 21:49:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJuNmPgW7lfYutbOtLbooG+P1CF+SVm0UkDgrNsfP6Z93JcbtOhJAN/frZoWWyeTmvpiUlW X-Received: by 2002:a17:902:b692:: with SMTP id c18-v6mr9568594pls.307.1527828597154; Thu, 31 May 2018 21:49:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527828597; cv=none; d=google.com; s=arc-20160816; b=D1pRUT5zzBMnJ9tE1XvkRLBR1OrT8SFGiNFqbCwzXA15Sk5yDabsgkD/OTSPh0CI8H qmqlDwUyXJjdr9Sbo9SDaYyxB6y19qwaWZWROCJ3ERIL0Rl+1IHP8MHXDokTCVWS2cbF js3ccjAvjnVvwGdnwzXy6/bmO4O95AbTi8QY3BtXQhxzbN02EhnqIe0w4p108VYYyU1k VjJ23JshFpSzdlU6/qk+dsK3iC+yMrRx7n9y69AZTJwW8WyVms/JPj8B69x6cyNBE+c1 amL4kIGiS6hoh+S0ln12G8HNU3mf50xgytgNifdtP6/BD5z26yQcik4j0+0tWcF9c/YG eTlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from:arc-authentication-results; bh=mpRmrZkvcyef6iAGLF1Q2pYCFtI3qcBVLkJvZ12BBzk=; b=G9tWyzCKPXdSBfExPbJsgPvwcebUKlVxeDJVJ3q6/k1FdVczhIqliAIQaoRuEtr6E2 mB4bKVXts00We7BZOKPMr+V5pzS1MJAu6ab5CpQhIPjRpfPG0nHOEK2F/8uiex3bYOqH ZcS9LkwK9d7O5BWDLoiJHTNcP1ywFf4/p7MhfJl+Fhv2kPVczpg3K/F/aZy2T15WZOJl EMqpCj6j5AC3SSss79noyzRVjVarF9/HO/PH7eySCxeSQU5jnXr6Bi41RTr8mxa3Rab0 jo3JD9K7AeyixB1QxpwMI5gE0GEueI//t+GycjZ3VLQaVYwVvFr+BHDJu1FlA/GH9cdS frNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d8-v6si29632451pgn.428.2018.05.31.21.49.12; Thu, 31 May 2018 21:49:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751436AbeFAErc (ORCPT + 99 others); Fri, 1 Jun 2018 00:47:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:34217 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750961AbeFAEqy (ORCPT ); Fri, 1 Jun 2018 00:46:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext-too.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 8F560AD02; Fri, 1 Jun 2018 04:46:52 +0000 (UTC) From: NeilBrown To: Thomas Graf , Herbert Xu Date: Fri, 01 Jun 2018 14:44:09 +1000 Subject: [PATCH 17/18] rhashtable: rename rht_for_each*continue as *from. Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <152782824992.30340.13679240743690463593.stgit@noble> In-Reply-To: <152782754287.30340.4395718227884933670.stgit@noble> References: <152782754287.30340.4395718227884933670.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pattern set by list.h is that for_each..continue() iterators start at the next entry after the given one, while for_each..next() iterators start at the given entry. The rht_for_each*continue() iterates are documented as though the start at the 'next' entry, but actually start at the given entry, and they are used expecting that behaviour. So fix the documentation and change the names to *from for consistency with list.h Signed-off-by: NeilBrown --- .clang-format | 8 ++++---- include/linux/rhashtable.h | 38 +++++++++++++++++++------------------- lib/rhashtable.c | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.clang-format b/.clang-format index faffc0d5af4e..53a5188df01a 100644 --- a/.clang-format +++ b/.clang-format @@ -332,14 +332,14 @@ ForEachMacros: - 'rhl_for_each_entry_rcu' - 'rhl_for_each_rcu' - 'rht_for_each' - - 'rht_for_each_continue' + - 'rht_for_each_from' - 'rht_for_each_entry' - - 'rht_for_each_entry_continue' + - 'rht_for_each_entry_from' - 'rht_for_each_entry_rcu' - - 'rht_for_each_entry_rcu_continue' + - 'rht_for_each_entry_rcu_from' - 'rht_for_each_entry_safe' - 'rht_for_each_rcu' - - 'rht_for_each_rcu_continue' + - 'rht_for_each_rcu_from' - '__rq_for_each_bio' - 'rq_for_each_segment' - 'scsi_for_each_prot_sg' diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index f58cb62dce05..e148f72d4a89 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -418,13 +418,13 @@ static inline struct rhash_head __rcu **rht_bucket_insert( } /** - * rht_for_each_continue - continue iterating over hash chain + * rht_for_each_from - iterate over hash chain from given head * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from + * @head: the &struct rhash_head to start from * @tbl: the &struct bucket_table * @hash: the hash value / bucket index */ -#define rht_for_each_continue(pos, head, tbl, hash) \ +#define rht_for_each_from(pos, head, tbl, hash) \ for (pos = rht_dereference_bucket(head, tbl, hash); \ !rht_is_a_nulls(pos); \ pos = rht_dereference_bucket((pos)->next, tbl, hash)) @@ -436,18 +436,18 @@ static inline struct rhash_head __rcu **rht_bucket_insert( * @hash: the hash value / bucket index */ #define rht_for_each(pos, tbl, hash) \ - rht_for_each_continue(pos, rht_ptr(*rht_bucket(tbl, hash)), tbl, hash) + rht_for_each_from(pos, rht_ptr(*rht_bucket(tbl, hash)), tbl, hash) /** - * rht_for_each_entry_continue - continue iterating over hash chain + * rht_for_each_entry_from - iterate over hash chain from given head * @tpos: the type * to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from + * @head: the &struct rhash_head to start from * @tbl: the &struct bucket_table * @hash: the hash value / bucket index * @member: name of the &struct rhash_head within the hashable struct. */ -#define rht_for_each_entry_continue(tpos, pos, head, tbl, hash, member) \ +#define rht_for_each_entry_from(tpos, pos, head, tbl, hash, member) \ for (pos = rht_dereference_bucket(head, tbl, hash); \ (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ pos = rht_dereference_bucket((pos)->next, tbl, hash)) @@ -461,7 +461,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( * @member: name of the &struct rhash_head within the hashable struct. */ #define rht_for_each_entry(tpos, pos, tbl, hash, member) \ - rht_for_each_entry_continue(tpos, pos, rht_ptr(*rht_bucket(tbl, hash)), \ + rht_for_each_entry_from(tpos, pos, rht_ptr(*rht_bucket(tbl, hash)), \ tbl, hash, member) /** @@ -487,9 +487,9 @@ static inline struct rhash_head __rcu **rht_bucket_insert( rht_dereference_bucket(pos->next, tbl, hash) : NULL) /** - * rht_for_each_rcu_continue - continue iterating over rcu hash chain + * rht_for_each_rcu_from - iterate over rcu hash chain from given head * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from + * @head: the &struct rhash_head to start from * @tbl: the &struct bucket_table * @hash: the hash value / bucket index * @@ -497,7 +497,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( * the _rcu mutation primitives such as rhashtable_insert() as long as the * traversal is guarded by rcu_read_lock(). */ -#define rht_for_each_rcu_continue(pos, head, tbl, hash) \ +#define rht_for_each_rcu_from(pos, head, tbl, hash) \ for (({barrier(); }), \ pos = rht_ptr(rht_dereference_bucket_rcu(head, tbl, hash)); \ !rht_is_a_nulls(pos); \ @@ -521,10 +521,10 @@ static inline struct rhash_head __rcu **rht_bucket_insert( pos = rcu_dereference_raw(pos->next)) /** - * rht_for_each_entry_rcu_continue - continue iterating over rcu hash chain + * rht_for_each_entry_rcu_from - iterated over rcu hash chain from given head * @tpos: the type * to use as a loop cursor. * @pos: the &struct rhash_head to use as a loop cursor. - * @head: the previous &struct rhash_head to continue from + * @head: the &struct rhash_head to start from * @tbl: the &struct bucket_table * @hash: the hash value / bucket index * @member: name of the &struct rhash_head within the hashable struct. @@ -533,7 +533,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( * the _rcu mutation primitives such as rhashtable_insert() as long as the * traversal is guarded by rcu_read_lock(). */ -#define rht_for_each_entry_rcu_continue(tpos, pos, head, tbl, hash, member) \ +#define rht_for_each_entry_rcu_from(tpos, pos, head, tbl, hash, member) \ for (({barrier(); }), \ pos = rht_dereference_bucket_rcu(head, tbl, hash); \ (!rht_is_a_nulls(pos)) && rht_entry(tpos, pos, member); \ @@ -552,7 +552,7 @@ static inline struct rhash_head __rcu **rht_bucket_insert( * traversal is guarded by rcu_read_lock(). */ #define rht_for_each_entry_rcu(tpos, pos, tbl, hash, member) \ - rht_for_each_entry_rcu_continue(tpos, pos, \ + rht_for_each_entry_rcu_from(tpos, pos, \ rht_ptr(*rht_bucket(tbl, hash)), \ tbl, hash, member) @@ -609,7 +609,7 @@ static inline struct rhash_head *__rhashtable_lookup( hash = rht_key_hashfn(ht, tbl, key, params); head = rht_bucket(tbl, hash); do { - rht_for_each_rcu_continue(he, *head, tbl, hash) { + rht_for_each_rcu_from(he, *head, tbl, hash) { if (params.obj_cmpfn ? params.obj_cmpfn(&arg, rht_obj(ht, he)) : rhashtable_compare(&arg, rht_obj(ht, he))) @@ -744,7 +744,7 @@ static inline void *__rhashtable_insert_fast( } - rht_for_each_continue(head, rht_ptr(*headp), tbl, hash) { + rht_for_each_from(head, rht_ptr(*headp), tbl, hash) { struct rhlist_head *plist; struct rhlist_head *list; @@ -1027,7 +1027,7 @@ static inline int __rhashtable_remove_fast_one( lock = pprev; rht_lock(lock); - rht_for_each_continue(he, rht_ptr(*pprev), tbl, hash) { + rht_for_each_from(he, rht_ptr(*pprev), tbl, hash) { struct rhlist_head *list; list = container_of(he, struct rhlist_head, rhead); @@ -1189,7 +1189,7 @@ static inline int __rhashtable_replace_fast( lock = pprev; rht_lock(lock); - rht_for_each_continue(he, rht_ptr(*pprev), tbl, hash) { + rht_for_each_from(he, rht_ptr(*pprev), tbl, hash) { if (he != obj_old) { pprev = &he->next; continue; diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 1b9820787cd5..84288142ddf6 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -232,7 +232,7 @@ static int rhashtable_rehash_one(struct rhashtable *ht, err = -ENOENT; - rht_for_each_continue(entry, rht_ptr(*pprev), old_tbl, old_hash) { + rht_for_each_from(entry, rht_ptr(*pprev), old_tbl, old_hash) { err = 0; next = rht_dereference_bucket(entry->next, old_tbl, old_hash); @@ -527,7 +527,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht, int elasticity; elasticity = RHT_ELASTICITY; - rht_for_each_continue(head, rht_ptr(*pprev), tbl, hash) { + rht_for_each_from(head, rht_ptr(*pprev), tbl, hash) { struct rhlist_head *list; struct rhlist_head *plist;