Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp408366lqp; Sun, 9 Jun 2024 01:28:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWSsJR6/1oaIhf86L6+qQDFQZR3diDLOVzNywd1qWFeqWUtkw150p5sjS6Gs0c5B6L5gb7EqHueEaws/JQhGt7eMp42EiEzIQ4vIIpN2w== X-Google-Smtp-Source: AGHT+IGWhZLWNhul8TWwJz1K2RybwJNGUMktQXAzkTyATYqAmHkQsx4x/Wwp5bXG0c5jutuwhfnf X-Received: by 2002:a17:907:551:b0:a6e:ffef:b6af with SMTP id a640c23a62f3a-a6effefbbdbmr174620966b.41.1717921737538; Sun, 09 Jun 2024 01:28:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717921737; cv=pass; d=google.com; s=arc-20160816; b=OSw6f42/MmkgLReLX8xYmYEIVXbqwiZp52I5q+4KL3V82o3cY5EDtrKMkztiFXH4aX vlDXYR96jZh9nnyIkc472NVRCI1DwdhlGDrG/QMmvQpQRn9ZyH2VsUxx7XQjdeWeu5vT kMbWmIZ6ZLWAPr1ikkG8WsAEKefqn/GbUEvKOlswnAUVQhB2g+3cz5k0l5NnVYsOEFZW xZZ3o+fl6K17SFXQnkKOZLtLLxL+g4KrPTdKTbIl8kjgGEfQg38BDFK/9W6Me15uockR BR6cJfWIQKRsBPd8M4LrrhO6ig7fUGishnJjZcGog4Yp9HxwUAYv7UdnECHIeGsRrGwD XWvw== 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=zD7ynr/1tlkX1uaDOLGJoOQ33RKpDATGoutWutKpPm8=; fh=YGdAL6ySbLTrmaYhFrR4eaLOjak3lMcM03yxvMrvCr8=; b=mOJHEDZOYPDjWK/QtcxEDLzk9vuJebKdK6L26WcB64zvG17lFWbW0egI2FCB0eFHxV 5NUmL6/06qj+AhzLBUVk2CfMkmBpIgIDmy1sHdVF9TfdTNVcjkOxwM78OXCblCUT7611 MF9d5LDNqe4CjP/do3e8+HB2YcR0WZANXytKlmYjJ+b78n6xG9fsFodALsTig/YQZmpH e4pcQhJSdr/stUhF/h7Pf0EItOTr/UZoi4ItcFCcrXHMGl/6qKju3JslgFaup4RT/gSr qA4KXHJqctErmL98S5afdKRdyGdyCsnTfBPNGhX+pVIRd6CKBCXLzkUjjlk3zdCQuSF4 PGXA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=DagXZfUz; 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-207281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207281-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f12e3b7basi64885066b.406.2024.06.09.01.28.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:28:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=DagXZfUz; 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-207281-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207281-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 EC64B1F20FDA for ; Sun, 9 Jun 2024 08:28:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08BAF26AC7; Sun, 9 Jun 2024 08:28:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="DagXZfUz" 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 904511CF9B; Sun, 9 Jun 2024 08:28:00 +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=1717921683; cv=none; b=PVd8zT8xyyrd43B/s+f4HCaBW/obix7/covmfV1DZG03bwnhVUGt89jfQn5d5Fs3mzFhqtSy0WPBr5sNLk7vAypTE2zLR5rpU60+GHKTiE+KMN5iHy6j9+APQwozXI0IAMYQ5vAmNEVkDlhJeJ1SDykIQc8CQ/k4iXv6HT/2reY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921683; c=relaxed/simple; bh=DIOSKqTpToIMwFVNjlUEe3yI6S/nMaYNXYjDOcuM4EQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eQ2uixf4yt9FP3JWMU65dxLXK7JqNz4PUfqY+Ywy4MCh8JjJtZ1JMlbvrnLbz3UHFj/0i3Gz8OSpkFdYnC3Qq7sE5f8E5/lrVyL9nHHf4gitEHoJV3WVoTwDd8K1YOvgb1Mkse/1ChvI/pZszCNJaJD91A4HJEHyVZYhpDgx6fo= 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=DagXZfUz; 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=zD7ynr/1tlkX1uaDOLGJoOQ33RKpDATGoutWutKpPm8=; b=DagXZfUzdJWxwoYzmzmcEEdumUzJIa5J0CQYYbILkDG/vxnjNLrQtADH Zr3+IGWHHTGjtQGCVa5ooF0J9nev/GChyQeMc6SmkGK2HoL3KVzdspOzO VEuZqOgM9n6vbqQ+I7kkL+HhJhbcnrmDykDjT6SypihrjH36fewBvsXo3 Q=; 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="169696896" 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:48 +0200 From: Julia Lawall To: "Jason A. Donenfeld" Cc: kernel-janitors@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , wireguard@lists.zx2c4.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 01/14] wireguard: allowedips: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:13 +0200 Message-Id: <20240609082726.32742-2-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 --- drivers/net/wireguard/allowedips.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireguard/allowedips.c b/drivers/net/wireguard/allowedips.c index 0ba714ca5185..e4e1638fce1b 100644 --- a/drivers/net/wireguard/allowedips.c +++ b/drivers/net/wireguard/allowedips.c @@ -48,11 +48,6 @@ static void push_rcu(struct allowedips_node **stack, } } -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) { struct allowedips_node *node, *stack[MAX_ALLOWEDIPS_DEPTH] = { @@ -330,13 +325,13 @@ void wg_allowedips_remove_by_peer(struct allowedips *table, child = rcu_dereference_protected( parent->bit[!(node->parent_bit_packed & 1)], lockdep_is_held(lock)); - call_rcu(&node->rcu, node_free_rcu); + kfree_rcu(node, rcu); if (!free_parent) continue; if (child) child->parent_bit_packed = parent->parent_bit_packed; *(struct allowedips_node **)(parent->parent_bit_packed & ~3UL) = child; - call_rcu(&parent->rcu, node_free_rcu); + kfree_rcu(parent, rcu); } }