Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp416016lqp; Sun, 9 Jun 2024 01:58:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtAaWFQYqmpt+y0rONod3xBaUTTI2N5l0mNNI7WFR12c12bdpYra/kd8wF1GljNWOircIL8gIPLb3UtBxhp3Un9iuXhRNzzvq9Wp+iqA== X-Google-Smtp-Source: AGHT+IH+mvbvBY4/j6DWP2mW7unB7OeT2YpvHcBIfJfZF+wwjxqOVgnXu45bTKjRMMvTetkVo/WV X-Received: by 2002:a05:620a:3186:b0:795:be11:c626 with SMTP id af79cd13be357-795be11cb6bmr40122785a.26.1717923495522; Sun, 09 Jun 2024 01:58:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717923495; cv=pass; d=google.com; s=arc-20160816; b=NjUBXMr8nmuGJG7gjRhuA8wRTCsTEmhMBcoWdu9QNQzTtlw7mGbzkBRQx+UMp+v9Gi VlPmFS1jymc8h8XWXwsXYHq5BXgCZ6mBUAp8Te+oYD0Ad0o1q2XIa8Sam67B2coot28g GSaZ3X7XX0LWzVw371uo01VWVtsA6CNhE1HX6v+U300kNz/oC0t/4nDCXv7rBvLiN1KT X2/vMMMIwsEdPdmJslrnfYHVeYe6XMNFwdiz8wYilzU+XzE9k5LwdlsIwcjWrLE3s40D kgbNdB/o8iroSabNRcikurkcEVvvKFYQa1TUB9Vlcd0xQUTe219c0mDfV8ZyHuvzDYE6 /ZzQ== 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=tUDxrqQiWbXlWuXN/Tr1rDsMKk8ae92U1Hm7BKqU4jI=; fh=arCQrRvi2z/xDlqzwZZ5n0QeQFPEp/s1Ww6Q+I6YVwc=; b=EGRZ6a2xnNwb/FUWSlZfLpW+0gKh6J5z657L6s7xnROUVRXAT2WhsHZdIpBOrvAwb4 FDXuMsq5HU5i2k3aSkN3y4RoFe1gul8pQ46HU4ivIk7r1/3mPHh4rn3WtsClb+cQdnGw X3HxgVXbM3dswwQ2ahdbxz0IamzK6dq4Shlgb/6D7VEKCnVoXaKgY9uxRGvcOLJpDOWX 7pgkOTq+SEfi7VjvyXjm+WaDy7Bd6u0cWsyka7ZTDvqeF1kKMBKF4XI+V/eJYcjmDSdA tSzV2aE3x6TUBVaejqdoJMwNFrdEiXUQpw0MqFyWh2W53kxJm80u19S075rdSj0HfmXT +5IQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=RJ+U44L7; 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-207293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207293-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7953338695bsi771415585a.706.2024.06.09.01.58.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:58:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=RJ+U44L7; 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-207293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207293-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E29201C21D08 for ; Sun, 9 Jun 2024 08:33:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C99696F2FE; Sun, 9 Jun 2024 08:28:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="RJ+U44L7" 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 D15A4524C4; Sun, 9 Jun 2024 08:28:12 +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=1717921695; cv=none; b=Sn1CxzKmZdr0gs4VhC5k+2oEeaVOJsFSKAsZwY0RBkfi6Hqlt2FcStS1aqrUMRRMSQYlqJyjvM1UbDzqqgb7IJrAk2DXcd6k+6Hm+Ojr7NeV7KY2Fx2SDY4wQBxe8/GC+8prU7EaF5U6kfY3I/tfI3CoTHAdjW9WEYSDwGpdISY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921695; c=relaxed/simple; bh=fR12+M+APr/jd/Ecu2I15utUI4N3KHLcSGf4K4f6s/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pjdLYLrlGxaHl1bcVrjUPAoewAfE0Gwl1c2Ubk95mIM5QOTWlyV+dA/WuUdxjC/URVKFjbDzLOG0lRZS94v0pCkhzCESIKr28JT9XQHp7Bh858p/nO0xAVIXzVtE5ZwqMa78OmPHrCPj/3FCB7Xjcmutwp6ON7vfAgRnin/qALo= 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=RJ+U44L7; 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=tUDxrqQiWbXlWuXN/Tr1rDsMKk8ae92U1Hm7BKqU4jI=; b=RJ+U44L7RR+i7JTpW1vs4VVKKFFrUGQKAc6FoO1bz1zuIIzuO824qiFn wtyNmkaoiFDVLOUiVYVMqlnSy3ShvrrAtKDBIxuA/f+cDy3h3PPiCWVzB CihqDphX7Jflln/MpPO7Po2np2ikiLbceKL+xGbwrufkxltBFWgxYyVEl U=; 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="169696908" 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: "David S. Miller" Cc: kernel-janitors@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 13/14] kcm: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:25 +0200 Message-Id: <20240609082726.32742-14-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/kcm/kcmsock.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 2f191e50d4fc..fbb730cd2d38 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1580,14 +1580,6 @@ static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) return err; } -static void free_mux(struct rcu_head *rcu) -{ - struct kcm_mux *mux = container_of(rcu, - struct kcm_mux, rcu); - - kmem_cache_free(kcm_muxp, mux); -} - static void release_mux(struct kcm_mux *mux) { struct kcm_net *knet = mux->knet; @@ -1615,7 +1607,7 @@ static void release_mux(struct kcm_mux *mux) knet->count--; mutex_unlock(&knet->mutex); - call_rcu(&mux->rcu, free_mux); + kfree_rcu(mux, rcu); } static void kcm_done(struct kcm_sock *kcm)