Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp411258lqp; Sun, 9 Jun 2024 01:39:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUw6cCVQI4MaJy+t6u9bxH7T4poHCBtxb+6/xkFqPlghAv3FFtGjF6gLXTNZSi7fkJlJOlYm2/hxTm0Dl8tZh/WhqUTDbhz1NeqbdT13g== X-Google-Smtp-Source: AGHT+IHwAqMM4IOQkl1wIiPUOYRnr1X2mNksTQBZ3Mih4YFjaijUjxCZag9gqOVvqcl6P8ACceax X-Received: by 2002:a17:902:e5d1:b0:1f6:a624:b6b1 with SMTP id d9443c01a7336-1f6d02e6d2bmr75256175ad.27.1717922349309; Sun, 09 Jun 2024 01:39:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717922349; cv=pass; d=google.com; s=arc-20160816; b=heh25cCvSEGsl6K5FE13twFR/DKH7IOgmheEz0JbfxlHPg3MgvmAs4ryA38Lun8Lgr 0+yr8XdMOwDFFeLpMJrNohEeyJzyAD5gqrpPUZanNU065vavYlT8JNw7qDnfy39JphK7 rTRBIA62mHD/0+nvSXTwQyQTpU1Tmr15FCNfrSWbXI80aW9L5Ar9Srk0pKodkDHDOcqJ JITUHV9C8qAvkLd4xWhx7bd9rS+vZfiy51diCBgGh7oAofbQ+u/ib4wCPKDyAhH0WfB+ KPWHWs4FEHCmIY/HY9OEF0YLZeGmk0aTjNLmkLkzWluWHDpmfifyUq2lcajG3OoavBv9 Nu3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X9IqNiprrXZb6MHGk7aZq3SWcPVK5fPzmf82pe9GCT8=; fh=VZJO9ZpWshtpd2VxANzfQRCufu4E2mkudzgqfTxLWO4=; b=M4QPzFpeVDaDqKmP0bQKzGbpuMY+scgy/eEL9Dk5CpeRf07l64/tub9wu6Q55VUDfN lqQuIxZYY5iYd5itYfXSUFDIAmvpGswtRu3K8hxij0cMBQ0izH3QlMRafnqgf3zJuIxs zeVUCvSnHDOs7atgym50sHyLdSttbZXiAAPubGrou//MbhIBjIeDfO/GfpqSn6sgN1Hk d+29hqQWTD69yLQxgiGWR/z8Xk1zj81RbJHu5Lr2Fh9plgX31pYwThdVu7y9Tr2qY4tm 4vKkHx7Yfe3/m/CgW09TRFMveS7Hu40YU2FWH4rt4OGB9/M50PrreyuamKNcjihEB9rE 2FwQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="piJcIS//"; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-207291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6bd7f432csi59486105ad.494.2024.06.09.01.39.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="piJcIS//"; arc=pass (i=1 spf=pass spfdomain=inria.fr dkim=pass dkdomain=inria.fr dmarc=pass fromdomain=inria.fr); spf=pass (google.com: domain of linux-kernel+bounces-207291-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207291-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8483AB224D8 for ; Sun, 9 Jun 2024 08:32:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6742043AC4; Sun, 9 Jun 2024 08:28:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="piJcIS//" Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BAAA482FF; Sun, 9 Jun 2024 08:28:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.83 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; cv=none; b=N8ifeB0voo3JHccnLWotuGn6u28WDVMhv8LEVez8TN6TKm/ZxZAmxKNq6qqVN6ytlrRVSVk0YbG8AcKXBGycUvQRCWbfqJ3n6mcDuqAoRKKLGWAfJTSw6l7ilYGKGnZM8chnUfwCxE5Zk/WwOs4uSHiBgI5/y6nyJi+MkxI4PnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; c=relaxed/simple; bh=6GIjz5N6hc/+rjpb+kIsuZe52mzAkiPpkv+A8YoO+MI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iTNc/NTORkIq/AT6N+klMd4gTdIdTs3p0j/DIynbTRRoUFreid/nenoIMdVGY2/G+/MtzutFN5qCyuwiEPCzsC/2D5WC3zzCY4Pm1iY0oSqr06YuhQIY75T7L/bG3wdBG3XYaaH24doZ9UyUAGD8xZNvFAF8rqV0ZwCMx4dYH+Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr; spf=pass smtp.mailfrom=inria.fr; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b=piJcIS//; arc=none smtp.client-ip=192.134.164.83 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inria.fr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X9IqNiprrXZb6MHGk7aZq3SWcPVK5fPzmf82pe9GCT8=; b=piJcIS//x58NzsIAPazGIB+abmqDcnvkuqGskL8US1zhYqDV8rt3qBPc h6CIeifF90XNr/yhhLY/VPzaE2/VJlIk3jEopBvzmI7jbBXkvoD1+yEhu rz7e3w+JXN9wDDW+odxmdOb54ZSBeILJrZZFdlEEnR1kl0UtOmhnkrj4t k=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.08,225,1712613600"; d="scan'208";a="169696905" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2024 10:27:49 +0200 From: Julia Lawall To: Oliver Hartkopp Cc: kernel-janitors@vger.kernel.org, Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 10/14] can: gw: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:22 +0200 Message-Id: <20240609082726.32742-11-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240609082726.32742-1-Julia.Lawall@inria.fr> References: <20240609082726.32742-1-Julia.Lawall@inria.fr> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since SLOB was removed, it is not necessary to use call_rcu when the callback only performs kmem_cache_free. Use kfree_rcu() directly. The changes were done using the following Coccinelle semantic patch. This semantic patch is designed to ignore cases where the callback function is used in another way. // @r@ expression e; local idexpression e2; identifier cb,f; position p; @@ ( call_rcu(...,e2) | call_rcu(&e->f,cb@p) ) @r1@ type T; identifier x,r.cb; @@ cb(...) { ( kmem_cache_free(...); | T x = ...; kmem_cache_free(...,x); | T x; x = ...; kmem_cache_free(...,x); ) } @s depends on r1@ position p != r.p; identifier r.cb; @@ cb@p @script:ocaml@ cb << r.cb; p << s.p; @@ Printf.eprintf "Other use of %s at %s:%d\n" cb (List.hd p).file (List.hd p).line @depends on r1 && !s@ expression e; identifier r.cb,f; position r.p; @@ - call_rcu(&e->f,cb@p) + kfree_rcu(e,f) @r1a depends on !s@ type T; identifier x,r.cb; @@ - cb(...) { ( - kmem_cache_free(...); | - T x = ...; - kmem_cache_free(...,x); | - T x; - x = ...; - kmem_cache_free(...,x); ) - } // Signed-off-by: Julia Lawall Reviewed-by: Paul E. McKenney Reviewed-by: Vlastimil Babka --- net/can/gw.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/net/can/gw.c b/net/can/gw.c index 37528826935e..ffb9870e2d01 100644 --- a/net/can/gw.c +++ b/net/can/gw.c @@ -577,13 +577,6 @@ static inline void cgw_unregister_filter(struct net *net, struct cgw_job *gwj) gwj->ccgw.filter.can_mask, can_can_gw_rcv, gwj); } -static void cgw_job_free_rcu(struct rcu_head *rcu_head) -{ - struct cgw_job *gwj = container_of(rcu_head, struct cgw_job, rcu); - - kmem_cache_free(cgw_cache, gwj); -} - static int cgw_notifier(struct notifier_block *nb, unsigned long msg, void *ptr) { @@ -603,7 +596,7 @@ static int cgw_notifier(struct notifier_block *nb, if (gwj->src.dev == dev || gwj->dst.dev == dev) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } } @@ -1168,7 +1161,7 @@ static void cgw_remove_all_jobs(struct net *net) hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) { hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); } } @@ -1236,7 +1229,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, hlist_del(&gwj->list); cgw_unregister_filter(net, gwj); - call_rcu(&gwj->rcu, cgw_job_free_rcu); + kfree_rcu(gwj, rcu); err = 0; break; }