From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 647AB175A6 for ; Fri, 27 Sep 2024 01:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727401094; cv=none; b=Ht/QS2pqJ3Q/gJETCOlRh6wPxLIp0hVYbUGQp9//AkqakGQRD2hdj7Ifjk+rQ0RYJJ3L1LblZEj3tHaxKxvDSCgktlnJnQPiPyLjkVBUOF4cU0COABhxDuSDZe4xv6yyJprAHlO62mXP/Wik+XHDEXaiUh+NEgOGktoWjRf+DPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727401094; c=relaxed/simple; bh=EJQzkHkcMnte8kk3sy70iNjECMxGr+QWFDl5GeUDibk=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=NefS7jfO6rj0UR6pDaLef1zYPVKj1t4ct7X1aBku2z4wXpocRoB6sw+mwATPAu3/Nnavc6D/Qv4YGCSiiKa9kVh0MZeuMBqfJMGhAEVQ3RAa2EQZl2j0jpIifBRqFO8T4sHGQPyNBPd6TlASOJoSCRNlZ8ptj/3ytLzHN81GFFE= 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=lFnhZS/U; arc=none smtp.client-ip=209.85.222.180 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lFnhZS/U" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7a99fde9f1dso147565785a.2 for ; Thu, 26 Sep 2024 18:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727401092; x=1728005892; darn=lists.linux.dev; h=content-transfer-encoding:subject:references:in-reply-to:message-id :cc:to:from:date:mime-version:feedback-id:from:to:cc:subject:date :message-id:reply-to; bh=Vlhv6vJ9/p0T/1mFJKv1z0EQJeECGsYyZGl1aUOn/r8=; b=lFnhZS/UD79DBZM4t0vBUv6dN3kAkeKejO6G6oFB6owrFNxHMLGs9sf1Y2t6eyL/kc XTrGWoo+jHpMNk7nzP8I/cZAnJigIg1v4WQ1IGMyPNRZUgnoHEVCWfVqPJ5XtuQC+OYa jdPmvLOq4Lz6O36EP2UT94G9rznVXXztwu/jTE2xixIomwrt5e1uEIaSvvlIlQYsGcRl fAqbEB+qOP4Bfn6/xTEy/35GHivi4TkTvikJ6jsSaGhgrdxvjN+p11hF8LPm1/3x9Gi3 vvMwYmvk8xaDVr/HxZTiMB/0qFCkavtHVG3Uw2lw7Cl/I+KVlMMx3j2iNYK/LBCFzp8T lNyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727401092; x=1728005892; h=content-transfer-encoding:subject:references:in-reply-to:message-id :cc:to:from:date:mime-version:feedback-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Vlhv6vJ9/p0T/1mFJKv1z0EQJeECGsYyZGl1aUOn/r8=; b=vHo83pqsXPvYFixHudUuFzNDu+qojJJOf1shKbyuw+jCQwpo5K956ldcGc9reQk8Sb Pz0CLl7XcQKj5btw+h+rG554w2RmITpASNL2KAQspcMnX/FclseDvclIrzSKq04GrWGZ sx51q7fvqzna6mCh+ndM8gkvxeBVVmmEwaDYcGbkGJH39JnyomyOJJ0EkyTSS8aDr6ry oTvzfVZGjgMZzKbd53WZPr+M+P7vrD/Jp+JeS9AS/bZpfejRrjS8tffgM+bov6kecLvX fMPyS3qMz2m5VWc8TR6UVAse8fhwFs5qNYsP+5sPOj3qunJ9kHJHTiWSrtjHuTzKvVvd /HXg== X-Forwarded-Encrypted: i=1; AJvYcCUwOCFzHCkGokhvTvDprPHaRSB/Pz6lxjyqLe8+c+6JsEqLZPMv94bqA01ZicnGMSe7H4Np@lists.linux.dev X-Gm-Message-State: AOJu0Yzw3PR4w1vwA5BrAnqEbZahekH6Pfe3Y/RBDStq0EDCNd0H0ZkO qcuDcQH4ePE+ETrh6VFL02ECK/ip29HNt/roMLQOvGqdafE8duo9 X-Google-Smtp-Source: AGHT+IGGIx4GHXja8pTVUFJEvkYZ7hNl2HfLZkw22LyWg/l8WV2qX8Mb3nifflTKvhwohArNvVcLoQ== X-Received: by 2002:a05:620a:408e:b0:7a3:51ed:38c0 with SMTP id af79cd13be357-7ae3775f989mr306121985a.0.1727401092281; Thu, 26 Sep 2024 18:38:12 -0700 (PDT) Received: from fauth-a1-smtp.messagingengine.com (fauth-a1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7ae377f09bcsm42553085a.65.2024.09.26.18.38.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 18:38:11 -0700 (PDT) Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfauth.phl.internal (Postfix) with ESMTP id 2B6821200043; Thu, 26 Sep 2024 21:38:11 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-12.internal (MEProxy); Thu, 26 Sep 2024 21:38:11 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvddtkedggeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedfuehoqhhunhcuhfgvnhhgfdcuoegsohhquhhnrdhfvghnghesghhmrg hilhdrtghomheqnecuggftrfgrthhtvghrnhephfdvkeeukedtgeeugfegudejueetjedu heekhffhhedvudfgveehudefudffjeelnecuffhomhgrihhnpegvfhhfihgtihhoshdrtg homhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegs ohhquhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdeiledvgeehtdeige dqudejjeekheehhedvqdgsohhquhhnrdhfvghngheppehgmhgrihhlrdgtohhmsehfihig mhgvrdhnrghmvgdpnhgspghrtghpthhtohepvdeipdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehnvggvrhgrjhdruhhprgguhhihrgihsegrmhgurdgtohhmpdhrtghpthht ohepmhgrrhhkrdhruhhtlhgrnhgusegrrhhmrdgtohhmpdhrtghpthhtohepmhgrthhhih gvuhdruggvshhnohihvghrshesvghffhhitghiohhsrdgtohhmpdhrtghpthhtohepjhhi rghnghhshhgrnhhlrghisehgmhgrihhlrdgtohhmpdhrtghpthhtohepkhgvnhhtrdhovh gvrhhsthhrvggvthesghhmrghilhdrtghomhdprhgtphhtthhopehmrghgvggurdhmihgt hhgrvghlsehgmhgrihhlrdgtohhmpdhrtghpthhtohepqhhirghnghdriihhrghnghduvd duudesghhmrghilhdrtghomhdprhgtphhtthhopehurhgviihkihesghhmrghilhdrtgho mhdprhgtphhtthhopehrohhsthgvughtsehgohhoughmihhsrdhorhhg X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id DDF96B00067; Thu, 26 Sep 2024 21:38:10 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: lkmm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Date: Fri, 27 Sep 2024 09:37:50 +0800 From: "Boqun Feng" To: "Mathieu Desnoyers" , "Linus Torvalds" Cc: "Jonas Oberhauser" , linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-mm@kvack.org, lkmm@lists.linux.dev, "Paul E. McKenney" , "Frederic Weisbecker" , "Neeraj Upadhyay" , "Joel Fernandes" , "Josh Triplett" , "Uladzislau Rezki (Sony)" , rostedt , "Lai Jiangshan" , Zqiang , "Peter Zijlstra" , "Ingo Molnar" , "Will Deacon" , "Waiman Long" , "Mark Rutland" , "Thomas Gleixner" , "Kent Overstreet" , "Vlastimil Babka" , maged.michael@gmail.com, "Neeraj Upadhyay" Message-Id: In-Reply-To: <0b262fe5-2fc5-478d-bf66-f208723238d5@efficios.com> References: <4167e6f5-4ff9-4aaa-915e-c1e692ac785a@efficios.com> <48992c9f-6c61-4716-977c-66e946adb399@efficios.com> <2b2aea37-06fe-40cb-8458-9408406ebda6@efficios.com> <55633835-242c-4d7f-875b-24b16f17939c@huaweicloud.com> <54487a36-f74c-46c3-aed7-fc86eaaa9ca2@huaweicloud.com> <0b262fe5-2fc5-478d-bf66-f208723238d5@efficios.com> Subject: Re: [RFC PATCH 1/4] hazptr: Add initial implementation of hazard pointers Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, Sep 27, 2024, at 9:30 AM, Mathieu Desnoyers wrote: > On 2024-09-27 02:01, Boqun Feng wrote: >> #define ADDRESS_EQ(var, expr) \ >> ({ \ >> bool _____cmp_res = (unsigned long)(var) == (unsigned long)(expr); \ >> \ >> OPTIMIZER_HIDE_VAR(var); \ >> _____cmp_res; \ >> }) > > If the goal is to ensure gcc uses the register populated by the > second, I'm afraid it does not work. AFAIU, "hiding" the dependency > chain does not prevent the SSA GVN optimization from combining the > registers as being one and choosing one arbitrary source. "hiding" > the dependency chain before or after the comparison won't help here. > > int fct_hide_var_compare(void) > { > int *a, *b; > > do { > a = READ_ONCE(p); > asm volatile ("" : : : "memory"); > b = READ_ONCE(p); > } while (!ADDRESS_EQ(a, b)); Note that ADDRESS_EQ() only hide first parameter, so this should be ADDRESS_EQ(b, a). Regards, Boqun > return *b; > } > > gcc 14.2 x86-64: > > fct_hide_var_compare: > mov rax,QWORD PTR [rip+0x0] # 67 > mov rdx,QWORD PTR [rip+0x0] # 6e > cmp rax,rdx > jne 60 > mov eax,DWORD PTR [rax] > ret > main: > xor eax,eax > ret > > gcc 14.2.0 ARM64: > > fct_hide_var_compare: > adrp x0, .LANCHOR0 > add x0, x0, :lo12:.LANCHOR0 > .L12: > ldr x1, [x0] > ldr x2, [x0] > cmp x1, x2 > bne .L12 > ldr w0, [x1] > ret > p: > .zero 8 > > > -- > Mathieu Desnoyers > EfficiOS Inc. > https://www.efficios.com