From patchwork Mon Nov 28 21:50:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 9450411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0EC486071C for ; Mon, 28 Nov 2016 20:16:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0279226D05 for ; Mon, 28 Nov 2016 20:16:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB7C928068; Mon, 28 Nov 2016 20:16:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7904726D05 for ; Mon, 28 Nov 2016 20:16:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbcK1UOs (ORCPT ); Mon, 28 Nov 2016 15:14:48 -0500 Received: from p3plsmtps2ded01.prod.phx3.secureserver.net ([208.109.80.58]:53934 "EHLO p3plsmtps2ded01.prod.phx3.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754380AbcK1T4i (ORCPT ); Mon, 28 Nov 2016 14:56:38 -0500 Received: from linuxonhyperv.com ([72.167.245.219]) by : HOSTING RELAY : with SMTP id BS1Zc1yGyzI9mBS1ZcFw4s; Mon, 28 Nov 2016 12:55:37 -0700 x-originating-ip: 72.167.245.219 Received: by linuxonhyperv.com (Postfix, from userid 528) id C6CAA22B8040; Mon, 28 Nov 2016 13:51:18 -0800 (PST) From: Matthew Wilcox To: linux-kernel@vger.kernel.org, Andrew Morton , Konstantin Khlebnikov , Ross Zwisler Cc: Matthew Wilcox , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, "Kirill A . Shutemov" Subject: [PATCH v3 15/33] radix-tree: Move rcu_head into a union with private_list Date: Mon, 28 Nov 2016 13:50:19 -0800 Message-Id: <1480369871-5271-16-git-send-email-mawilcox@linuxonhyperv.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1480369871-5271-1-git-send-email-mawilcox@linuxonhyperv.com> References: <1480369871-5271-1-git-send-email-mawilcox@linuxonhyperv.com> X-CMAE-Envelope: MS4wfCYI7bRM92+0QvlKBCl1NYkj2eyh46iZ8o3nxTAbtMHWw7gdqHkjSn8T7OoUzjyys55AicBrGGd1p9EXjMMaDeo5mCerVLZqHHwJ9//ZXEHaOf2hHv0c tC8pnz048mnJp9x80q+nNAGRnU7geNQlS1B3pdz/gb9tPop3faNOCnxXYRmsLvBkyuPlQapE89OhACfCvcAefJ9X1eZWhSR5EwjWenaV8gtm722zf7DzwL75 BWjfvW7TDyPPW1k+LYJfHFWZwobfk5eJPnCjwNFzpgZrcgftYWm8VaZVJWRxy0A7NwWVCzsT/Or7zFkWa9YT4BwVREHWiuPar9wVU9kRiEERTR55cKes+SEI Rt3XYSGHyhtT0/EwrtkE+3CHK9j6rh1piyRJ+nCPQznIe2u/F3z4ZKmqClbddlXuSt9wXadA6WGqjRfiGqwegZBYsaLsag0uGC7pof6Q9INtjMZvuHI= Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox I want to be able to reference node->parent after freeing node. Currently node->parent is in a union with rcu_head, so it is overwritten when the node is put on the RCU list. We know that private_list is not referenced after the node is freed, so it is safe for these two members to share space. Signed-off-by: Matthew Wilcox --- include/linux/radix-tree.h | 14 ++++---------- lib/radix-tree.c | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index 7444860..d04073a 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -85,18 +85,12 @@ struct radix_tree_node { unsigned char offset; /* Slot offset in parent */ unsigned char count; /* Total entry count */ unsigned char exceptional; /* Exceptional entry count */ + struct radix_tree_node *parent; /* Used when ascending tree */ + void *private_data; /* For tree user */ union { - struct { - /* Used when ascending tree */ - struct radix_tree_node *parent; - /* For tree user */ - void *private_data; - }; - /* Used when freeing node */ - struct rcu_head rcu_head; + struct list_head private_list; /* For tree user */ + struct rcu_head rcu_head; /* Used when freeing node */ }; - /* For tree user */ - struct list_head private_list; void __rcu *slots[RADIX_TREE_MAP_SIZE]; unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS]; }; diff --git a/lib/radix-tree.c b/lib/radix-tree.c index b329056..3f49417 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -324,6 +324,7 @@ static void radix_tree_node_rcu_free(struct rcu_head *head) tag_clear(node, i, 0); node->slots[0] = NULL; + INIT_LIST_HEAD(&node->private_list); kmem_cache_free(radix_tree_node_cachep, node); }