Received: by 2002:a05:6500:1b8a:b0:1ef:a0f1:aef6 with SMTP id df10csp69093lqb; Sun, 10 Mar 2024 05:37:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBL6EgCjwGhDAWVg4xVGns7VkJwfU2/PiNOR0IALe9V7TjhxfjaE8ScyGXohRwp7jEvQMYt9Ygq9fj4BfX+/BLK6Yn6sQs4cFsh8GdYg== X-Google-Smtp-Source: AGHT+IE/PTnTsZmvB92JOXZrnWKEyK46vW6uf/minh4lgfS7w57kXbVL+f+123W1Eqpi8HfFj/hy X-Received: by 2002:a2e:97c9:0:b0:2d4:15e8:b545 with SMTP id m9-20020a2e97c9000000b002d415e8b545mr2720042ljj.18.1710074223071; Sun, 10 Mar 2024 05:37:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710074223; cv=pass; d=google.com; s=arc-20160816; b=Gl6xpIyCxeOzM5iSlmbKBetQHMG8l0xV4rVQ75fgVKZJR8OPWwGItY0LKhsWhu4Vrc hn6pKvXyTgd0wEG4wQtq6/W3J+BybBMt1bqErMw5Fx6HM72zFWTjfXyBX+b6NvvizjQL vj3dRpaihfQEB+8l9UzXiPfopH1BUAwS90iZuijMbYwiV4jF8SAG4EODLng8uAyIjknx NJbiFR8UNAFW7NVWRh6JZKl8QgBOA1mJyhgjvwmaKIemEUHX+eayM09eRR9yAQwceeSd pUj5/EQ55jgTyAFVzwbth9J79FPRKkf/YnDSZpdmfraHm6KL+txtDsxeU48rcj3OczKc 0jsQ== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=xhILMpXmjh62wZTAFQ4UaRzNQOPst+CVs6ZuyVeh/8A=; fh=MRD9L7V3aMx7WNFzFB9ItaFAeS1YG/H6VdPkCcF4AOw=; b=ik2tbNfVDWDO3sM5p5Kr+z0z51C5djbrwvwZ7XgWZlPofDEjDaM8kQS6gbSguPesth h/6yxro8xsYN6KFprb2imVpNmmXX8kp9tqe1XBFWD2D/7ZS1QUsyn7kw5JUhlPkeNjA0 +k8RaNtHMKj1bfnC0ngWS9e6qlqVsGf3HzQOTLJrclb72St+B/gyR+0SsQmP7YbrDWIb FykQmyRVv5TMALqfYvjvZvln7bBNLBXAT/ptrTSWW2xR9c6V5H/s0fzv8NE48U9DqU8F WzI0dXk1pUgIhlyPCbCABvmYUzbmb6MkJNUzHPhFdw+dt/GCfPTEHquMuXFJ0xjAAkoa cI+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=lC0KogEM; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-98211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n13-20020a05640205cd00b005684bb03de7si811948edx.466.2024.03.10.05.37.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Mar 2024 05:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=lC0KogEM; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-98211-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98211-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.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 am.mirrors.kernel.org (Postfix) with ESMTPS id C337F1F21316 for ; Sun, 10 Mar 2024 12:37:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FE5525619; Sun, 10 Mar 2024 12:36:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="lC0KogEM" Received: from out203-205-251-72.mail.qq.com (out203-205-251-72.mail.qq.com [203.205.251.72]) (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 BE0F316FF23; Sun, 10 Mar 2024 12:36:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.251.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710074214; cv=none; b=bDNh87do+c1ghCPPj/GynvoFUvXA+FJBWsXFBBPxoAOEB2y/3o7FtrMg1UPg3nwXQJb77Qvg5xYsvFLESLytxyO85Xnd69S9aohOHF/Widn4D2W6yZ7cDcl9rukOETjorQhSjqV06FqjEubYBBJvwfdXbrgZ1e5DmLFMTwc5mZs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710074214; c=relaxed/simple; bh=FHkI/XTtwAO2bphz0FP9YeV3o6idfDLKkX3YyUFYqv0=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=buo48tZermijYUiXKfQnZbZnZfAscQifQdWIJxxfmAozfpe/Dw7bZxAEpwFM+JE/6Jfo04Qz9+//GC9jEs/CQoDB3sUqsqmlkhDGOlsR5OHXT5v6lckM0ZLpWX7L43abHvJAOtI3hAagx2ZxHbdYL1J3D+EBWJ139T5Rhcw+/Qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=lC0KogEM; arc=none smtp.client-ip=203.205.251.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1710074198; bh=xhILMpXmjh62wZTAFQ4UaRzNQOPst+CVs6ZuyVeh/8A=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lC0KogEMEb/4iYqtfE1JaBUbZWTUCwNNxfLA9Ts4s+z1SQaN3GFMYxE0M+lW1Ss6H dwZrAcjiFJD3MIn5iR0dJqH4KmTGUKFQS5p1ut6TsGSa18AL01rXlGFra4jMeXqKk5 5iXtxpcC/6LsVVrHbXkgZr3uBDLjVQxUm+WN35Zc= Received: from localhost.localdomain ([58.213.8.163]) by newxmesmtplogicsvrszc5-1.qq.com (NewEsmtp) with SMTP id 9241D2F1; Sun, 10 Mar 2024 20:36:36 +0800 X-QQ-mid: xmsmtpt1710074196tfumjurs7 Message-ID: X-QQ-XMAILINFO: OGvgEoGelOUdHurlUnToO+m81M24ckg367b+/dp254AnKIZvlDyeKxKrO/gMk8 b91c0QhLa5yZIEWaZh9v7Jna9+dCVnEERKBOevSHhyAy9cLOjQXANaCddOL8ZN8JxILN6U77Xru1 QVbA1f5m4AWaWg8VNZwSVf4ivmkfO2+5gFrX4jr+nV09E3FxBBQ4u6VwvyndyaZuDumDHRHT6Rnw QCIWlmKPLfcY+b+eCN+9AmfpYwTNJXGtA2Yhp4RnoYHAtaRmoukCnXxERtuft+UC7ZbLJ3pzPRQ6 COp9Lslu2Amk+GjOuzVWPvtG231gXP4JL2hDI0heS49SenvKdRC327Sg98reVIZyrVg2LRBHupc0 DFvu48aDs+avBWS04mdOfGt6WkTx8PRtaFy6m7dGfSKP4ZnRcjlcV56OxAkEcKNP2YG8iswWFA+k 1tZuo1RwGB+hz6ZhtLOTGGX9vcFa7L9aKebO+MUIz+8cu/drP55USYMxPcfkW5Hr+lQDTXq4YsBq 5GqXmIv/Xfo/VU9RBFtXUBLfJ+Qt6SxKX1cGt3cIklWdFi7sVq8ZWNw5rZB1ij1v47+TkROWTo6f wKU75smHb4x/vYy4FJlNoryWlDEPxkoax1fR5c+EP1nPVmvc51HdkdWEElJ1pECC7n326Y96POZd bqDEOAFojecnMyXy6LosOIKIptAJ1qneXQcadj1e2K7F6ZY/eRL3QCr0Cdm73Z0/dryH9AsDtDrq Qdv55k9Zvlfa35nM3i5x2V2bMEDLxUFanzM8fzw95w80MyBUG3sT1Cxdf9a2S+vh8xlGvuO6pm7P dazVStddgY89245lLr1oETDaWRMBSw+2Bu2toXkkv46iRNYFWNdjTnPNXiZPq5YZ4tg1zdBy5Q06 BuDznGL0Ph6M+JnKnRvILKKA8EsRsadp733EfZM9lV6Hgta3HhXQehONeCYBIaDOfGu478YKhVDX REoSyXMrLQQiGlT7pq0OCi/Qp8Jp75MKfJVlWI3N7P+7cFB3gkNwMn1P5xzlyGzIMaxrmNmIkOvL UyABIfAswCiZ4ta8uqFMo8/Rhy1aXie9A289yM+9yGHxykl5nQRri+B6oO0eMZBs33dCnR5A== X-QQ-XMRINFO: M/715EihBoGSf6IYSX1iLFg= From: linke li To: yanjun.zhu@linux.dev Cc: bmt@zurich.ibm.com, jgg@ziepe.ca, leon@kernel.org, lilinke99@qq.com, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org Subject: Re: [PATCH] RDMA/siw: Reuse value read using READ_ONCE instead of re-reading it Date: Sun, 10 Mar 2024 20:36:34 +0800 X-OQ-MSGID: <20240310123634.69189-1-lilinke99@qq.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) In-Reply-To: <2d508574-c2b8-489b-a26d-71b1c36961cf@linux.dev> References: <2d508574-c2b8-489b-a26d-71b1c36961cf@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit > In a complicated environment, for example, this function is called many > times at the same time and orqe->flags is changed at the same time, I am > not sure if this will introduce risks or not. I think one function of READ_ONCE is to read a valid value while the value may change concurrently. And there is a smp() above the READ_ONCE, which means that the READ_ONCE is well ordered. I think it is kind of safe here. > if you need to ensure the consistency of the flags throughout the function, not sure if the following is better or not. > if (((orqe_flags=READ_ONCE(orqe->flags))) & SIW_WQE_VALID) { This patch looks like exactly do the same things. The only difference I think is the code style. Thanks, Linke