Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3375156pxb; Mon, 17 Jan 2022 18:59:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxRrZIEF32SgdMEd1x8QZOjpEuku9sz5jL2Hb/huqY4c7dnOueCkA1nv31Z7uuhDHvWuBh/ X-Received: by 2002:a17:90b:1a84:: with SMTP id ng4mr6962346pjb.237.1642474778026; Mon, 17 Jan 2022 18:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642474778; cv=none; d=google.com; s=arc-20160816; b=qByIBj2HuvOBvcXCSyYzc5iATc/Okiw46j8qJAQkEDjMZo3Ou/96OxI7XXEOMqitDc Oi/4//8fN/hdo5GvUwv4GJexilqz9wX+ZQMZCOmQVg17sLBdwFJArpWiCccjW9uErDrm S6N2R0wGczLYncuXOs3CoaRMAHICsQ28XeMLD0OKZzq3tU6Q0ZICpX8u4Pb62D9omTbc BpBk30lNgghRATMf9y2VaMS2rSiwtDiNFmEf0VM2D2Kx7U2d3arQfZt+W0/EriAsSWBR 9/iu40tNgjyVQohweH7+Vf7thCWstBdQ/6Vs9UhpLoUt1pAt9pd6puPReQDTkqXQU66k 2ktA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=oFeOoQH4Vj+MFWBJ4y/Sl9kptVmSyx9QAY4/v7g1kCs=; b=jHwQvKl6CYkWpLSiMVvvqsEpiBrEwMJq0GWe3e6Z4N8F8l6TNvyILCfpy+6JGSWgr1 wayjl8jm/LAhli2MkKcdiqwjaSirA2LpdH0JYkQ+26l+sKwzPNC9jTze1M+rUS+s8UzR M3zwY4bttPg0H6QOXskqzcAtM0sSNVEkzQwASyNULjJ3NKWZIqNUZOll4gD2w4WCyAQV kUrgqK+BGh5lgsbFiMEEk+wMyj/6fI15N2R2I6UFv702EO0sMF+RHzxy/bzmkdfUbPiD agt4fUORNNwwUEl15wuR2FWDMFSW0qc3h9ZGFZ0938dI9AZuXLrnh5laWN0LXObnTpic KAdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j37si4786720pgl.665.2022.01.17.18.59.26; Mon, 17 Jan 2022 18:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241702AbiAQTmK (ORCPT + 99 others); Mon, 17 Jan 2022 14:42:10 -0500 Received: from foss.arm.com ([217.140.110.172]:35784 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231558AbiAQTmJ (ORCPT ); Mon, 17 Jan 2022 14:42:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A85916D; Mon, 17 Jan 2022 11:42:08 -0800 (PST) Received: from FVFF7649Q05P (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DE0E53F774; Mon, 17 Jan 2022 11:42:06 -0800 (PST) Date: Mon, 17 Jan 2022 19:42:04 +0000 From: Vincent Donnefort To: Tao Zhou Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, valentin.schneider@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, qperret@google.com, lukasz.luba@arm.com Subject: Re: [PATCH v2 1/7] sched/fair: Provide u64 read for 32-bits arch helper Message-ID: References: <20220112161230.836326-1-vincent.donnefort@arm.com> <20220112161230.836326-2-vincent.donnefort@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] > > +/* > > + * u64_u32_load/u64_u32_store > > + * > > + * Use a copy of a u64 value to protect against data race. This is only > > + * applicable for 32-bits architectures. > > + */ > > +#ifdef CONFIG_64BIT > > +# define u64_u32_load_copy(var, copy) var > > +# define u64_u32_store_copy(var, copy, val) (var = val) > > +#else > > +# define u64_u32_load_copy(var, copy) \ > > +({ \ > > + u64 __val, __val_copy; \ > > + do { \ > > + __val_copy = copy; \ > > + /* \ > > + * paired with u64_u32_store, ordering access \ > > + * to var and copy. \ > > + */ \ > > + smp_rmb(); \ > > + __val = var; \ > > + } while (__val != __val_copy); \ > > + __val; \ > > +}) > > +# define u64_u32_store_copy(var, copy, val) \ > > +do { \ > > + typeof(val) __val = (val); \ > > + var = __val; \ > > + /* \ > > + * paired with u64_u32_load, ordering access to var and \ > > + * copy. \ > > + */ \ > > + smp_wmb(); \ > > + copy = __val; \ > > +} while (0) > > Code stay there some time from me. Just from my crude review; > The above macro need a variable to load @var temporarily for > later store; that means the @copy value is from @var not @val. > > # define u64_u32_store_copy(var, copy, val) \ > do { \ > typeof(val) __val = (val), __var = (var); \ > var = __val; \ > /* \ > * paired with u64_u32_load, ordering access to var and \ > * copy. \ > */ \ > smp_wmb(); \ > copy = __var; \ > } while (0) Hi Tao, __var would then contain the previous value of @var, wouldn't it? We need both @var and @copy to be equal to @val. > > > > Thanks, > Tao