From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) (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 8FC8241D64A for ; Thu, 6 Aug 2026 21:14:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.134.164.104 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786050866; cv=none; b=HAqCcjvVc8GYehUmJSSNz9cK9hY5VYrtiNSdFO47rWQn4Kj2E7K/K8aEc9JthbM9MKwzgKJ0m0L/57MgOX4+EK+kh1H8BhFgSW/N/rT18D87haJ4lNm0YAkn3c/EIE1eHc80MxfFwjMuhFYJWSg3AIy4VfMf3KX0RvlSbMKcUWk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786050866; c=relaxed/simple; bh=XJgQK+wRXyHXFDH0VPJlx+MHFtluSoqEbzCbUZX33Gs=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=l9PBsN4ieC7vfwLrSHbG2ywNCW9OtfLkplaDceV3iRFbINkAOWYHM7EnsJNhFwbrhjhb0WofyZ77EhA5+5bn3h8mjNpXT6vklnAurYwhl7kU0qfE6hRyO1v+bxRg9zOnDa94ZmJgvxQ0tS0CVPhLiJo3m65Gx3LpNzNG0FhdL04= 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=Wg//09lO; arc=none smtp.client-ip=192.134.164.104 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inria.fr header.i=@inria.fr header.b="Wg//09lO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=vr2BTIxHyPqlCzr3Wz8UeqgAuTTu21C1/8oyIkJX+bM=; b=Wg//09lORuPMQ0pWsCocE8Rj1T8sX2p/4DXz4gy183zPtc/nom/e4b+g 66n+Etz30GYcegKwajloE4W8DZbzk90gVXGA3v8JxUMk0ew1G3uQQ0v/B Da/UA5tUBNJnrc2xcLOX/GKFOSc6AxKhMr82l9jjw7yfJMhmtwbPqKR43 w=; X-CSE-ConnectionGUID: MuNc9Ye8TTeM3ZGwlopQ+A== X-CSE-MsgGUID: egy0GkLbQymhii/cUS4eSQ== Authentication-Results: mail3-relais-sop.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.25,209,1779141600"; d="scan'208";a="153781456" Received: from 88-188-149-159.subs.proxad.net (HELO hadrien.home) ([88.188.149.159]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Aug 2026 23:14:13 +0200 Date: Thu, 6 Aug 2026 23:14:13 +0200 (CEST) From: Julia Lawall To: Sang-Heon Jeon cc: Nicolas Palix , cocci@inria.fr, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] coccinelle: mini_lock: improve performance when searching loops In-Reply-To: <20260727135249.1634580-1-ekffu200098@gmail.com> Message-ID: References: <20260727135249.1634580-1-ekffu200098@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII On Mon, 27 Jul 2026, Sang-Heon Jeon wrote: > The 'looped' rule collects the returns inside a for loop to > prevent 'err' from reporting them. It searches every for loop in > the file, and on files with large loop bodies the search explodes. > > For example, kernel/bpf/verifier.c runs for over 200 seconds, > almost entirely in 'looped' according to --profile. Since the > kernel .cocciconfig sets a 200 second timeout, coccicheck silently > skips the file. > > To avoid this, collect the candidate returns first, so that > 'looped' checks only those positions. 'err' then excludes what > 'looped' found. > > Every return that 'err' can report is also a candidate, so the > same returns are excluded as before and the output does not change. > A report-mode run over every .c file in the tree produces identical > output. > > So verifier.c now finishes well within the timeout, in a few > seconds. Thanks for the fixes. Applied. julia > > Signed-off-by: Sang-Heon Jeon > --- > Changes from v1 [1] > - remove unnecessary depends keyword as Julia suggested > - add exists keyword to 'looped' rule > > [1] https://lore.kernel.org/all/20260725113303.691676-2-ekffu200098@gmail.com/ > --- > scripts/coccinelle/locks/mini_lock.cocci | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci > index 71065d8a5d54..c65241c895ff 100644 > --- a/scripts/coccinelle/locks/mini_lock.cocci > +++ b/scripts/coccinelle/locks/mini_lock.cocci > @@ -53,11 +53,31 @@ spin_lock_irq@p1 > spin_lock_irqsave@p1 > ) (E1@p,...); > > -@looped@ > +@err_candidate exists@ > +expression E1; > +position prelocked.p; > +position up != prelocked.p1; > +position rc; > +identifier lock,unlock; > +@@ > + > +lock(E1@p,...); > +... when != E1 > + when any > +if (...) { > + ... when != E1 > + return@rc ...; > +} > +... when != E1 > + when any > +unlock@up(E1,...); > + > +@looped exists@ > +position err_candidate.rc; > position r; > @@ > > -for(...;...;...) { <+... return@r ...; ...+> } > +for(...;...;...) { <+... return@rc@r ...; ...+> } > > @err exists@ > expression E1; > -- > 2.43.0 > >