Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp33638lql; Sun, 10 Mar 2024 12:19:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGiTPu6BhYnow1rEz6jVToDCv0IJ+Gnmye5hWENHArtO1O4I6v2kzauM+ZtowQX0GH96QTqUHBSs1dbyghrUxtPLi4nEtFLqCNMab4yA== X-Google-Smtp-Source: AGHT+IGPONMve6dQK5CkcHHQCmpDc0uNbSfNxfz3fpB+4s8lsOCo3+CAZd+GrREUmzDunH4ZNfqr X-Received: by 2002:a17:90a:6986:b0:29b:a1b9:50d4 with SMTP id s6-20020a17090a698600b0029ba1b950d4mr2865438pjj.45.1710098363544; Sun, 10 Mar 2024 12:19:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710098363; cv=pass; d=google.com; s=arc-20160816; b=0rojCgK1+Tv4EYFIFhh3In4foJpjWxhQNBS+6rXY39n4dLPCaS19N51MazE2e6aOKU NMwub5Lo81l9jWM5p/UplUl08gwzFDjiAX6/WCqz5E7yfD4E+ROsywhWEoKYD8y0FiIl Aa5DOAPvcCJE4/xLx1GygBN31TkwejdZnNyrmKKYURhRMARr3Ez7IBoQhxw+I+82qgsw V10csauRr7a6Qx2UXQfV8u8cXrFezpOyzKaCz/WGSA08uG4g69H1/hSeWDEvbTlYmn2m O4KVvHqapxgIECBKCRoMatfSJtQMF2tINkiwECWjIjlSQuIH30o34oQVCCUoHLQ1yTiZ CgfQ== 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:dkim-signature; bh=vEioFK4BXE/VD41IBgnIDDIJDOJxCchRrXThDUfkbzY=; fh=HLo0AAMo83BV5zY+dvYCpl8RaUhI1YKkvmKdzHKqObY=; b=lhBrubIpmkI20JfAG7tICiaXcEeb3tEK83/hgyS2GsHRmIJGxdqXBah4G5wrzHu8t1 loxcjaW9ITwd5ADAwfP4+COTO7VQHAm73FIao/kWC2vgS5/0+gtaHztiPxDhCIXTXqaY zXVSW3uI44bVzmkImpsdrc9I3LymWpnOzI0s0gELh/Uda7E365Tqga9Ke38cwCexikBg VmpSwwzvDzgBGmI4Z3kz93BOCDf2BJLr8fD+W3AgtFnCm5yYcsCFo0fisEwC64oW/kIE 1RlqBnqHEstHrI1fWpaJqaQCL83LrVFrqJN2zGydU1XfdLL3FrBxMcf/MzJurnnqyqEU y0Yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=USuG65Iv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-98306-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98306-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l9-20020a17090add8900b0029b8f21e10dsi7075941pjv.126.2024.03.10.12.19.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Mar 2024 12:19:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-98306-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=USuG65Iv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-98306-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-98306-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3FCC328174F for ; Sun, 10 Mar 2024 19:19:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9811139FF3; Sun, 10 Mar 2024 19:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="USuG65Iv" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 BF8823065B; Sun, 10 Mar 2024 19:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710098354; cv=none; b=mFW9OZ2uvJ0hjVzRbvLQpx567KTu6+fhZQ+DWJLtU9Qgk3D2Rg3wcl7TML5D3DI742+hyxOFcpSK+AMNlXpjhczmuD5UXMBGZlTix5brfimP7jXAQIxtF5T6o9XyYi98UasQJmMVBg1jUw665YQZwKZPvGrY28zJjgBI0xIV+7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710098354; c=relaxed/simple; bh=vEioFK4BXE/VD41IBgnIDDIJDOJxCchRrXThDUfkbzY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Nvg+cn8VRo7KQriS6I+iidSrxCJ17W6kZEr03TqOs3zqtVVk2+JBtmbJfNYyspkZ5tkoBIDWG15GjdkPoz1jhCmW8kDz/H1bipg84xZaUVziraLtb/cO9ZoL9VbKhkgMMk0HIa9VaK4fb50tDx6cc34kAKJnPX2ODE4By1rE8Mk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=USuG65Iv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23B5AC433F1; Sun, 10 Mar 2024 19:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710098354; bh=vEioFK4BXE/VD41IBgnIDDIJDOJxCchRrXThDUfkbzY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=USuG65IvMp3kWPIq9Oxq2ufhBtzrZLxAbUz6Jlt82E5PgCnYqm89oM4q/4btXtXlc umoq1KPIMDwTdiiUqzmr4QZr3Sf/U4yYP5GSRpmtQPv8aB7pUTdr3xvIa0SQ05kxt6 8drSNT2bwjiyYjluKkqPMDKFhsk2Bqs6YsG6wnrMiRi+oFAuNJZfFP9jI0ogWLBHx3 /EjcLdEnknaVR6FspJGx+olpom5OpjQokzGV+OAXppywsNIW6MOuNzBR/EccRqV5Cy aQXZ9+DbeOFdHogObUJkxijd6sZ0VxNxcyB1D1GwUMxE3H6mqJIRzdWajD4QXD2MlV wRLb4KuaQLNRA== Date: Sun, 10 Mar 2024 21:19:10 +0200 From: Leon Romanovsky To: linke li Cc: bmt@zurich.ibm.com, jgg@ziepe.ca, 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 Message-ID: <20240310191910.GG12921@unreal> References: <20240310113306.GF12921@unreal> 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 Sun, Mar 10, 2024 at 08:15:25PM +0800, linke li wrote: > I want to emphasize that if the value of orqe->flags has changed by the > time of the second read, the value read will not satisfy the if condition, > causing inconsistency. Given that there is already a READ_ONCE. If value can change between subsequent reads, then you need to use locks to make sure that it doesn't happen. Using READ_ONCE() doesn't solve the concurrency issue, but makes sure that compiler doesn't reorder reads and writes. Thanks