Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp511249yba; Mon, 1 Apr 2019 10:45:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqykcSsJdEiI/B/wVOs1fCQgPixMkl69kR6TFU5nNe1jKu5L71oeo/eYKAqsbs2rVzDpbT/a X-Received: by 2002:a17:902:8f92:: with SMTP id z18mr12807088plo.123.1554140751687; Mon, 01 Apr 2019 10:45:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554140751; cv=none; d=google.com; s=arc-20160816; b=GwLGTnJ2n0s2Dd9TttCRydhsquZ5tcHXES658UEL3IQwhcRWtu+2zVLYq8BjwkEEnK DuYZVZMWWTMCicYh8jjwDV6oJzU4E9KaETctvbvuG3JTkWWkxch4RtHk6XM8yCS985VD ySod1HJaLQr08Ccs+sQ0N9L/89hacUAxuDkJ0ZvP2jHGGfLCRSAIHW/+rbLiZ6vCnOr5 eCAgudM+X9HkcRsOcG5btt5Y1RfQHpH+h4TfEQC0Oaf/Ybuj0H7jYAMWCKoa3rUyESAp kPhZYmmSssBhzLVqhMoI+YOdDduRipN4RHlKdnuRuz3D0QNXfdYhVOgaQ73o800jrnO/ JXKg== 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:date:subject:cc:to :from:dkim-signature; bh=VmoV4PjWkiwnVlFTVkS0iW9TtNJEqkR79TU81tX347Q=; b=Otxs5JDfAiMmLBnGGahf29sdiRZ+32pYY8u+B9nDi1Wu6Ew8IQTp6pBwI0tMDf5t1a 4hA4H+GQtUqFwson3bO5sWYdoOEb251whuV3gxIQaCeuS/qw8DVp+/5gbpRDqPqDwjdK mlxXZ5c/+xjfeDAXMDL73Rko8MS1DHZZP0+hTgsl0uSHcYa/SvZDgFwKLJVSLgaNWVX5 w8sDsS/Z5lNIxqOUIk1xfEfsvldY2SwLz6U1wqZegbYDCJ/37TSKn+BmO0NyRR4VjNT/ 1CemOoc99EWtDqjZaVe+Ku8sgkoQLlFXwSlkKUMmOUR+iU2FWyywYjEwJUv7x+kskIgR wmuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Kznqe97/"; 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 u9si952934plq.162.2019.04.01.10.45.36; Mon, 01 Apr 2019 10:45:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b="Kznqe97/"; 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 S2387766AbfDAReX (ORCPT + 99 others); Mon, 1 Apr 2019 13:34:23 -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: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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.