Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp411236lqp; Sun, 9 Jun 2024 01:39:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaFaa2D89uDmgLIReCmagQerp/RLoDGC7F+nadNpm1pKtKCdSU1yu1wZWE6zkgE+5WyU/Hv/+Q+X5P8L30+2UzaQR4WWCLRv0sg6XSQw== X-Google-Smtp-Source: AGHT+IFwJcedDs4/VaumlpuOIAsyIVR8hqcXo7qhSyOhVFuSKMk5Ie6+Pn2Uc7Pwr6dMw+TqNWg3 X-Received: by 2002:a05:6358:718b:b0:19f:449f:c65 with SMTP id e5c5f4694b2df-19f449f1180mr307388755d.2.1717922344128; Sun, 09 Jun 2024 01:39:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717922344; cv=pass; d=google.com; s=arc-20160816; b=E5kXdDw4dw9Gv2d/2VzVSAxZ8OpVE34LYgDDC5bgYVqy8jyXsFJWg6w9l+lxdB0zMf Ck9CXP2N3gaFFvcR53HzyKkDii0oSB5a9GoswsvIXVKrbacL9FzCp8IL+XKJYf0yOcEL Jlj2x96PtKO8CL6P8BLE9ZqxljmwppcAFmIIvBej5YCpyLlkuXz1fZIEid6PNruOEjl/ FVDYgr2xPpvfhtW2Uh7qzHeH41yTqqTbBqvdDt2GRWCv+dBTCwNR6vy5AKuuds/x0rEb z9GhjlCKV5LWC2VENWBx9mN+YQfLJR/xmsfq1Ppueiuln10Cl9m/rwSfC/xgQbkHXJyb B6tg== 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=a78ss3v9OAJO+CKMzQy2rYpVoY9Q0ZyloAHjx8C4Uac=; fh=JkJaoNSqQgVksD0SC/mHgUabCtB0BqIyQqm6LzrsUfM=; b=Y7hkIBmP+q2TpnHgzxNI9pE2J+vyCTmWICEcEz1wjLZI3tptvolb9sXqzpMBoHhwow RPLrsKPU5RWAvzDcAv4rTGOHvP6KhOOPXmaa2I3kwp4SjTQtJ/v386mNyUmIW86wJYTe xryEsQJEHLa5XxwxInDDxg55ZMoRlw4zQ5sHjzLs2RHk5pJrJomsMnuPmZ2oqZVl0Iom 786vqISF9jbZ0iOqnlX/f3amDzBoY4bvgv5/KW4BKxoFsfi4K4Hrhfue3QyUO3NLXAf8 dY4D/eCz38fOCzRAILWRMEZ+M/APuvf6JLe5wq5i5Y9KkrBy9yW3PEw+PadM0h+OPnyo pH2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=bb3XFAHK; 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-207290-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207290-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-1f6bd7d2968si28551545ad.247.2024.06.09.01.39.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:39:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207290-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=bb3XFAHK; 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-207290-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207290-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 B3408B22466 for ; Sun, 9 Jun 2024 08:32:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3EE4254FAD; 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="bb3XFAHK" 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 6407A4AEEF; 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=KgHh4JOULa6nN9zC4PEpQYlhrxkmDi4Vod9pnQmf31b8kxBlO39ebGJgL0hoD0R1LzFzbb+xNHVuH9BgnD6NVoeQxte3YRb4dLzed7yH5izbh464wMo1RIfi1Wea4d5uFDMvBPCbewHzfZZ8T27rA1274RMM2V87aB/JMFU5nbQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921692; c=relaxed/simple; bh=GdljLaLr8e2ac9pRTDj/L0VN9xs0OlSFKWDz1A6N+NQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lBckZwFHtb14FUDfTizyr9FHmYco6F0MRtfEoVeOMx4gaMlZrvQYEW3GaOzDC9Mxl0MzKD6R1zOI3Bmtl82lpFhjr+2BT4/xN+ql2p/z1MrC3kHK+tNrbzOSAzt2t/uYDXB/ME67Wk04WpXfSLnrVvKIjl6UDyWFMrR71ByuPMY= 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=bb3XFAHK; 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=a78ss3v9OAJO+CKMzQy2rYpVoY9Q0ZyloAHjx8C4Uac=; b=bb3XFAHK0DaOwijmTFrc0riw8PXL4V4YRFwXnaE8buCbFWlGyHgIACL3 JEQnoTZ16ALbyqH62TEtlLkcP49cjqDZJIt/tbmXgoVOdNucLX/1BEtyU CxHi4/QSlmFcsJl+Ke5d6RuugzOyOFyeAWFiSeVJMhZFKbGTMkFPaiQ5L I=; 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="169696906" 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: Anna-Maria Behnsen Cc: kernel-janitors@vger.kernel.org, Frederic Weisbecker , Thomas Gleixner , linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 11/14] posix-timers: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:23 +0200 Message-Id: <20240609082726.32742-12-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/time/posix-timers.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index b924f0f096fa..bad5db979664 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -412,18 +412,11 @@ static struct k_itimer * alloc_posix_timer(void) return tmr; } -static void k_itimer_rcu_free(struct rcu_head *head) -{ - struct k_itimer *tmr = container_of(head, struct k_itimer, rcu); - - kmem_cache_free(posix_timers_cache, tmr); -} - static void posix_timer_free(struct k_itimer *tmr) { put_pid(tmr->it_pid); sigqueue_free(tmr->sigq); - call_rcu(&tmr->rcu, k_itimer_rcu_free); + kfree_rcu(tmr, rcu); } static void posix_timer_unhash_and_free(struct k_itimer *tmr)