Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp392955lqr; Wed, 5 Jun 2024 09:01:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWCOmMtXhI3oA+R9Qix1i1ceGNycwEpFAghiO/ZWZK73ZaQNdSd6tJqUTpzctwt1hgGTfLppvInZRuboeOV3/xObZapW+2FC9jy2XdrXA== X-Google-Smtp-Source: AGHT+IED8WcGTh/UkBkYCfj+gT8u8beemaqqzdxIKcjAhJDmJHY+X7lbKs17G8Or5biCEg7eYcMP X-Received: by 2002:a17:902:c40a:b0:1f4:8a31:5a4c with SMTP id d9443c01a7336-1f6b8ef5145mr867205ad.24.1717603275363; Wed, 05 Jun 2024 09:01:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717603275; cv=pass; d=google.com; s=arc-20160816; b=yyB8BLx7tU8WujeQ+mZ0TIcGxdjbHye+Y5ytenrY4lkoU8Uxc/z0GeSx6uqJdar3iP qxxenxKeMSDwaHDgHfulOmUgIqq/ZhovRvUtyXfkjVNSdrJuRCuuR6ksl+WPDNoPpM6r QZe3JSRLPOTm0l5PGRt0lAmKAYkQoWKwn7D/HNPAZzCyfYGmvYqSo8ieE33X0bpjB2p0 Uo716CD+obn/iVFYuvL7gFP8mKIX0gGKjjuHDiiy/Yv92GKQTtQJEp6ch73/HTnefrns 9QwB5aZtmzC/1NV+4oVbeFJK/aV/NNGJjDqkUdNNjtKlbWdQAjDSX35uHeSFXcyJnjsD ReRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=f9jTJjGgq2Iq6AZpz1lcgmhEzP0+VmxrLLcoU2m5DL8=; fh=whT3whL0/0FAvwqCmtO4yry5pVUddBhTkNU2KPPAJts=; b=c/e1XoZNzoopTUm0ivdmNyIM8Wg2hwyTjgK9DymuIalzZJ1RPEf/mXKn7vExeroqs6 DNYcI9Hty7SSwDTGdmv+kqGx0+sxKwlWylvBxWXcEaLP/PyJ4jDjvS+ZxHN1TwaTbOx9 vHLeEy16N/S+oPYlkSyQgiv4qS5NNxaLADIOSYrrkMDCrQ/jsJHvxQVpDBelrgiaL+kZ nxfGJHDGImos4FQMDKHtUbSCicH890lmsTRTO4v4mAccTSZYy7B2E5NC8nfp5GMTkx4m DDokeeXF7lhAn327rHZi9XzR0E5pMwwEFHAww+AimZgev7NS46NgoNxuCHAAT8TpEzAs 0/DA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-202837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f63233d149si27300625ad.14.2024.06.05.09.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 09:01:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=netrider.rowland.org); spf=pass (google.com: domain of linux-kernel+bounces-202837-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202837-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu 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 16A85B2955D for ; Wed, 5 Jun 2024 15:32:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BB084AEC3; Wed, 5 Jun 2024 15:31:54 +0000 (UTC) Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by smtp.subspace.kernel.org (Postfix) with SMTP id 4F70D17BCD for ; Wed, 5 Jun 2024 15:31:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.131.102.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717601514; cv=none; b=DrYCTHCtRJSq9jOGmzXGUO4Fvux/tYzDaroBBeF6ZqWEljtJrtC5RDmw8QEyyiocAZ1uoUhFbBflsL1Ed/am52TG2ynu53a4ENC7iDGHok6zI7/VzAv0I4/1q84KMlHehtxk1WtSfuH4H97m7IP9oGuY43rVLwny6R547N1oNDY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717601514; c=relaxed/simple; bh=iRlfwxeaSfwteupu42k4XO0pgXSHyGiyHXTbklvGMgc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=q4joUcwQgAXUh7mVglqT5K0DAWn2SdysejYpsyhEWoE3XtZvt9akR/y1jTUqtAOEj8LLI7McfdbkbBrgiB1m0MJhxDeUbxlnXCANVph/jab0NQ2IB/EmiqwnEbJ4tySj1ccyo9aBSgi0HHURxdzAE9uH5MS6fnXmWDPW2lF+E0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu; spf=pass smtp.mailfrom=netrider.rowland.org; arc=none smtp.client-ip=192.131.102.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netrider.rowland.org Received: (qmail 200282 invoked by uid 1000); 5 Jun 2024 11:31:51 -0400 Date: Wed, 5 Jun 2024 11:31:51 -0400 From: Alan Stern To: Andrea Parri Cc: will@kernel.org, peterz@infradead.org, boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr, paulmck@kernel.org, akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, hernan.poncedeleon@huaweicloud.com, jonas.oberhauser@huaweicloud.com Subject: Re: [PATCH] tools/memory-model: Document herd7 (internal) representation Message-ID: <28bdcf4c-6903-4555-8cbc-a93704ec05f9@rowland.harvard.edu> References: <20240524151356.236071-1-parri.andrea@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 Content-Disposition: inline In-Reply-To: On Mon, May 27, 2024 at 10:07:06AM +0200, Andrea Parri wrote: > > It turns out the problem lies in the way lock.cat tries to calculate the > > rf relation for RU events (a spin_is_locked() that returns False). The > > method it uses amounts to requiring that such events must read from the > > lock's initial value or an LU event (a spin_unlock()) in a different > > thread. This clearly is wrong, and glaringly so in this litmus test > > since there are no other threads! > > > > A patch to fix the problem and reorganize the code a bit for greater > > readability is below. I'd appreciate it if people could try it out on > > various locking litmus tests in our archives. > > Thanks for the quick solution, Alan. The results from our archives look > good. Here's a much smaller patch, suitable for the -stable kernels. It fixes the bug without doing the larger code reorganization (which will go into a separate patch). Can you test this one? Alan Index: usb-devel/tools/memory-model/lock.cat =================================================================== --- usb-devel.orig/tools/memory-model/lock.cat +++ usb-devel/tools/memory-model/lock.cat @@ -102,19 +102,19 @@ let rf-lf = rfe-lf | rfi-lf * within one of the lock's critical sections returns False. *) -(* rfi for RU events: an RU may read from the last po-previous UL *) -let rfi-ru = ([UL] ; po-loc ; [RU]) \ ([UL] ; po-loc ; [LKW] ; po-loc) - -(* rfe for RU events: an RU may read from an external UL or the initial write *) -let all-possible-rfe-ru = - let possible-rfe-ru r = +(* + * rf for RU events: an RU may read from an external UL or the initial write, + * or from the last po-previous UL + *) +let all-possible-rf-ru = + let possible-rf-ru r = let pair-to-relation p = p ++ 0 - in map pair-to-relation (((UL | IW) * {r}) & loc & ext) - in map possible-rfe-ru RU + in map pair-to-relation ((((UL | IW) * {r}) & loc & ext) | + (((UL * {r}) & po-loc) \ ([UL] ; po-loc ; [LKW] ; po-loc))) + in map possible-rf-ru RU (* Generate all rf relations for RU events *) -with rfe-ru from cross(all-possible-rfe-ru) -let rf-ru = rfe-ru | rfi-ru +with rf-ru from cross(all-possible-rf-ru) (* Final rf relation *) let rf = rf | rf-lf | rf-ru