From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F365C25B78 for ; Tue, 28 May 2024 12:08:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1BC46B0099; Tue, 28 May 2024 08:08:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA5256B009A; Tue, 28 May 2024 08:08:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A1E7A6B009B; Tue, 28 May 2024 08:08:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8081E6B0099 for ; Tue, 28 May 2024 08:08:25 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id CFBAF1404CB for ; Tue, 28 May 2024 12:08:24 +0000 (UTC) X-FDA: 82167682128.01.EF085CF Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by imf09.hostedemail.com (Postfix) with ESMTP id 8124914000C for ; Tue, 28 May 2024 12:08:22 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=inria.fr header.s=dc header.b="dmTAZ/Lj"; dmarc=pass (policy=none) header.from=inria.fr; spf=pass (imf09.hostedemail.com: domain of julia.lawall@inria.fr designates 192.134.164.104 as permitted sender) smtp.mailfrom=julia.lawall@inria.fr ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1716898103; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WkYcaK24B1G4SYg3BmIR6wP1ac8fQ0u2Z8GojBBIG4I=; b=lysQ+a88ETB6LBsKwrKiZQT2ZGbGaaxwOAMZO0ZUZvkjDUZfYl7pkdvafSArKfYNliUTT2 Zii5Jo9zSj7FSmc559ffDmP9cnhLFLXs9yqB5QDVJ8MUYovAiGT6sc00Qzgrv/jGTo2RzG MIplnD90g7pPXOxBf/J333SVfE6NCIw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1716898103; a=rsa-sha256; cv=none; b=ks0+j9JAevSinGpab58rb3csIyb/AbCk/rbprvhsnvFx2Qq3qxGVnOAYhI+tmmDAeKt/eF pPYwMRrP6LPgdAYUlAXSL55fpFg+vJgp6+T58QetLXEx+++CvOQRwMPkp7AilEdpGwKxfh yuEBWPiRGoK2DaqLwnugbI0PveORBtQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=inria.fr header.s=dc header.b="dmTAZ/Lj"; dmarc=pass (policy=none) header.from=inria.fr; spf=pass (imf09.hostedemail.com: domain of julia.lawall@inria.fr designates 192.134.164.104 as permitted sender) smtp.mailfrom=julia.lawall@inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=WkYcaK24B1G4SYg3BmIR6wP1ac8fQ0u2Z8GojBBIG4I=; b=dmTAZ/Lj0NlBgW9JAh4SJVk5o43DGgyo/45D0OHEJvqf6Pl5cpdDjKaY uHRjcjfY241XTLLHDpSJGenY/HKkMRzPF3rhoVLw4zygvGdxbtBQ4Khre byBCfBlvfPP1cEKW5m3GkTH4i+iY0+jfoZ+TuWBRSEIg5v0VMtmB0W7Kx 8=; X-IronPort-AV: E=Sophos;i="6.08,195,1712613600"; d="scan'208";a="88165127" Received: from dt-lawall.paris.inria.fr ([128.93.67.65]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 14:08:21 +0200 Date: Tue, 28 May 2024 14:08:20 +0200 (CEST) From: Julia Lawall To: Uladzislau Rezki cc: "Paul E. McKenney" , Vlastimil Babka , "linux-mm@kvack.org" , RCU , cocci@inria.fr Subject: Re: [cocci] patch idea: convert trivial call_rcu users to kfree_rcu In-Reply-To: Message-ID: <2dd5bafb-ceb1-238d-2f51-83ebf135b73@inria.fr> References: <68b85796-c674-4691-936a-2051849f4692@suse.cz> <6b7e3ed9-d974-cb3b-6839-a6b7cf5f5a36@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Stat-Signature: 1s4joez8fi7x37oye7cgyzgw9qqpufmi X-Rspamd-Queue-Id: 8124914000C X-Rspam-User: X-Rspamd-Server: rspam01 X-HE-Tag: 1716898102-877473 X-HE-Meta: U2FsdGVkX1/Qg/47l1DXjLOn9ZOCb2mC7raB+VH1YAOyHlrqMaEaK8W+wq+GLOwOsXDedQdNyT4jdu84JVZtPG5iq+pCBTh0NRA1errmTTK8P93QqJZjUQnZIAG4qETiy078KNGUM+RFvhuMzyNKdHI8MCJ8FGamzNs2Vvy7E8X8CBEM/76q0QCYBdldOBWN/vF/pEYFxNE6UE6LnlBWHVJzCk7qLHw10hOMlxC20jmA4uVEeCQ+zPOI6vHY7uaJaoE/ekrstrS5FYWZgzBSqVq9aBRI5nIOcL5r3BRqvpZI+OaF/b0IY0kk6/bjDncivlHQpn/nCGeuTBXMOzY/tWZYbqeaKJy1xJx/NoG4a7vL4iDRS0NBa7QrVaCm7yz8dHtLuWgeaCPPAy95rbths1Z1ES0lsrnNXaT2MKgcL4M+eiMewZU8EudT7EwJju4oUkSBHm0TcadvvxGiF0y5z4ahiM+DuqsWIlfZitIvSiMSj0LrIUJTeHOzP5X0lM00kHavZAZRCY52QOZEUQGEktPcG9VNtVEis2NKLnQKp4ek92wju57kZRRgNHu6E5fEtoYfJAhPr++Nl2MrLz1rtlfk34YLhMHQVI3rp6e1miWIXpTD/tGC6DmbDEwaHRnLKothdOTtwUEXKF0aBH5sfkKMLMr0molQZIjHZSH7gWfkbwJ1mEmin37HrXgQErjgTh4lBCEmpbY0XzkZidqT//OvTGebhporFlWpHAoZg29gffeDtQatwP9py71N1S2Q39dUWi+vFLc/yWZsAUAfji7+GXLnGSKAH4UCOBwUQ7K5398LhoZ8ibSBte/KiPVGneiEnYwi3joYC0FkPyVIboNbVhlWPrCmrz6PBWolaNskYIjzp93eRQ9IqQjR1QrpsSvCIb0sLx4xeeheedQWglGZCOQyN8X/S5xVxL+UJAXfjauEcj7KGr5nL+ncFWolmoA2QgfidaKsLLvC+3A k9u+GbFY yqv+7CwkFNPk0nkh3S660N7cqw9Xy1kUXBfbGy6LP3jQ1sHT447ROkULChFXaC0dXbrO8yRkFg1zkjCgI/Pgiave28bSkxxzr47mefwDT6ZFnX925cbFCNmwzyGD+h67yhVAcsvCquPJ5cnE6oMzbmNJuecq/XBVr3dlIr1x1TIWKJdFGbgSUvF0a2kF7jF8Z0iFpFQcXOLAGNk1AjAVFoqyf6Yk2tYPwvno5 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, 28 May 2024, Uladzislau Rezki wrote: > Hello. > > > > > > > On Mon, 27 May 2024, Paul E. McKenney wrote: > > > > > On Mon, May 27, 2024 at 10:13:40AM +0200, Julia Lawall wrote: > > > > > > > > > > > > On Mon, 27 May 2024, Vlastimil Babka wrote: > > > > > > > > > Hi, > > > > > > > > > > one bit from LSF/MM discussions is that there might be call_rcu users with a > > > > > callback that only does a kmem_cache_free() to a specific cache. Since SLOB > > > > > was removed, it's always ok to use kfree() and thus also kfree_rcu() on > > > > > allocations from kmem_cache_alloc() in addition to kmalloc(). Thus, such > > > > > call_rcu() users might be simplified to kfree_rcu(). I found some cases > > > > > semi-manually, but I'd expect coccinelle could help here so if anyone wants > > > > > to take this task, feel free to. > > > > > > > > Thanks for the suggestion! I will try to look into it. > > > > > > Thank you both! > > > > I found the following functions. Do you want some other information, such > > as where they are called from? > > > > Ignore the -s at the beginning of some lines. Those are for emphasis. not > > to suggest to remove the code. > > > > I checked that the functions are only used in calls to call_rcu. > > > > Without more effort, Coccinelle only looks for functions defined in the > > same file. Here are the functions that are passed to call_rcu where the > > function is not defined in the same file: > > > > need definition for audit_free_rule_rcu > > need definition for __i915_gem_free_object_rcu > > need definition for io_eventfd_ops > > need definition for ip_vs_dest_dst_rcu_free > > need definition for __put_task_struct_rcu_cb > > need definition for radix_tree_node_rcu_free > > > > They all do something more, although radix_tree_node_rcu_free doesn't do > > much more (some memsets). > > > > julia > > > > diff -u -p /home/jll/linux/drivers/net/wireguard/allowedips.c /tmp/nothing/drivers/net/wireguard/allowedips.c > > --- /home/jll/linux/drivers/net/wireguard/allowedips.c > > +++ /tmp/nothing/drivers/net/wireguard/allowedips.c > > @@ -50,7 +50,6 @@ static void push_rcu(struct allowedips_n > > > > static void node_free_rcu(struct rcu_head *rcu) > > { > > - kmem_cache_free(node_cache, container_of(rcu, struct allowedips_node, rcu)); > > } > > > > static void root_free_rcu(struct rcu_head *rcu) > > diff -u -p /home/jll/linux/fs/ecryptfs/dentry.c /tmp/nothing/fs/ecryptfs/dentry.c > > --- /home/jll/linux/fs/ecryptfs/dentry.c > > +++ /tmp/nothing/fs/ecryptfs/dentry.c > > @@ -53,8 +53,6 @@ struct kmem_cache *ecryptfs_dentry_info_ > > > > static void ecryptfs_dentry_free_rcu(struct rcu_head *head) > > { > > - kmem_cache_free(ecryptfs_dentry_info_cache, > > - container_of(head, struct ecryptfs_dentry_info, rcu)); > > } > > > > /** > > diff -u -p /home/jll/linux/kernel/fork.c /tmp/nothing/kernel/fork.c > > --- /home/jll/linux/kernel/fork.c > > +++ /tmp/nothing/kernel/fork.c > > @@ -378,7 +378,6 @@ static struct kmem_cache *thread_stack_c > > > > static void thread_stack_free_rcu(struct rcu_head *rh) > > { > > - kmem_cache_free(thread_stack_cache, rh); > > } > > > > static void thread_stack_delayed_free(struct task_struct *tsk) > > diff -u -p /home/jll/linux/kernel/workqueue.c /tmp/nothing/kernel/workqueue.c > > --- /home/jll/linux/kernel/workqueue.c > > +++ /tmp/nothing/kernel/workqueue.c > > @@ -5024,8 +5024,6 @@ fail: > > > > static void rcu_free_pwq(struct rcu_head *rcu) > > { > > - kmem_cache_free(pwq_cache, > > - container_of(rcu, struct pool_workqueue, rcu)); > > } > > > > /* > > diff -u -p /home/jll/linux/net/ipv4/inetpeer.c /tmp/nothing/net/ipv4/inetpeer.c > > --- /home/jll/linux/net/ipv4/inetpeer.c > > +++ /tmp/nothing/net/ipv4/inetpeer.c > > @@ -130,7 +130,6 @@ static struct inet_peer *lookup(const st > > > > static void inetpeer_free_rcu(struct rcu_head *head) > > { > > - kmem_cache_free(peer_cachep, container_of(head, struct inet_peer, rcu)); > > } > > > > /* perform garbage collect on all items stacked during a lookup */ > > diff -u -p /home/jll/linux/net/ipv6/xfrm6_tunnel.c /tmp/nothing/net/ipv6/xfrm6_tunnel.c > > --- /home/jll/linux/net/ipv6/xfrm6_tunnel.c > > +++ /tmp/nothing/net/ipv6/xfrm6_tunnel.c > > @@ -180,8 +180,6 @@ EXPORT_SYMBOL(xfrm6_tunnel_alloc_spi); > > > > static void x6spi_destroy_rcu(struct rcu_head *head) > > { > > - kmem_cache_free(xfrm6_tunnel_spi_kmem, > > - container_of(head, struct xfrm6_tunnel_spi, rcu_head)); > > } > > > > static void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr) > > diff -u -p /home/jll/linux/security/security.c /tmp/nothing/security/security.c > > --- /home/jll/linux/security/security.c > > +++ /tmp/nothing/security/security.c > > @@ -1599,7 +1599,6 @@ static void inode_free_by_rcu(struct rcu > > /* > > * The rcu head is at the start of the inode blob > > */ > > - kmem_cache_free(lsm_inode_cache, head); > > } > > > > /** > > > See below some extra functions which can be eliminated. How i found them: > > find ./ -name "*.c" -o -name "*.h" | xargs grep -rn call_rcu -B 10 | grep kmem_cache_free > > > static void nfsd4_free_file_rcu(struct rcu_head *rcu); Thanks. I tried to find this kind of issue, but it turned up nothing. There must be some mistake, and I will try again. julia > static void lima_fence_release(struct dma_fence *fence); > void intel_context_free(struct intel_context *ce); > static void ipmr_cache_free(struct mfc_cache *c); > static inline void alias_free_mem_rcu(struct fib_alias *fa); > dsthash_free(struct xt_hashlimit_htable *ht, struct dsthash_ent *ent); > void nf_ct_expect_put(struct nf_conntrack_expect *exp); > static void node_free(struct net *net, struct fib6_node *fn); > static inline void ip6mr_cache_free(struct mfc6_cache *c); > static void posix_timer_free(struct k_itimer *tmr); > static void thread_stack_delayed_free(struct task_struct *tsk); > > > Those are can be replaced by directly calling of kfree_rcu() instead of call_rcu(). > > -- > Uladzislau Rezki >