Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6369672rwl; Mon, 9 Jan 2023 07:33:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXskYqNSZbd10R7SsJRsQvoybd8wAwOuwzwE3qBqpEGqjQ7dxXJxLuptEKY2/R7SJLYOwo9R X-Received: by 2002:a05:6a21:3290:b0:af:757d:a8b0 with SMTP id yt16-20020a056a21329000b000af757da8b0mr94211988pzb.9.1673278398629; Mon, 09 Jan 2023 07:33:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673278398; cv=none; d=google.com; s=arc-20160816; b=Sut+kyxPvMlDwigdb9saXbF0dI7G+Nykjo1MRhyuchFR7gQ1W7/tXHH4wf9qdrgB06 LvPFFTSojTIcCFiSmqttkm2SOMeWq1fxK8lBaVnQ5JdPOXKkHIsRo0i2FCH97QUO4kV/ INZOI6lEDv+YGB1pAr1Z2kMrn86bCwihN6yqtnLA2ozaiymDHK3VnigxchDsqQoEaecK Sz2/U00LRnvH2KbEWQgWMQYGsfdXkkeMK+Lnta2DGNA5hD6DVe3KgCP5/TOcoHOLFUBw xnB2Ck/1H/XK1DSQ0y09Uoz0B4B/mYR92+vfSYY4Dq/OXKkwo2BNkYSRX4HRgWpwbhl+ hr9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=KoiFHa3OYaUadlpj4XIDCoE4VEmQuSerBU1ZGv9DnLo=; b=XhqwH60vt2efVLuCo4+7FehVjH0kNAOZMmAHIY7eXCy3m8yQdQoaUGMgPVb/bhr+t9 q8VkvU0Z+c5XUWIvmGaEa4h4x/dadNTSmQnusN/Nq80ywRwE6lH2QjwHbJTHhnfaggi6 w1cd2ls9i568OvRCdvMa5T6Ev6UaBnF4QjV5sZyhAPfV8JFRBJcTgC2lwwW3d1bqtgvP H5Pwl9M9t/rXKAEMng8vnJ23v6QzQWDNeoR7NPAq79Ro+9lvuZ08Z7dM1uOn+duO9h5a qn1+9K9vvG9JZ/HE4gBHFMD5v0Fv7L8nCUJr7EZWjsCIr3k28CCJ/2MRdaqCgq7xRSnb gcsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OnNlXVI4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CZHFPtJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 33-20020a631461000000b0046f5808167asi9677934pgu.812.2023.01.09.07.33.12; Mon, 09 Jan 2023 07:33:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OnNlXVI4; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CZHFPtJP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237060AbjAIPaG (ORCPT + 53 others); Mon, 9 Jan 2023 10:30:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236885AbjAIP3f (ORCPT ); Mon, 9 Jan 2023 10:29:35 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C881FB8D for ; Mon, 9 Jan 2023 07:29:34 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673278172; 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=KoiFHa3OYaUadlpj4XIDCoE4VEmQuSerBU1ZGv9DnLo=; b=OnNlXVI4ddvfBx/m5OTKEBQuyVb7cjlADg637Gsgi1H1U3SOck00FIi0KuikWfCERHPPcc av1tt9E7/NWqr4e7brvvf1Ih5WwTrky4geNfDi2Ud8ErV+Qgfxen1WWMtmYWas9NvBpMAC RK+7k9N8rLGgwA31d9LySbDfOlcD7n/LUBoKpRTVh8MaRh+JBYQJyDlzAM2Z7WhbGg/Kq9 xLRq5Y8n2M+eksNGgyhFSd6gKj7eqXkyqhxFTiFxQlXGpRK/C6xY7Wm57PYsaV1nppLP0G OANzM0RPvvPwPGH1X8eu39HeKOQFKW+7WGoYP8NdX+WRyAaNm/4iFRLA9s3crw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673278172; 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=KoiFHa3OYaUadlpj4XIDCoE4VEmQuSerBU1ZGv9DnLo=; b=CZHFPtJPuGRR5JMiSzNZNLLnEk+jcaDXQ22Ea1ihyEmk0PJ70MkfiUR2S29JqVzSa5vTKO PXwi4NtnSYnptuBg== To: Guo Hui , sboyd@kernel.org Cc: jstultz@google.com, wangxiaohua@uniontech.com, linux-kernel@vger.kernel.org, Guo Hui , Will Deacon , Mark Rutland , Peter Zijlstra Subject: Re: [PATCH] timekeeping:add padding in timekeeper for Unixbench pipe In-Reply-To: <20230106062946.19983-1-guohui@uniontech.com> References: <20230106062946.19983-1-guohui@uniontech.com> Date: Mon, 09 Jan 2023 16:29:32 +0100 Message-ID: <874jszlo9v.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 Guo! On Fri, Jan 06 2023 at 14:29, Guo Hui wrote: > When the LLC cache line size is 128 bytes, such as Kunpeng 920, > the seq attribute and xtime attribute in the structure tk_core > are completely in the same LLC cache line, > and xtime_sec is the data protected by the seq lock > in the function ktime_get_coarse_real_ts64, > so seq and xtime_sec are in the same LLC cache line > causing the false sharing problem. What exactly causes the alleged false sharing problem? > Adding padding before xtime_sec in the structure timekeeper > is based on the comment of the structure tk_read_base: "This > struct has size 56 byte on 64 bit. Together with a seqcount > it occupies a single 64byte cache line." Therefore, > seq and the structure tk_read_base > should be placed in the same 64-byte cacheline. How is that relevant? They _are_ in the same cacheline independent of your padding, no? Offset Size seqcount_raw_spinlock_t seq; /* 0 4 */ struct timekeeper timekeeper; /* 8 280 */ struct tk_read_base tkr_mono; /* 8 56 */ 8 + 56 = 64 which is also the case with your padding. If your false sharing thing exists then all other timekeeper read functions which only use tk_core.seq and tk_core.timekeeper.tkr_mono have the very same false sharing problem because seq and data are in the same cache line, no? Aside of that, for architectures with 64 byte cache line size, your change is fundamentally bad. Why? It moves xtime_sec to offset 128 which means seq and xtime_sec are not longer in consecutive cache lines. If you change core data structures for the benefit of your platform, then you have to provide proof that it does not cause any issues on other architectures and platforms. Thanks, tglx