Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3379912pxb; Mon, 17 Jan 2022 19:06:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxnj02LVsIIo4yuDJAYvpmu64sCAyw9otQIjP9j14jnn1OThwKY44rc7QGz8ttPqv/0VhWs X-Received: by 2002:a17:90a:c698:: with SMTP id n24mr20333339pjt.188.1642475178965; Mon, 17 Jan 2022 19:06:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642475178; cv=none; d=google.com; s=arc-20160816; b=oRmcJHV7NejRrKZ+wRMoNkzDPLg2GbXPHFYcsdiRGsaus3LUjA9abwLcKJgSJiW60g 9yl3dCAsFZGo5+tRslTYij13WiHCEgg8WL0+JvYim7Pd2iapcWY6xtaV++ilNRv5Cnhy Rd/z+2TQ+qWX2wgEWDP4VSjtKuKCBlU6/6smyB4QKrNb3ofVDuBad1yUlOSX4Ocy9QM9 IXMxzLZFJqKOPuivdr6IzGtFgeesPsDzVZf2mxBjDfLYjjKifvTNSYQfGHR3ExsGZzqG RPQvH4857rKy5GSvfWoqO+EZ9VQh3AfFGHJ0eNPSuS7wao1J1TOW2uLLODUCAZE+3w8/ KFpg== 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:dkim-signature:date; bh=jgK5Clodoz0vuYNJCwWgm6WXu1kx5wRywemzPx+NBvw=; b=fB/9q7O9XHQbCA7BDonFAoW6g7sZ23wpXfzd6keQY+LjQoUpsMP6ATpDihDB+MSgpA LR/fyZi5hxzqhb1LCtV0r9e6UouHALtJs+k039ngCt5Bjrxhs1aG6IsBcDuN9aVosRP7 yYmoQwatvz+SmBmH98P5Ips2pz+lziCcURACoLcsF0hclsFf2e1rmeAakM1B8yAvkcoU VC+vOOy2qNOF8l4enWCqkbg/6SqJ5gT4fSLpk0xHj4Lza5HIUt5PD2UWoSCwwoHviFA9 4IAalxrZRV14BMUk7i9iw5iWAW+ShaXLBo/fyGML+Zsobqu+UG+q45/IdfUKURfNukNZ Du2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Eto2CZBY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si17904421pfc.69.2022.01.17.19.06.07; Mon, 17 Jan 2022 19:06:18 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b=Eto2CZBY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243813AbiAQXpB (ORCPT + 99 others); Mon, 17 Jan 2022 18:45:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235399AbiAQXpA (ORCPT ); Mon, 17 Jan 2022 18:45:00 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF498C061574 for ; Mon, 17 Jan 2022 15:44:59 -0800 (PST) Date: Tue, 18 Jan 2022 07:44:54 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1642463097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=jgK5Clodoz0vuYNJCwWgm6WXu1kx5wRywemzPx+NBvw=; b=Eto2CZBYlPtO0ItAbAhPRM5S05rZYlKeNE102wD+UkjIpM6qDqyYRioOezqeD+WwRoqGx7 RUM91WZnGnC+kQhu51uhISO4rPdGJf9oZ7M75tXID42DJRjPz6etLijbeCD4f8HoB9Dazg Ahgj+B0IP5MJyC+/o4tHrLTCjL/0aQ4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Zhou To: Vincent Donnefort 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, Tao Zhou 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: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 17, 2022 at 07:42:04PM +0000, Vincent Donnefort wrote: > [...] > > > > +/* > > > + * 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. Sorry for the noise, I'm wrong here. > > > > > > > > > Thanks, > > Tao