Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp150442lqt; Mon, 18 Mar 2024 04:28:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLaxEJ368EkNxJH1QpEHkB0y5nWcacj8EgaxEzyF242foN1WuQox8p8jTMBhqJ00PulcvyGDbQVVSDeJWxkD3BVGII2URJwM/DLCwLvA== X-Google-Smtp-Source: AGHT+IH0wxmSeorh1vEu810tD29gUJ5kV+LrjVWGtEqbbhEM3/MbvSu9hV6g2PYOulcGEI9Ay8b9 X-Received: by 2002:a05:6808:220d:b0:3c3:88d1:644b with SMTP id bd13-20020a056808220d00b003c388d1644bmr3666007oib.8.1710761321820; Mon, 18 Mar 2024 04:28:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710761321; cv=pass; d=google.com; s=arc-20160816; b=tCHOoIL1WrPA/dB1h8BGgePhbVC7kV3UmJTlEgXQCymEN571S39nnVizoPlEANWNAt af6l2XQRpR0y2z3XGVck3OxWm/aIP9RHV3XNe0qONxpNPl/GK/qnSh1zOkmNgSD+N+iV NvI3YU9LEBWRwUP+yy821OjvsKSgl9g/VByeMheaJg2Tan4JpMRX+jfjYtYoaAHPnU8A m6JHfQ3GCo4Bq+t+dhvMmycRew+8AMs+5wSIRwhBhZlA3SVNForGqblRpPUtRJxh295U Yx/aNAlwZ6oGKoXrEfYbojkLuctVb6hZ5NFDuwaT+N+sSRJI0D++4t4NJnPmXrgngLsg KrRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=S4Mt4p7wAOdgiDEHZhgd4EK4q9C+aV5jj64LBCK23vI=; fh=mhMWuXmf8pVDoG6YzuprGTdbWv9jpsbmkWJBkLxCytw=; b=Rr1yKCqxJwcJ9lZj+MUD39tl04JUcuKj5Eu1HW66ZZMB8p8KiJbZI6IKhwGNc7EwgX 7pIzNyZm/GGNeN9CdQUlo8UkZstpbihwFpaAy2+cqseZnnSHbCogLLDM72xjbWHjFSrx MVNK/+NARVnwb7gt3ipMvzEcZyoPvVdxNPZ+1qikQ71922OpsE2SxCRHavzRNEGoaZcZ l08QiI5tmyOeBDc4D/0B/VMhyLNToidWiswscyAqTP4uD4VWrXp47XAxTiZsmi/0cq+f hxA/5mFVHMKbIT39qRGTGSMyUUnrq11xeP6O7VhpC1CkhL7xLcM5F3ldRw0dLf9Jj8Md C3Yg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=jV8esOJk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h32-20020a63f920000000b005d798062b8csi7890563pgi.499.2024.03.18.04.28.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:28:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106059-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=@gmail.com header.s=20230601 header.b=jV8esOJk; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106059-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106059-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 865BEB23410 for ; Mon, 18 Mar 2024 11:21:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF6F53BBF1; Mon, 18 Mar 2024 11:20:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jV8esOJk" Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B47C3BBE2; Mon, 18 Mar 2024 11:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760813; cv=none; b=iTNqqOq5SwkE0TvDOGiZqlzltESTsWD3EmwZ5qTWICJ6nc3BCTyon3s5VAjFWVXYkYf5WiI3O6nZjDUy7Ly2oDNJ/qeOLDPWFZ7MnqOhecaUeocuGJJBlcRlgVS9Ra5JsHZuEkzkQS+0MAK7li+kXWrc7BTyvgJ5PbLb+WScF/s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760813; c=relaxed/simple; bh=BL1bAqpLJmyZg3Nv7cSa0Llbm5MKvY0HFvK/cxp2F1s=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=MhfsD87kMLZfBaEF6ZSnb2wqLmKxpusXSmaClQ0lwczo5CLxM66N628Wq4xhL4tXFqumwN8rsm6Nq5JTLSWvLOt30Vn/wcnB2j/HX2IHCJwJu7d5lmcm4w/qeKYiz50cHx9UUivEAH8vxonkawyh2CxugnQ3Fvw9xIqF0zlOLm8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jV8esOJk; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e6aa5c5a6fso4123876b3a.0; Mon, 18 Mar 2024 04:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710760812; x=1711365612; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=S4Mt4p7wAOdgiDEHZhgd4EK4q9C+aV5jj64LBCK23vI=; b=jV8esOJkRaZErKopnzHJUVO1VxyMr7L5iRbvS+F8yWjK0SSusWg0Gz6GZJ4FRZYEdg DuE7AakZoHllV9h74E52VLO/fP/gh7pBVXkv1UkEr8UOpRBEIn8uK+Bf+D8E4VI3MVeQ 4P2wgVQsJlv7CFX11+wt4eq9OhlRajmFsX4vwSWr+zepyIrRmSVNZLdQuMJWtg0QGBRG vsJLs9RVno+CJKOti0Gn3oTo7oBg7mqn5HltKWtKpecDHPfxLB/zq4F3Uju22l4aVSO6 SAl/mFqFFxZj8lSFcQAzhkoCaVQTnTqOOrtiAk/8c1QmnYexDQD9BgnCBdleLOe1zMi5 94mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710760812; x=1711365612; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S4Mt4p7wAOdgiDEHZhgd4EK4q9C+aV5jj64LBCK23vI=; b=R23chMUdlv7Ksv1NIIs+VVhaC5W7Mv7mFWaGD0XU9rswzUCTwX3mJj2yJasNdxwdq1 t8lRgvH6eNAMI2Ls4lvW/pOFvajB3fidXggx1AudeP9J5FKuOarP+QRFyenoPpVyL2Q7 /P2lWhM3nSPh2t1zpuSYvnhFZTvJnmaNuaU45pafBD21fcLILbX41ifsNApG3Vbgj6K7 AUUhmcm6uwrOvgf8G9K4oXdAms7/TnbvB5novxCaFlqBzkUUzYhXevlrCMSniYv0tJe8 J5dBsjWVH2Dn+2cGzO+4Rp+n44okAqZmu+yQhN8Q1/tYB30/kxZ/NdQfhAe0oXs323LC mVVQ== X-Forwarded-Encrypted: i=1; AJvYcCUuQqbMJ77bhFu7iZz52oG/XMblpGky1AD64NwMeyxxyejKbD01VJfTdoLjTZIZHJYP3kyg/qzjsEnaoWimyIT+3rYEww8xWog+jsxaZqi+11WeZdky9jIX0oi5R+Dwaw== X-Gm-Message-State: AOJu0Yw2jU8uKstFW6sx0sA/6FUl0HBvHXnxKqfrmiGbgyo+AuUopoWz moyzFH4C9IdQInzvzpSUy4iYiOY3Ph130sZmtV3S6FMnuSTYd8qZkcsbONuR/4w= X-Received: by 2002:a05:6a20:9f87:b0:1a3:6b56:d4d8 with SMTP id mm7-20020a056a209f8700b001a36b56d4d8mr704884pzb.48.1710760811728; Mon, 18 Mar 2024 04:20:11 -0700 (PDT) Received: from smtpclient.apple ([2402:d0c0:11:86::1]) by smtp.gmail.com with ESMTPSA id e11-20020a170902b78b00b001dd75d4b408sm8946380pls.302.2024.03.18.04.20.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Mar 2024 04:20:11 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.300.61.1.2\)) Subject: Re: Question about ISA2+pooncelock+pooncelock+pombonce litmus From: Alan Huang In-Reply-To: <17ddc858-a926-4f12-beda-3f54cb91bfbb@paulmck-laptop> Date: Mon, 18 Mar 2024 19:19:56 +0800 Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, rcu@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <12E5C279-ADB1-463E-83E2-0A4F5D193754@gmail.com> <17ddc858-a926-4f12-beda-3f54cb91bfbb@paulmck-laptop> To: "Paul E . McKenney" X-Mailer: Apple Mail (2.3774.300.61.1.2) > 2024=E5=B9=B43=E6=9C=8818=E6=97=A5 07:02=EF=BC=8CPaul E. McKenney = wrote=EF=BC=9A >=20 > On Mon, Mar 18, 2024 at 01:47:43AM +0800, Alan Huang wrote: >> Hi, >>=20 >> I=E2=80=99m playing with the LKMM, then I saw the = ISA2+pooncelock+pooncelock+pombonce. >>=20 >> The original litmus is as follows: >> ------------------------------------------------------ >> P0(int *x, int *y, spinlock_t *mylock) >> { >> spin_lock(mylock); >> WRITE_ONCE(*x, 1); >> WRITE_ONCE(*y, 1); >> spin_unlock(mylock); >> } >>=20 >> P1(int *y, int *z, spinlock_t *mylock) >> { >> int r0; >>=20 >> spin_lock(mylock); >> r0 =3D READ_ONCE(*y); >> WRITE_ONCE(*z, 1); >> spin_unlock(mylock); >> } >>=20 >> P2(int *x, int *z) >> { >> int r1; >> int r2; >>=20 >> r2 =3D READ_ONCE(*z); >> smp_mb(); >> r1 =3D READ_ONCE(*x); >> } >>=20 >> exists (1:r0=3D1 /\ 2:r2=3D1 /\ 2:r1=3D0) >> ------------------------------------------------------ >> Of course, the result is Never.=20 >>=20 >> But when I delete P0=E2=80=99s spin_lock and P1=E2=80=99s = spin_unlock: >> ------------------------------------------------------- >> P0(int *x, int *y, spinlock_t *mylock) >> { >> WRITE_ONCE(*x, 1); >> WRITE_ONCE(*y, 1); >> spin_unlock(mylock); >> } >>=20 >> P1(int *y, int *z, spinlock_t *mylock) >> { >> int r0; >>=20 >> spin_lock(mylock); >> r0 =3D READ_ONCE(*y); >> WRITE_ONCE(*z, 1); >> } >>=20 >> P2(int *x, int *z) >> { >> int r1; >> int r2; >>=20 >> r2 =3D READ_ONCE(*z); >> smp_mb(); >> r1 =3D READ_ONCE(*x); >> } >>=20 >> exists (1:r0=3D1 /\ 2:r2=3D1 /\ 2:r1=3D0) >> ------------------------------------------------------ >> Then herd told me the result is Sometimes. >=20 > You mean like this? >=20 > Test ISA2+pooncelock+pooncelock+pombonce Allowed > States 8 > 1:r0=3D0; 2:r1=3D0; 2:r2=3D0; > 1:r0=3D0; 2:r1=3D0; 2:r2=3D1; > 1:r0=3D0; 2:r1=3D1; 2:r2=3D0; > 1:r0=3D0; 2:r1=3D1; 2:r2=3D1; > 1:r0=3D1; 2:r1=3D0; 2:r2=3D0; > 1:r0=3D1; 2:r1=3D0; 2:r2=3D1; > 1:r0=3D1; 2:r1=3D1; 2:r2=3D0; > 1:r0=3D1; 2:r1=3D1; 2:r2=3D1; > Ok > Witnesses > Positive: 1 Negative: 7 > Flag unmatched-unlock > Condition exists (1:r0=3D1 /\ 2:r2=3D1 /\ 2:r1=3D0) > Observation ISA2+pooncelock+pooncelock+pombonce Sometimes 1 7 > Time ISA2+pooncelock+pooncelock+pombonce 0.01 > Hash=3Df55b8515e48310f812aa676084f2cc88 >=20 >> Is this expected?=20 >=20 > There are no locks held initially, so why can't the following > sequence of events unfold: >=20 > o P1() acquires the lock. >=20 > o P0() does WRITE_ONCE(*y, 1). (Yes, out of order) >=20 > o P1() does READ_ONCE(*y), and gets 1. >=20 > o P1() does WRITE_ONCE(*z, 1). >=20 > o P2() does READ_ONCE(*z) and gets 1. >=20 > o P2() does smp_mb(), but there is nothing to order with. >=20 > o P2() does READ_ONCE(*x) and gets 0. >=20 > o P0() does WRITE_ONCE(*x, 1), but too late to affect P2(). >=20 > o P0() releases the lock that is does not hold, which is why you see > the "Flag unmatched-unlock" in the output. LKMM is complaining > that the litmus test is not legitimate, and rightly so! Oh! I missed that line, Thank you for pointing this out! :) >=20 > Or am I missing your point? >=20 > Thanx, Paul