Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp411026lqp; Sun, 9 Jun 2024 01:38:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBijrmj25GWON4zfZhXc62hbuU4OzUeZRPc5tfhqLl3aacRPI0m+xLzNV5jSgQYSLKW6E846I932rJ8kNE2c9vZCIzg+SwFXhH7ew5rA== X-Google-Smtp-Source: AGHT+IEsXQkoa+RLGXdn5hzV67OzpM3af8AZ44K0Rt2tbBmLeEBhike/8HNYIkY21+rkp8Gd8YtP X-Received: by 2002:a50:aa85:0:b0:57a:76c1:b14e with SMTP id 4fb4d7f45d1cf-57c506c1b44mr4179128a12.0.1717922294766; Sun, 09 Jun 2024 01:38:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717922294; cv=pass; d=google.com; s=arc-20160816; b=XX9kUSbkhe25+zK34Q3JBpapJpGX6ddMkZ9hwiUctsv1pIGYlUXcS8B+x4YgQMVjq7 sZfXXzs7aoZkS3Vun24Qw3xCQymGnonJOEVbzvqX86RxqLH+oivaGpmj0ZeqLLgvUvwg iXYS2mpH9dkDnDIl5bobPcbaI06KLi25Pa6Dm0GTut0OAuY5fXYoU2rp9aP4ULq7OZgH bJ+QDD4yx4M9SVli1VJipt3KNPPVtx5Ad9xDj5y4HAb5+gkhO6u68h+TZNwq/5J3xkYN SDYTYwBpt9Rm+j9f4DHqkw4LmlRfwk4XU452MCLanuu+qD0Tq/2VJlXDvot5bTi+844Q IJpA== 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=ygyQ5hnv+3lKS8dtNJ/yFc43Rpbcbrp+lT/TZAkOJVM=; fh=nTMsnj1/hSUPGm21BA0/Ba6yl+n8bb8GsIARMcksRbg=; b=WaV+SNldXAqDP6KVIe9Jd7sRolfU/U57YSxIo+ytMp75Tueb6puJycX0FYWSYZX4DR GdO/acAFgDlZepQnmooJbDAT7M7Wl6ro77Jf5gYQ/JbbBGitvoTrwcT6EAHfiM4R2be9 lVIMIYsQfMgdk7ksCaciP9dEsXlvrvQpK9dbepBzgR6NgNBPIs5pCS1Rlhs0DhCp+ex0 6a5Kc7cQBrDpEIE6PDG6sPdPT2K4BABZrr85BWlpNcSurcFgW2/rgB0/pHwioPh2Szxl oKOBObJYEyy5RgxDKsnAyqT6lt+uyljEIYT867X3H5OD2lfw1l9ObA0HpY6ScNQ4qhVb sz+g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=jVC72JU7; 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-207292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207292-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57aae22892bsi3653753a12.394.2024.06.09.01.38.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:38:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=jVC72JU7; 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-207292-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207292-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 57F3B1F226E7 for ; Sun, 9 Jun 2024 08:32:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E82D57CA6; Sun, 9 Jun 2024 08:28:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="jVC72JU7" 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 757DC4D8BF; Sun, 9 Jun 2024 08:28:11 +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=1717921693; cv=none; b=qMdcomPV44e4S5nqEwEko0ymf9wOFXSyBV47zUwJ+mr12zgf8p2hJq5ndxTVhAShoN6T/Xf5bz4vGn2SsumUX5y93nxLFVQ4jV6jp071+qMsJmaEWrtJgLHDXGwfqbZIfSa2JdgvznNLpzQyLE6hEe3aIHEeov4dzHb+LcWLU3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921693; c=relaxed/simple; bh=mQ3EDAVm4CCUHrkqlx/DX6sXVOIvE+vo6Q6lBCjqo4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nG3xiyM5cvaMKuOd427maNAbAtoHljgfHcsfXxt2bBUqbhtcDX0Yjo27u2tq1kY6+bIW7ZFThzmtJxtVvsZgPgOCplVaY7vEli3osjzp74rK08LwxdbF/yk+kZ3EWcUdsUuPIPpdmlgW94rDK4gi5vEbjyElSFIt1I0ZTyhOM+k= 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=jVC72JU7; 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=ygyQ5hnv+3lKS8dtNJ/yFc43Rpbcbrp+lT/TZAkOJVM=; b=jVC72JU7hF53dnZUuUMgmhliEsXK3xdP852+pxN3iJY+4py8rdh5w9j1 KjpVieoTCrs6zpAhqC9mmNZlBo4etvXQdfHTLJsNLO8S6+3q1tZkBXm7f R17cewoA53OG2cKOeI3V1wnLEUz5YJbOCrKDi1iFyKuochepa6zjIo4Vo M=; 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="169696907" 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: Tejun Heo Cc: kernel-janitors@vger.kernel.org, Lai Jiangshan , linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 12/14] workqueue: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:24 +0200 Message-Id: <20240609082726.32742-13-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 --- kernel/workqueue.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 3fbaecfc88c2..2ec195dcc2bb 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5038,12 +5038,6 @@ static struct worker_pool *get_unbound_pool(const struct workqueue_attrs *attrs) return NULL; } -static void rcu_free_pwq(struct rcu_head *rcu) -{ - kmem_cache_free(pwq_cache, - container_of(rcu, struct pool_workqueue, rcu)); -} - /* * Scheduled on pwq_release_worker by put_pwq() when an unbound pwq hits zero * refcnt and needs to be destroyed. @@ -5089,7 +5083,7 @@ static void pwq_release_workfn(struct kthread_work *work) raw_spin_unlock_irq(&nna->lock); } - call_rcu(&pwq->rcu, rcu_free_pwq); + kfree_rcu(pwq, rcu); /* * If we're the last pwq going away, @wq is already dead and no one