Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp408760lqp; Sun, 9 Jun 2024 01:30:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlKhouRw6/a4AVDAxQIpyEi9BAr5jSYpXM41X6W2qnD5xZ08nNEvozAj/Ua2eMzH4KOrXGp5t7cRAw1cIzCnfh+F+wxxlFjul+7aJcMg== X-Google-Smtp-Source: AGHT+IF9KteULthptkDjetpadaP49fE0pp/C1BcBQSwjwP9oKI3GixWIiXfZsR7EJmD+5z9urbuT X-Received: by 2002:a17:903:2452:b0:1f7:8f4:ac24 with SMTP id d9443c01a7336-1f708f4b100mr10579265ad.12.1717921821261; Sun, 09 Jun 2024 01:30:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717921821; cv=pass; d=google.com; s=arc-20160816; b=xsJCAVq3I1DjMYglAxOEVWQ9y6NPcNbijubT40WJ1Vx0M+c/BcbHK7HhCECXxKcseI 3cfxY3M4TAwfMUJdD8+pBJrd6lKX6mYjEoBAunsuM2n+T3qjkv+pyKaYnUq6RvLUtAwX jugITSkquUMJYjF36XouPJHJPPxIzJ5qR2y1Ez7NwXoQ1qUuo6sTWxXjiPUyCBiX0SK2 aeOUWJ5HFU3wrYC1dwKkXjxTIE+STgkDwz/dhBNWD6pWa3JuoaXiKk7gQGoRwcAwvmsJ 0xUS/2qP/VBeONIuzp4EchqgptuHBpXcLQ+sUBwlYCZ14S88VSk+evToS9V6MAg2DM2+ 8F7g== 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=ZwDxwbFMfkAGTj6xpSZP0MBWfEJMR+icep3KWfFQ5q4=; fh=3R7TKhZ18cJbRcJr84md1XRNyUYNCyDi9rg6mQn5mio=; b=RnVPbGky0CQaYE2pB6TB7rXr6R5sLE9FnN/FjsFGS2u/DVFkWuiRFSuSi6edbrbL5m aX5SxmmGrTLP2Ja4z4fJJgm1mGXJmX+hqXYtzMFLRPUP8GJCRwKX313awO9301OD5ADX ycey+i+HYYVIDJ0KUxiICPp+pGw8ZIDGPxvTDc/+YceNbqkLWWIm/rU1z7Mpe0Dc9NEB CYqz3zlfP7eGWw+O31hkAedcim3QIcmwCBaglbIe05GY+CpYteiEI3XbM7i92Wb1y15z N7Ps8cFtrKwQP+85tEqrMJHVE4mCQ51xbNc4SjMZgApAa7FJfuxwZ3cgn9F7pIK0cWkU vyjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Np+fYlbG; 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-207283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207283-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-1f6bd7614a4si20837635ad.89.2024.06.09.01.30.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 01:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207283-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=Np+fYlbG; 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-207283-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207283-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 9185BB2125A for ; Sun, 9 Jun 2024 08:29:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A72973EA86; Sun, 9 Jun 2024 08:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="Np+fYlbG" 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 9CF7222F1C; Sun, 9 Jun 2024 08:28:03 +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=1717921685; cv=none; b=TolEDEeEqo6v5XU6Ru0kculx8XB8mo/L1xEsTZixjqE0Fc3ho18lNn+rzamIPjHZP7cvlK0zEhogPitMwuUj27R8jic/BI5F219qk9fItRJyM1QMuRbTEZQFIap5gYD59y51Dnr9ku99l9kRz3hk2R3nBebLFQXjHOIe/1D5ZLY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717921685; c=relaxed/simple; bh=yoTu63QouQ0BjTg8zv0l9uF0vA2xd9QWsFgV+/ef3vY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D6sXbMwEFhKcj5pXbSkmvhvi5FSVt1L6UUSbdjnY3lS95WA/QU95YH40KrCjHxvE+RiGiGJupJDbWnkRGRxFW55sQnn1rRjt6xhwtWgTFSMcj7c1skj9xwubGIPRM1kklIP2IEloxd6QIM6CjGJzhIPkFUA1D5vorDm+0CTas6Y= 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=Np+fYlbG; 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=ZwDxwbFMfkAGTj6xpSZP0MBWfEJMR+icep3KWfFQ5q4=; b=Np+fYlbGt3JUPSQjzXCtgXi8lRudY+xTEr+op3xX7Nwe4QAO64Nvz0am rZWIZtJpKcVG2lVroSwyQ3jRnIZ27KTGZbkh1lAjD+6wVfqlpHsabtPr6 SBJ0rTMWogAnMwz6+VzZO/NGZMFvEtfSzWwmyt6IR3LdYRSo6pzF1YTOG w=; 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="169696898" 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: Michael Ellerman Cc: kernel-janitors@vger.kernel.org, Nicholas Piggin , Christophe Leroy , "Naveen N. Rao" , linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E . McKenney" , Vlastimil Babka Subject: [PATCH 03/14] KVM: PPC: replace call_rcu by kfree_rcu for simple kmem_cache_free callback Date: Sun, 9 Jun 2024 10:27:15 +0200 Message-Id: <20240609082726.32742-4-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 --- arch/powerpc/kvm/book3s_mmu_hpte.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_mmu_hpte.c b/arch/powerpc/kvm/book3s_mmu_hpte.c index ce79ac33e8d3..d904e13e069b 100644 --- a/arch/powerpc/kvm/book3s_mmu_hpte.c +++ b/arch/powerpc/kvm/book3s_mmu_hpte.c @@ -92,12 +92,6 @@ void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte) spin_unlock(&vcpu3s->mmu_lock); } -static void free_pte_rcu(struct rcu_head *head) -{ - struct hpte_cache *pte = container_of(head, struct hpte_cache, rcu_head); - kmem_cache_free(hpte_cache, pte); -} - static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) { struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu); @@ -126,7 +120,7 @@ static void invalidate_pte(struct kvm_vcpu *vcpu, struct hpte_cache *pte) spin_unlock(&vcpu3s->mmu_lock); - call_rcu(&pte->rcu_head, free_pte_rcu); + kfree_rcu(pte, rcu_head); } static void kvmppc_mmu_pte_flush_all(struct kvm_vcpu *vcpu)