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 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 2E0AFC433E2 for ; Fri, 4 Sep 2020 07:41:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E97B2206A5 for ; Fri, 4 Sep 2020 07:41:53 +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="WVqFR3tu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729651AbgIDHlw (ORCPT ); Fri, 4 Sep 2020 03:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726127AbgIDHlv (ORCPT ); Fri, 4 Sep 2020 03:41:51 -0400 Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29D02C061244 for ; Fri, 4 Sep 2020 00:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=oAdewkxWA7zZhhRIIu3LLj08dgY5aFFVJNcpz8rgRyo=; b=WVqFR3tuF4i7vaXkBgcfaXqcWU gZ4IE9vApbk6xQ7Wsd75qIARfk3I+scha0o+rqQePtaLMBMp+RlxuzSLEcTDgvoC2QJlihp9HbdN7 4ja5/amloiItBJ23/iczFStwQlusiL/B5AJUUCoG0H66wI7w3bsBOWY6XUkHMCtpLYT96pxcyZecu nYAjm0Rjt1cI0QMLk/ufQrKLjYVx9daYrfLrjuE1iPGAwNzxPTQ3azjabwrJrOsvxnBksVjC8K+LH KaVGBBnauGhmMiz47Oe3ExAHjwBlSvCDasfQK9CUb6eT1WSbbpVxokf6ppfqRnFPn37qNIzvGXaR4 rbqUWQLg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kE6Lw-0002w3-Ua; Fri, 04 Sep 2020 07:41:45 +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 F289A3012DF; Fri, 4 Sep 2020 09:41:42 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id CFA742BE18715; Fri, 4 Sep 2020 09:41:42 +0200 (CEST) Date: Fri, 4 Sep 2020 09:41:42 +0200 From: peterz@infradead.org To: "Ahmed S. Darwish" Cc: Ingo Molnar , Will Deacon , Thomas Gleixner , "Sebastian A. Siewior" , LKML , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Subject: Re: [PATCH v1 6/8] x86/tsc: Use seqcount_latch_t Message-ID: <20200904074142.GL2674@hirez.programming.kicks-ass.net> References: <20200827114044.11173-1-a.darwish@linutronix.de> <20200827114044.11173-7-a.darwish@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200827114044.11173-7-a.darwish@linutronix.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 01:40:42PM +0200, Ahmed S. Darwish wrote: > __always_inline void cyc2ns_read_begin(struct cyc2ns_data *data) > { > + seqcount_latch_t *seqcount; > int seq, idx; > > preempt_disable_notrace(); > > + seqcount = &this_cpu_ptr(&cyc2ns)->seq; > do { > - seq = this_cpu_read(cyc2ns.seq.sequence); > + seq = raw_read_seqcount_latch(seqcount); > idx = seq & 1; > > data->cyc2ns_offset = this_cpu_read(cyc2ns.data[idx].cyc2ns_offset); > data->cyc2ns_mul = this_cpu_read(cyc2ns.data[idx].cyc2ns_mul); > data->cyc2ns_shift = this_cpu_read(cyc2ns.data[idx].cyc2ns_shift); > > - } while (unlikely(seq != this_cpu_read(cyc2ns.seq.sequence))); > + } while (read_seqcount_latch_retry(seqcount, seq)); > } So I worried about this change, it obviously generates worse code. But I was not expecting this: Before: 196: 0000000000000110 189 FUNC GLOBAL DEFAULT 1 native_sched_clock After: 195: 0000000000000110 399 FUNC GLOBAL DEFAULT 1 native_sched_clock That's _210_ bytes extra!! If you look at the disassembly of the thing after it's a complete trainwreck.