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=-10.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 90F1CC433E0 for ; Wed, 15 Jul 2020 06:55:39 +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 5B07E2067D for ; Wed, 15 Jul 2020 06:55:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ak7J4il3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F7ElWs/X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B07E2067D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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=JX3C1ovtm/IFCstMRE4eag2lDxk4HrpaAUPuecjFVh4=; b=Ak7J4il3wNUY4zQjjXlqT2mZ9 qsnkDI7SWWJX8mJzob6MnFixZobEJb92KM9D25z/LKGv7G25VSoTP7rYCqFtKmd++X8IDYljZ4lt8 FDQmu/hBx2zOTPo9fuMf8KGjl3RrcQlnYeVJnupIR7vPAl4sQOZ7goZTuXMbTv1VYFoHef/IzFVvs K31vje/nZqjwTF/OCjjTlWD4ZiVwU9sxAjyzp7aEfJecmqNEa8NXEaIqKaeeFPf+QEa0Z+a9RgqyN hrS6EgfGNPivK+KWaoPRHup37Z8uPh44yB2LBBLWaQEpc94+1ZlaAjoAugSPYUn3ZLHWxExnSUC5E wIvqET+cA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvbJ1-0005Uc-E1; Wed, 15 Jul 2020 06:54:15 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvbIy-0005TY-Jl for linux-arm-kernel@lists.infradead.org; Wed, 15 Jul 2020 06:54:13 +0000 Received: by mail-pl1-x642.google.com with SMTP id x9so2004150plr.2 for ; Tue, 14 Jul 2020 23:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=17b8hbCm8iAaa62tZL0iIJtXNS59CDTl98QfnYxmWkw=; b=F7ElWs/XlZa/5vdvS+xKFxXa36pRykGC5qHshchJ6QlDdy5Y27EQaIMd3fm03nJPUV EFUYxxes6TTM+vfRciWbnsoPbZSnivAuHxlW0+tR0/oUtIJ055C3MoHHAWCgf+3lgeP5 fWIZuILg4sEhAlmMnvE3PY00q4pMilg7GnbId7UEFgsqcS+6LZaeCw+mNnHcWMfvjd7q KUGzx/xA39ZHjJgjCT0pWLPIJMJBXfmYIWcfvMkbnR7lHphY0moIT34HmnC+Mx6fLUO0 d4F1dds1IgkeUzdFlwp/8fOP9A0z+IwWT8ClBYQUxtV6eMrUhpZo3d7QANUtJoq5RFF0 y6PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=17b8hbCm8iAaa62tZL0iIJtXNS59CDTl98QfnYxmWkw=; b=KgKtRl/yJmEyVMB12KpUis7ZLO+WpE2Q1T8EG9cEmTB09N7KPejq1GRCYazBObxl1A 3nUiG6f6EFxZ36gN0AwMqyhfsWeMdXgqNBuo1UEIfKac3UrRLC9OW1CNyW6+ufwaBnyV cRJqk+F5Cwbj3N+ZrzUXZSN/MlWADJz6N0oRSvA8KmW5HDOmKveaIxlM3AN/tdZDZpmt /yqDukYJjw2NK7R6e3vDCWg2SSjfBi/7ycbOmD7fmpQhyxfcd7oey9t/BU6XPiNn77XE e5oJu94qWPgL+2Lh/LPhqAqK22+ClsGdUxnZndNGQw+TDTfM2UlVaWYzQxHNFvwXgxi5 LtOg== X-Gm-Message-State: AOAM533Okq3KdTbrDHohlSmfXC1infTmCKOCb3+8eoxsmANjxUoMwVHR 87fFxosAdzcHc2ugUcB3pxsopg== X-Google-Smtp-Source: ABdhPJwJkrF75tMhWncnzHm12LsWV+Bu99s1vPbepGHU5q0a50Bukf/pDGebojbnpubXJ12l6YMkpQ== X-Received: by 2002:a17:902:8490:: with SMTP id c16mr6971459plo.153.1594796050515; Tue, 14 Jul 2020 23:54:10 -0700 (PDT) Received: from leoy-ThinkPad-X240s ([2600:3c01::f03c:91ff:fe8a:bb03]) by smtp.gmail.com with ESMTPSA id k71sm1136416pje.33.2020.07.14.23.54.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jul 2020 23:54:09 -0700 (PDT) Date: Wed, 15 Jul 2020 14:54:07 +0800 From: Leo Yan To: "Ahmed S. Darwish" Subject: Re: [PATCH v2 1/6] sched_clock: Expose struct clock_read_data Message-ID: <20200715065407.GB19269@leoy-ThinkPad-X240s> References: <20200715020512.20991-1-leo.yan@linaro.org> <20200715020512.20991-2-leo.yan@linaro.org> <20200715055650.GB225020@debian-buster-darwi.lab.linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200715055650.GB225020@debian-buster-darwi.lab.linutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200715_025412_780009_9AB9B21B X-CRM114-Status: GOOD ( 17.94 ) 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 , Peter Zijlstra , Jiri Olsa , Adrian Hunter , Arnaldo Carvalho de Melo , linux-kernel@vger.kernel.org, Paul Cercueil , Alexander Shishkin , Ingo Molnar , Catalin Marinas , 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 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(). Good point. To be honest, I think myself cannot give a good judgement for memory barrier related thing :) I read a bit the document for the latch technique [1], comparing to raw_read_seqcount_latch(), the function raw_read_seqcount() contains smp_rmb(), IIUC, the *read* memory barrier is used to support for kcsan. The usage for smp_rmb() and kcsan flow is like below: sched_clock_read_begin() `-> raw_read_seqcount() `-> smp_rmb() `-> kcsan_atomic_next(KCSAN_SEQLOCK_REGION_MAX) sched_clock_read_retry() `-> read_seqcount_retry() `-> smp_rmb() `-> kcsan_atomic_next(0) So the question is: should we support kcsan or not in this flow? > 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. I don't think we need pair with smp_wmb(), since it's mainly related with data reading, so a smp_rmb() would be sufficient [2]. Thanks, Leo [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/seqlock.h?h=v5.8-rc5#n321 [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/seqlock.h?h=v5.8-rc5#n373 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel