Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp310839ybh; Wed, 15 Jul 2020 02:34:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwy8GDQ88vD/3Z57z9REFfX0zGLT3+JxrfjW7SNU34IfBIB+veFsNBF0zZoC/MG7oFu8Pr X-Received: by 2002:aa7:cdca:: with SMTP id h10mr8871808edw.285.1594805686340; Wed, 15 Jul 2020 02:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594805686; cv=none; d=google.com; s=arc-20160816; b=Fx71sLy5hbg7V47X7V4SzG3YA3yG2mzcOq9C0GNeZIOpR8BA+sscbcTk1UUa3kHFbV NtFt16Ezi9rXLGp/aWgdUxyhC8VUQZhT+vzLGtf+iZ8jCU0yogwusCfmryfNcMwn37wR 7mIl11Mhpjc6rgXtK2RAOf5+7/iDirAldxFn6CKe9v74G/+hbwp//Cy+DVIaMv/BKagX 3tEkVAwPE0z4poLeG2tcJwWhumJ9eq9p9pix4S5Bi1Jt3zZbLnU8e+fxYLw4jpL1kMWB KZ1VNeFpLJ34KUeJKCFOU7GiHYFK09oK7q66fkVOuDJGYk6GiQCDH0trbaGoZYOfnaO2 JivQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from :dkim-signature:dkim-signature:date; bh=nVewUEkE+vEgqvpSZaR+rHv9rvICaRBJ6Hc/Y4Gfv04=; b=S0MBl/C/1eXoaRsYC3uqMcTnrJXnCxFm+/bxuJZiyILIshHCtzboBGILSGsiJX5t61 emlHydGnVvbTELQuEVjT/2axUktZGjFQuEb1s3WUKixmHLSavqfoF4kTfeyLdpMDuW+G isqoZ6WmxFiC+9BpZh+XJnPckkYv5vNS8tQOSvknCSasX4nY+h6KedtHPkTU7NVhgLx3 fS49rprSmSlb3FRZqYP0XsgqdqLl43SGoNf55TKx3gsY+NOwVVrqUarGmlVvXfg9NKcj KDlOw9XB9H19S+3rDpWYDaqDy8WfzQ1uwWg1W5TBSWudHHNl7LYTK7i4sUQRYVliqQ4w VAjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iRcqbhoo; dkim=neutral (no key) header.i=@vger.kernel.org; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e13si972470edn.432.2020.07.15.02.34.22; Wed, 15 Jul 2020 02:34:46 -0700 (PDT) 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=@linutronix.de header.s=2020 header.b=iRcqbhoo; dkim=neutral (no key) header.i=@vger.kernel.org; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730641AbgGOJXv (ORCPT + 99 others); Wed, 15 Jul 2020 05:23:51 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49896 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729672AbgGOJXt (ORCPT ); Wed, 15 Jul 2020 05:23:49 -0400 Date: Wed, 15 Jul 2020 11:23:45 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1594805027; 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=nVewUEkE+vEgqvpSZaR+rHv9rvICaRBJ6Hc/Y4Gfv04=; b=iRcqbhooQLbNQYs0t6EgUxItIJxhtP3b8s8woTQvVERuHgCybkfAetFUIzEPA2qoDta3XB hFGfqNFUsu3hRGjuhAphrutMLv6knCYWsKZM43Mb3AYZHtaVSpWCf9rN/cvu+IehElTs6w w7jkCecMreibSzUAgIGJ2NVV3RoeZlRT8WDBS9NXru7YSKwOWLV7KNvaQtm77bvWFv6rIw Tmf674X1SQV4U6ysvZST8Y6X5/9VyE6jietFR2lRK9R/Fnv4Xy0+oqlSKZzC+OAamfCMpL S6AUQbGmozxbFDdI/qPyin9SrTMah7JNfk2r2V4MAlBnzEXS+gnSSHhpJVaY6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1594805027; 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=nVewUEkE+vEgqvpSZaR+rHv9rvICaRBJ6Hc/Y4Gfv04=; b=XvgIcEpx3pM+hW2dYCP5H7sBCeEboYeXT2fgmDCQ3cwOqyeGO6r/T+NNo/0VBxbVQMqjLC G1W0Dhzx1t3IK1CQ== From: "Ahmed S. Darwish" To: peterz@infradead.org 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: <20200715092345.GA231464@debian-buster-darwi.lab.linutronix.de> 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> <20200715081443.GB43129@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200715081443.GB43129@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:14:43AM +0200, peterz@infradead.org wrote: > 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 Oh, spot on. Can we then please replace the raw_read_seqcount(), in the original patch which started this discussion, with raw_read_seqcount_latch()? I see that you already did something similar for timekeeping.c: 7fc26327b756 ("seqlock: Introduce raw_read_seqcount_latch()"). Confession time: I have an internal patch series which introduces seqcount_latch_t. Having a standardized set of accessors for the seqcount latch read and write paths will make everything much more streamlined :-) Thanks, -- Ahmed S. Darwish Linutronix GmbH