Received: by 10.192.165.148 with SMTP id m20csp2220547imm; Thu, 3 May 2018 12:27:01 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpmEkK3NuYsYm75JNCWC/qQ/2bpCbbCeGtXXTYR8QgPuGZB9GYSCO4qPWaxdxDslj6A+wxL X-Received: by 2002:a63:3c0c:: with SMTP id j12-v6mr20856288pga.203.1525375621576; Thu, 03 May 2018 12:27:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525375621; cv=none; d=google.com; s=arc-20160816; b=YDDOtEgwGshl8ANpDzUmO/c+bDF0Ia7sXRiKeE2nIvtKYvsp8bJHJR2gmi/Pc3xUbe TaCSBjnq48pwMcDsjRZ1VeUQRzyer8xfk+AOEkmTjodrjiJbdAD9f7vz4+Uj3nZd7UqO +WR4Kdgb3rqTaboZInb9qaJiy96/opMfLQ0lwglR4YxxFP/3wi6BzQU0MEDbgaFzqh/0 w1fm7dGx9qTA3nh308NZLhMYotePFVlTLe+NKBToq6PO34NS1Nyu7XURkR313gpgsLRC xzh0okd5xzQaZEzXRrIjsjLTvkoDdwLaohiF6sKEezEZMckaio5REuYvV7dNXzgD+kdK L7DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=Sd469h+inLBfLGpz+mJtb9cn+9ApCWo4/5LbLuekwaU=; b=tI6zvnOUNppGD1fsT/J3sRnxp00FXUDqCSH2sfwl2ptV9CQuqedtZ9OFxqeJeMEG8E KO1/uChffdHq2zV1RP2iIQYG5jkdDf8VyMvuttPj752ALbYf808KroW/gzOTmLyN1o4R w8hHIvVlK3sUo7gpKbO5ZIFh1bsI8kCon3mWzraXYFujgmhfpzWG4KGU42esAE8ZR1lZ wcfDrx/G3mpvzKFjKL2d4Y8jco4+lvkod9w17SKbjmPTMoANqizw9MdgIVvUw7Ejd4bp KDUkUXuwaN2VHvo4JMZFG0wgebnpalHqPFADF64xRwQ6H1ex6DUIoXbv1h8xQrZ6er7X 5RAg== 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 q1-v6si13958249plb.549.2018.05.03.12.26.47; Thu, 03 May 2018 12:27:01 -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 S1751838AbeECTZ6 (ORCPT + 99 others); Thu, 3 May 2018 15:25:58 -0400 Received: from mga02.intel.com ([134.134.136.20]:8165 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751271AbeECTYg (ORCPT ); Thu, 3 May 2018 15:24:36 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 May 2018 12:24:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,359,1520924400"; d="scan'208";a="225573197" Received: from theros.lm.intel.com ([10.232.112.164]) by fmsmga005.fm.intel.com with ESMTP; 03 May 2018 12:24:34 -0700 From: Ross Zwisler To: Andrew Morton , linux-kernel@vger.kernel.org, Matthew Wilcox Cc: Ross Zwisler , Christoph Hellwig , Dan Williams , Dave Chinner , Jan Kara , linux-nvdimm@lists.01.org Subject: [PATCH 3/5] radix tree test suite: add item_delete_rcu() Date: Thu, 3 May 2018 13:24:28 -0600 Message-Id: <20180503192430.7582-4-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180503192430.7582-1-ross.zwisler@linux.intel.com> References: <20180503192430.7582-1-ross.zwisler@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently the lifetime of "struct item" entries in the radix tree are not controlled by RCU, but are instead deleted inline as they are removed from the tree. In the following patches we add a test which has threads iterating over items pulled from the tree and verifying them in an rcu_read_lock()/rcu_read_unlock() section. This means that though an item has been removed from the tree it could still be being worked on by other threads until the RCU grace period expires. So, we need to actually free the "struct item" structures at the end of the grace period, just as we do with "struct radix_tree_node" items. Signed-off-by: Ross Zwisler --- tools/testing/radix-tree/test.c | 19 +++++++++++++++++++ tools/testing/radix-tree/test.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/tools/testing/radix-tree/test.c b/tools/testing/radix-tree/test.c index 5978ab1f403d..def6015570b2 100644 --- a/tools/testing/radix-tree/test.c +++ b/tools/testing/radix-tree/test.c @@ -75,6 +75,25 @@ int item_delete(struct radix_tree_root *root, unsigned long index) return 0; } +static void item_free_rcu(struct rcu_head *head) +{ + struct item *item = container_of(head, struct item, rcu_head); + + free(item); +} + +int item_delete_rcu(struct radix_tree_root *root, unsigned long index) +{ + struct item *item = radix_tree_delete(root, index); + + if (item) { + item_sanity(item, index); + call_rcu(&item->rcu_head, item_free_rcu); + return 1; + } + return 0; +} + void item_check_present(struct radix_tree_root *root, unsigned long index) { struct item *item; diff --git a/tools/testing/radix-tree/test.h b/tools/testing/radix-tree/test.h index d9c031dbeb1a..8cf4a7a7f94c 100644 --- a/tools/testing/radix-tree/test.h +++ b/tools/testing/radix-tree/test.h @@ -5,6 +5,7 @@ #include struct item { + struct rcu_head rcu_head; unsigned long index; unsigned int order; }; @@ -15,6 +16,7 @@ int item_insert(struct radix_tree_root *root, unsigned long index); int item_insert_order(struct radix_tree_root *root, unsigned long index, unsigned order); int item_delete(struct radix_tree_root *root, unsigned long index); +int item_delete_rcu(struct radix_tree_root *root, unsigned long index); struct item *item_lookup(struct radix_tree_root *root, unsigned long index); void item_check_present(struct radix_tree_root *root, unsigned long index); -- 2.14.3