From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B26EDC433F1 for ; Wed, 15 Jul 2020 08:15:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 353012067D for ; Wed, 15 Jul 2020 08:15:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="M9zfAwe4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729635AbgGOIPD (ORCPT ); Wed, 15 Jul 2020 04:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726201AbgGOIPD (ORCPT ); Wed, 15 Jul 2020 04:15:03 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 464C5C061755 for ; Wed, 15 Jul 2020 01:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K/b2gzLoXUAw2gDUZSlQlfPbeMDcCTrXkeWFcHteJ9E=; b=M9zfAwe4IWuymtjYzyffcH5NBQ Tc8CS5HMRap2tQUJ31MPk2PAxoJU/DiwZqE4e3lMt8ftk2EgUJIHMe19uAijoO0gGvl9ejZAIaU0C tZ/pUHF/F+RKqprtARg6n8L7r9TQ36tEYIMayX3epN9Kd04gBDdl34FK948FsnTpKllmc7r5aMe0V yzAdFgpHx5kkoMG0YzSeNyVW6tiADJslaKyi6G3DO3l3LSJcXT87WllSl4plJC3ZAF9+ArM0la2OK /bdvV+aBgm5CqxSpkpuQcf6aIplFccGngs2lWjRJySCUxk2sAeqX0UbDy+TI4vOF+FCT7qZPlfEmi KR6W9CwA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvcYv-0005kx-Uh; Wed, 15 Jul 2020 08:14:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 22DB2300130; Wed, 15 Jul 2020 10:14:43 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0DC1823648704; Wed, 15 Jul 2020 10:14:43 +0200 (CEST) Date: Wed, 15 Jul 2020 10:14:43 +0200 From: peterz@infradead.org To: "Ahmed S. Darwish" Cc: Leo Yan , Will Deacon , Mark Rutland , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Catalin Marinas , Thomas Gleixner , Paul Cercueil , "Ben Dooks (Codethink)" , Adrian Hunter , Kan Liang , jogness@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/6] sched_clock: Expose struct clock_read_data Message-ID: <20200715081443.GB43129@hirez.programming.kicks-ass.net> References: <20200715020512.20991-1-leo.yan@linaro.org> <20200715020512.20991-2-leo.yan@linaro.org> <20200715055650.GB225020@debian-buster-darwi.lab.linutronix.de> <20200715081222.GB10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200715081222.GB10769@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 10:12:22AM +0200, Peter Zijlstra wrote: > On Wed, Jul 15, 2020 at 07:56:50AM +0200, Ahmed S. Darwish wrote: > > On Wed, Jul 15, 2020 at 10:05:07AM +0800, Leo Yan wrote: > > > From: Peter Zijlstra > > > > > ... > > > > > > Provide struct clock_read_data and two (seqcount) helpers so that > > > architectures (arm64 in specific) can expose the numbers to userspace. > > > > > ... > > > > > > +struct clock_read_data *sched_clock_read_begin(unsigned int *seq) > > > +{ > > > + *seq = raw_read_seqcount(&cd.seq); > > > + return cd.read_data + (*seq & 1); > > > +} > > > + > > ... > > > > Hmm, this seqcount_t is actually a latch seqcount. I know the original > > code also used raw_read_seqcount(), but while at it, let's use the > > proper read API for seqcount_t latchers: raw_read_seqcount_latch(). > > > > raw_read_seqcount_latch() has no read memory barrier though, and a > > suspicious claim that READ_ONCE() pairs with an smp_wmb() (??). But if > > its implementation is wrong, let's fix it there instead. > > It's supposed to be a dependent load, so READ_ONCE() is sufficient. > Except, of course, the C standard has other ideas, so a compiler is > allowed to wreck that, but they mostly don't :-) Also see: https://lkml.kernel.org/r/20200625085745.GD117543@hirez.programming.kicks-ass.net From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C522C433EA for ; Wed, 15 Jul 2020 08:47:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 202F42065D for ; Wed, 15 Jul 2020 08:47:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AZwPzCWz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="M9zfAwe4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 202F42065D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GWUX0+t12ZZAOVjTKC2B250/mXNcvT4il2Fmar+7RFg=; b=AZwPzCWz6mGqsO/KsRqMtrYZL yGNDqtdcfWliGPi7oLlUVOZvLEH0P4N+kXpsx9J6TE36DWPkOWKPXMkexcI9h6/t+liA6obUef2fe FtSG/Eg/7q/wJjj5eHH6qiVAH66nYeNmmUsn7szY68U5JAcf+uiRcejEd5RTWubQUuMXTXgwod4Qj eyrRiruyiq0fvBOqBFTeOFSQraHPws//ORulylsA3vGbPHpJsuwialz/sFJa4zEx/qZrFx02ReDvY XZGo7EopdbbJrvz2sa75lH4XzBqwn5p753r6vDl9CVj1O7AjJ3lfPAotmfbcd2GZBWbgdHqyV6Iu7 dhw91ebUA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvcZ1-00013r-2X; Wed, 15 Jul 2020 08:14:51 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvcYz-00013Y-DP for linux-arm-kernel@merlin.infradead.org; Wed, 15 Jul 2020 08:14:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=K/b2gzLoXUAw2gDUZSlQlfPbeMDcCTrXkeWFcHteJ9E=; b=M9zfAwe4IWuymtjYzyffcH5NBQ Tc8CS5HMRap2tQUJ31MPk2PAxoJU/DiwZqE4e3lMt8ftk2EgUJIHMe19uAijoO0gGvl9ejZAIaU0C tZ/pUHF/F+RKqprtARg6n8L7r9TQ36tEYIMayX3epN9Kd04gBDdl34FK948FsnTpKllmc7r5aMe0V yzAdFgpHx5kkoMG0YzSeNyVW6tiADJslaKyi6G3DO3l3LSJcXT87WllSl4plJC3ZAF9+ArM0la2OK /bdvV+aBgm5CqxSpkpuQcf6aIplFccGngs2lWjRJySCUxk2sAeqX0UbDy+TI4vOF+FCT7qZPlfEmi KR6W9CwA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvcYv-0005kx-Uh; Wed, 15 Jul 2020 08:14:46 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 22DB2300130; Wed, 15 Jul 2020 10:14:43 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 0DC1823648704; Wed, 15 Jul 2020 10:14:43 +0200 (CEST) Date: Wed, 15 Jul 2020 10:14:43 +0200 From: peterz@infradead.org To: "Ahmed S. Darwish" Subject: Re: [PATCH v2 1/6] sched_clock: Expose struct clock_read_data Message-ID: <20200715081443.GB43129@hirez.programming.kicks-ass.net> References: <20200715020512.20991-1-leo.yan@linaro.org> <20200715020512.20991-2-leo.yan@linaro.org> <20200715055650.GB225020@debian-buster-darwi.lab.linutronix.de> <20200715081222.GB10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200715081222.GB10769@hirez.programming.kicks-ass.net> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Paul Cercueil , Ingo Molnar , Leo Yan , Namhyung Kim , Thomas Gleixner , jogness@linutronix.de, Will Deacon , "Ben Dooks \(Codethink\)" , linux-arm-kernel@lists.infradead.org, Kan Liang Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 15, 2020 at 10:12:22AM +0200, Peter Zijlstra wrote: > On Wed, Jul 15, 2020 at 07:56:50AM +0200, Ahmed S. Darwish wrote: > > On Wed, Jul 15, 2020 at 10:05:07AM +0800, Leo Yan wrote: > > > From: Peter Zijlstra > > > > > ... > > > > > > Provide struct clock_read_data and two (seqcount) helpers so that > > > architectures (arm64 in specific) can expose the numbers to userspace. > > > > > ... > > > > > > +struct clock_read_data *sched_clock_read_begin(unsigned int *seq) > > > +{ > > > + *seq = raw_read_seqcount(&cd.seq); > > > + return cd.read_data + (*seq & 1); > > > +} > > > + > > ... > > > > Hmm, this seqcount_t is actually a latch seqcount. I know the original > > code also used raw_read_seqcount(), but while at it, let's use the > > proper read API for seqcount_t latchers: raw_read_seqcount_latch(). > > > > raw_read_seqcount_latch() has no read memory barrier though, and a > > suspicious claim that READ_ONCE() pairs with an smp_wmb() (??). But if > > its implementation is wrong, let's fix it there instead. > > It's supposed to be a dependent load, so READ_ONCE() is sufficient. > Except, of course, the C standard has other ideas, so a compiler is > allowed to wreck that, but they mostly don't :-) Also see: https://lkml.kernel.org/r/20200625085745.GD117543@hirez.programming.kicks-ass.net _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel