Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp845204pxb; Fri, 22 Apr 2022 12:25:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyozMPchtWRzAtAk1Nlzt5TZyC6slOr9LtAn9zq3VmBMYUas+7rBx7r6SuLsck2k1fAEE9c X-Received: by 2002:a17:902:aa81:b0:158:ae65:b926 with SMTP id d1-20020a170902aa8100b00158ae65b926mr5959203plr.41.1650655556248; Fri, 22 Apr 2022 12:25:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650655556; cv=none; d=google.com; s=arc-20160816; b=ooGpEDJOcmkRGbfiLPcJGCqgPrEjSt69srdR5h9Rrj0Ver4bKRKEl23ZbPh/uONqFX rfHa+INffr9mvaSTyZx+fYAgfAkQYy+DU7kR/OWxNPQaP/NckHTAyBzP8Ygx+dJdSlht 1q6tf0dvDlVHeZAPfJFkWHbNv/kLbfAQHTdrcdEHRymgxmPsqfM4fT6jVMvHo5kfddTT Bede34sph68o1k0z/Ubfq96Fb0xmHGxCJcc7okg+Lprns0eoY0Cc/auKZSPfzeQlvacQ 36SRD6QJLncr78HXtrLfgHuanNIKfbuUVXcVEktgoRIPc15QMZrXzGO8tBLK4Brnp9ur SAyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=LA5+uHQnKH/tK0lj7h5XTYTEZudwmuTOM1O8nik4gU0=; b=lwJ015tH8FKVqqoAS9ElM/mYUwebjCRIzpq1Pvh908D90JKiTTOIhr98QCJugeQxd5 jBCIAvTeiGSgx9QiWbOhEAzaeWIi2EnY27v6KCMrmIxLbzFri9y2LD3pJHGhtAAYu92t 4QAnQtdc+euuwgti3NtoItAqy2Zo3A+maWQL/0zuyYNGvVne+HYzMpVcWqtvxMHMRAga Nr8aUnXOgkKwBZ/BA3XMqwCIaGGGd3k//ba2pEk+pM8qUmZrffgBqK7j0gQRGiwTrzwu hVcTOA25ZZJ1wphC25FatAL0zUDt63jkWKGYBHtbUnTpu6H9+vgqwkwoXMuKaXJRo2HN A17g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j2-20020a056a00234200b0050605f7112bsi10252872pfj.130.2022.04.22.12.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 12:25:56 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 28D5A1299CA; Fri, 22 Apr 2022 11:37:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1447021AbiDVLNf (ORCPT + 99 others); Fri, 22 Apr 2022 07:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446686AbiDVLNd (ORCPT ); Fri, 22 Apr 2022 07:13:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E44EB53A77 for ; Fri, 22 Apr 2022 04:10:40 -0700 (PDT) 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 A9CAE1576; Fri, 22 Apr 2022 04:10:40 -0700 (PDT) Received: from [10.57.44.4] (unknown [10.57.44.4]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB0D13F73B; Fri, 22 Apr 2022 04:10:38 -0700 (PDT) Message-ID: <5033835b-195f-2712-d621-c3c06cc61a08@arm.com> Date: Fri, 22 Apr 2022 12:10:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v4 1/7] sched/fair: Provide u64 read for 32-bits arch helper Content-Language: en-US To: Tao Zhou Cc: peterz@infradead.org, mingo@redhat.com, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, dietmar.eggemann@arm.com, morten.rasmussen@arm.com, chris.redpath@arm.com, qperret@google.com References: <20220412134220.1588482-1-vincent.donnefort@arm.com> <20220412134220.1588482-2-vincent.donnefort@arm.com> From: Vincent Donnefort In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [...] >> +#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; \ > > `copy = __val;` should be `copy = var`. > > If var equal to val we do not need to do store. Check this condition > in the above macro to avoid a redundant store. > > if (var != __val) > var = __val; Judging by the users of this macro, var = val is very much unlikely to happen. Also, I don't think we want to waste a if here. [...]