From patchwork Sun Apr 19 17:10:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 11497715 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 732C5112C for ; Sun, 19 Apr 2020 17:11:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BD5821473 for ; Sun, 19 Apr 2020 17:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726597AbgDSRLH (ORCPT ); Sun, 19 Apr 2020 13:11:07 -0400 Received: from mout-p-202.mailbox.org ([80.241.56.172]:15408 "EHLO mout-p-202.mailbox.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726513AbgDSRLG (ORCPT ); Sun, 19 Apr 2020 13:11:06 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 494xDn67n2zQlFh; Sun, 19 Apr 2020 19:11:05 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id rRiqKnmPV220; Sun, 19 Apr 2020 19:10:58 +0200 (CEST) From: Hauke Mehrtens To: backports@vger.kernel.org Cc: johannes@sipsolutions.net, Hauke Mehrtens Subject: [PATCH 6/8] backports: rcupdate: Add rcu_replace_pointer Date: Sun, 19 Apr 2020 19:10:37 +0200 Message-Id: <20200419171039.17268-7-hauke@hauke-m.de> In-Reply-To: <20200419171039.17268-1-hauke@hauke-m.de> References: <20200419171039.17268-1-hauke@hauke-m.de> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1904D1762 X-Rspamd-Score: -5.43 / 15.00 / 15.00 Sender: backports-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: backports@vger.kernel.org rcu_replace_pointer() was added in upstream commit a63fc6b75cca ("rcu: Upgrade rcu_swap_protected() to rcu_replace_pointer()") and is now used by the mt76 driver. Signed-off-by: Hauke Mehrtens --- backport/backport-include/linux/rcupdate.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backport/backport-include/linux/rcupdate.h b/backport/backport-include/linux/rcupdate.h index db501007..0bbfd615 100644 --- a/backport/backport-include/linux/rcupdate.h +++ b/backport/backport-include/linux/rcupdate.h @@ -77,4 +77,24 @@ rcu_head_after_call_rcu(struct rcu_head *rhp, rcu_callback_t f) } while (0) #endif +#ifndef rcu_replace_pointer +/** + * rcu_replace_pointer() - replace an RCU pointer, returning its old value + * @rcu_ptr: RCU pointer, whose old value is returned + * @ptr: regular pointer + * @c: the lockdep conditions under which the dereference will take place + * + * Perform a replacement, where @rcu_ptr is an RCU-annotated + * pointer and @c is the lockdep argument that is passed to the + * rcu_dereference_protected() call used to read that pointer. The old + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr. + */ +#define rcu_replace_pointer(rcu_ptr, ptr, c) \ +({ \ + typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \ + rcu_assign_pointer((rcu_ptr), (ptr)); \ + __tmp; \ +}) +#endif + #endif /* __BACKPORT_LINUX_RCUPDATE_H */