Message ID | 3c571436-b678-49bc-938d-892913e0e96e@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | AMD/IOMMU: assorted corrections | expand |
On 03.02.2025 17:25, Jan Beulich wrote: > These were needed by TMEM only, which is long gone. The Linux original > doesn't have such either. This effectively reverts one of the "Other > changes" from 8dc6738dbb3c ("Update radix-tree.[ch] from upstream Linux > to gain RCU awareness"). > > Positive side effect: Two cf_check go away. > > While there also convert xmalloc()+memset() to xzalloc(). (Don't convert > to xvzalloc(), as that would require touching the freeing side, too.) > > Requested-by: Andrew Cooper <andrew.cooper3@citrix.com> > Signed-off-by: Jan Beulich <jbeulich@suse.com> I'm sorry, the question mark after for-4.20 was somehow lost in the submission. Jan
On 03/02/2025 4:25 pm, Jan Beulich wrote: > These were needed by TMEM only, which is long gone. The Linux original > doesn't have such either. This effectively reverts one of the "Other > changes" from 8dc6738dbb3c ("Update radix-tree.[ch] from upstream Linux > to gain RCU awareness"). > > Positive side effect: Two cf_check go away. Not only that, they can now be inlined, although you've merged them directly. > > While there also convert xmalloc()+memset() to xzalloc(). (Don't convert > to xvzalloc(), as that would require touching the freeing side, too.) > > Requested-by: Andrew Cooper <andrew.cooper3@citrix.com> > Signed-off-by: Jan Beulich <jbeulich@suse.com> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com> One formatting point. > --- a/xen/common/radix-tree.c > +++ b/xen/common/radix-tree.c > @@ -66,26 +60,19 @@ static void cf_check _rcu_node_free(stru > xfree(rcu_node); > } > > -static void cf_check rcu_node_free(struct radix_tree_node *node, void *arg) > -{ > - struct rcu_node *rcu_node = container_of(node, struct rcu_node, node); > - call_rcu(&rcu_node->rcu_head, _rcu_node_free); > -} > - > static struct radix_tree_node *radix_tree_node_alloc( > struct radix_tree_root *root) > { > - struct radix_tree_node *ret; > - ret = root->node_alloc(root->node_alloc_free_arg); > - if (ret) > - memset(ret, 0, sizeof(*ret)); > - return ret; > + struct rcu_node *rcu_node = xzalloc(struct rcu_node); > + > + return rcu_node ? &rcu_node->node : NULL; > } > > static void radix_tree_node_free( > struct radix_tree_root *root, struct radix_tree_node *node) > { > - root->node_free(node, root->node_alloc_free_arg); > + struct rcu_node *rcu_node = container_of(node, struct rcu_node, node); Newline here. ~Andrew > + call_rcu(&rcu_node->rcu_head, _rcu_node_free); > } > > /* >
--- a/xen/common/radix-tree.c +++ b/xen/common/radix-tree.c @@ -53,12 +53,6 @@ struct rcu_node { struct rcu_head rcu_head; }; -static struct radix_tree_node *cf_check rcu_node_alloc(void *arg) -{ - struct rcu_node *rcu_node = xmalloc(struct rcu_node); - return rcu_node ? &rcu_node->node : NULL; -} - static void cf_check _rcu_node_free(struct rcu_head *head) { struct rcu_node *rcu_node = @@ -66,26 +60,19 @@ static void cf_check _rcu_node_free(stru xfree(rcu_node); } -static void cf_check rcu_node_free(struct radix_tree_node *node, void *arg) -{ - struct rcu_node *rcu_node = container_of(node, struct rcu_node, node); - call_rcu(&rcu_node->rcu_head, _rcu_node_free); -} - static struct radix_tree_node *radix_tree_node_alloc( struct radix_tree_root *root) { - struct radix_tree_node *ret; - ret = root->node_alloc(root->node_alloc_free_arg); - if (ret) - memset(ret, 0, sizeof(*ret)); - return ret; + struct rcu_node *rcu_node = xzalloc(struct rcu_node); + + return rcu_node ? &rcu_node->node : NULL; } static void radix_tree_node_free( struct radix_tree_root *root, struct radix_tree_node *node) { - root->node_free(node, root->node_alloc_free_arg); + struct rcu_node *rcu_node = container_of(node, struct rcu_node, node); + call_rcu(&rcu_node->rcu_head, _rcu_node_free); } /* @@ -718,19 +705,6 @@ void radix_tree_destroy( void radix_tree_init(struct radix_tree_root *root) { memset(root, 0, sizeof(*root)); - root->node_alloc = rcu_node_alloc; - root->node_free = rcu_node_free; -} - -void radix_tree_set_alloc_callbacks( - struct radix_tree_root *root, - radix_tree_alloc_fn_t *node_alloc, - radix_tree_free_fn_t *node_free, - void *node_alloc_free_arg) -{ - root->node_alloc = node_alloc; - root->node_free = node_free; - root->node_alloc_free_arg = node_alloc_free_arg; } static __init unsigned long __maxindex(unsigned int height) --- a/xen/include/xen/radix-tree.h +++ b/xen/include/xen/radix-tree.h @@ -66,11 +66,6 @@ typedef void radix_tree_free_fn_t(struct struct radix_tree_root { unsigned int height; struct radix_tree_node __rcu *rnode; - - /* Allow to specify custom node alloc/dealloc routines. */ - radix_tree_alloc_fn_t *node_alloc; - radix_tree_free_fn_t *node_free; - void *node_alloc_free_arg; }; /* @@ -78,11 +73,6 @@ struct radix_tree_root { */ void radix_tree_init(struct radix_tree_root *root); -void radix_tree_set_alloc_callbacks( - struct radix_tree_root *root, - radix_tree_alloc_fn_t *node_alloc, - radix_tree_free_fn_t *node_free, - void *node_alloc_free_arg); void radix_tree_destroy( struct radix_tree_root *root,
These were needed by TMEM only, which is long gone. The Linux original doesn't have such either. This effectively reverts one of the "Other changes" from 8dc6738dbb3c ("Update radix-tree.[ch] from upstream Linux to gain RCU awareness"). Positive side effect: Two cf_check go away. While there also convert xmalloc()+memset() to xzalloc(). (Don't convert to xvzalloc(), as that would require touching the freeing side, too.) Requested-by: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Jan Beulich <jbeulich@suse.com> --- v2: New.