From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80C16C43381 for ; Mon, 1 Apr 2019 17:34:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5215520856 for ; Mon, 1 Apr 2019 17:34:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140059; bh=3UhkprX9JsAoNkNCRVaFstaZOE8z8fAO8ei/+0o0eBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=R/BCrrPqi+5dWZtwmc2jk1eEZH6S30ijvaMkaTJIbV2ixJkOuN1fTCz4PiR8BydfL HIFpA1NshksNDzBbcyBPA3YmdRi8xN6fRxdGNFUm5FAqITv+yPJCXUcM63pwDxp14T D5keB/P1r9u5TRaTS3IBCAxwN9F0F726pEYOARYw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387743AbfDAReS (ORCPT ); Mon, 1 Apr 2019 13:34:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:44022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387740AbfDAReR (ORCPT ); Mon, 1 Apr 2019 13:34:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 676FF20896; Mon, 1 Apr 2019 17:34:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554140056; bh=3UhkprX9JsAoNkNCRVaFstaZOE8z8fAO8ei/+0o0eBM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kznqe97/BIcSwNRYrw17Ny4WlGCkE9WdG+4X8kd0csHGsekNSkPCNH+Ld942TT5iq STidNiUTiORkYwAPxWYX39e9J7lKg9yFSWWRapY1HkGMpOS1Aez8g5VEXsxVVGWZXV YUaMkNzcdIQrGS56azs9pqCW3Z97KxTv7h21HlNk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "David S. Miller" Subject: [PATCH 4.4 094/131] Add hlist_add_tail_rcu() (Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net) Date: Mon, 1 Apr 2019 19:02:44 +0200 Message-Id: <20190401170059.818827375@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170051.645954551@linuxfoundation.org> References: <20190401170051.645954551@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: David S. Miller commit 1602f49b58abcb0d34a5f0a29d68e7c1769547aa upstream. [This commit was a merge, but it added hlist_add_tail_rcu(), which is what we need in this stable tree, so I've changed the subject to be more descriptive - gregkh] Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/rculist.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) --- a/include/linux/rculist.h +++ b/include/linux/rculist.h @@ -402,6 +402,42 @@ static inline void hlist_add_head_rcu(st } /** + * hlist_add_tail_rcu + * @n: the element to add to the hash list. + * @h: the list to add to. + * + * Description: + * Adds the specified element to the specified hlist, + * 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 hlist_add_head_rcu() + * or hlist_del_rcu(), running on this same list. + * However, it is perfectly legal to run concurrently with + * the _rcu list-traversal primitives, such as + * hlist_for_each_entry_rcu(), used to prevent memory-consistency + * problems on Alpha CPUs. Regardless of the type of CPU, the + * list-traversal primitive must be guarded by rcu_read_lock(). + */ +static inline void hlist_add_tail_rcu(struct hlist_node *n, + struct hlist_head *h) +{ + struct hlist_node *i, *last = NULL; + + for (i = hlist_first_rcu(h); i; i = hlist_next_rcu(i)) + last = i; + + if (last) { + n->next = last->next; + n->pprev = &last->next; + rcu_assign_pointer(hlist_next_rcu(last), n); + } else { + hlist_add_head_rcu(n, h); + } +} + +/** * hlist_add_before_rcu * @n: the new element to add to the hash list. * @next: the existing element to add the new element before.