Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp648656rwn; Thu, 15 Sep 2022 04:36:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HZtoNfik3fgsnbZbX7dyuqYnOWkgKSZqIfZs7mxhOYP08f3iwpDobWguIUtPNNfzgafqR X-Received: by 2002:a17:902:6b82:b0:16d:d268:3842 with SMTP id p2-20020a1709026b8200b0016dd2683842mr3921688plk.16.1663241797029; Thu, 15 Sep 2022 04:36:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663241797; cv=none; d=google.com; s=arc-20160816; b=B2TpNYxi2O9qq+GbPKPkFtAt3SPkK6mJ/keji/aZYepc2T8AVWZNZ3+mMUAfhd+squ 7R1e0LC2zUoOC2Jb/CnP4vsk1sdG3w2pvi/iA6Wi5uByqPQV4Buj0FsjaN7ZZTUcoCBz iniw3DVHgem+TcmkzsMxIHIIpfiLYpxkwKDXaMmUCRf00Sv7Q225hOXVrgTHXI3j34b0 Z3WsMDjZafDgKFleU1MsXZlZoKHN1kd1PKjOXG11ZUjBJVUlzyB7wle/7VTGyYFOUW44 l/QjBrrelo0BdFnrriGuJdldvx6fJhL/6INlYaqsp7mCru76WK6mmtL5FJM05tdNM2FT RRmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1EvKTI+8vdc4mrKuvrpi7vpxhe4JIVCAewhTA3ti8qc=; b=S2ix4f1KPpj3x5YrjFnduf4R5TmQeKG7+APNfkFGJgdtcBcb/gYkFuNETcOB4B0l1I Dw8RzVu/+4zgWxXv9aOuYbN7jmAHfD7tnrlnOdLfJjZxD6vSqxur/b2uX5uQ/vT0/NXK 8/69ZY3m+WXlC3bOdCJ0oO739DbsKoXL/Qd6hlZx66VVhftXHHuAfXzYrDGPWp0a5hNZ UraQkFYGFn/RYqzTd5KFyLTFlImz9wIKQvKRvpNVgeDe4CTkjpBTQ6FGAyhR/OTM+Zo0 B6AtGC/CFu1UtfkGPr3Yw0sDbruB9FQAeIa1kKJpCyzePGgBaRoURVsFjg8sdjUPypsy Gaww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=FuqDqvKs; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a056a00158e00b00545c1d801d7si8959486pfk.364.2022.09.15.04.36.24; Thu, 15 Sep 2022 04:36:37 -0700 (PDT) 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=@infradead.org header.s=desiato.20200630 header.b=FuqDqvKs; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbiIOLXD (ORCPT + 99 others); Thu, 15 Sep 2022 07:23:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbiIOLXB (ORCPT ); Thu, 15 Sep 2022 07:23:01 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 746917D783 for ; Thu, 15 Sep 2022 04:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=1EvKTI+8vdc4mrKuvrpi7vpxhe4JIVCAewhTA3ti8qc=; b=FuqDqvKs3kCvpr8IrOUsK3sFZz ZbTh3ayxic3EmFpQf240Nloa1N5nMIHSQ+AoME07L7MlloOYqzCityEaf555ngb1Xa8tQJhXL+jVe Za3802G+htij/YdzFxfkPD6mMhhr01ZUbUHUV05AWbCGsEU9ap6aDIXqaS2yNwV+RB9fVCvbWPAl3 XIfQU+YQ9NdNdrmV41w2nNibxOMnJEYp/ypYPwHg0o9csIRwfppHFTlCpUsRq3ud7gwn0DJNm5UqC 4LWXV49rteCtQdxkL5zkVdZVhP+L2D6y4kOnK/pu3XIwLx6MmH5vI8hPniVq7IBXkOHvPgYhofZqO sRuqEqDw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYmwl-00CaNR-IB; Thu, 15 Sep 2022 11:22:19 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id DF47A30029C; Thu, 15 Sep 2022 13:22:17 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id AACED2B1A4535; Thu, 15 Sep 2022 13:22:17 +0200 (CEST) Date: Thu, 15 Sep 2022 13:22:17 +0200 From: Peter Zijlstra To: Jann Horn Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, x86@kernel.org, Linus Torvalds , Tim Chen , Josh Poimboeuf , Andrew Cooper , Pawan Gupta , Johannes Wikner , Alyssa Milburn , "H.J. Lu" , Joao Moreira , Joseph Nuzman , Steven Rostedt , Juergen Gross , Masami Hiramatsu , Alexei Starovoitov , Daniel Borkmann , K Prateek Nayak , Eric Dumazet Subject: Re: [PATCH v2 22/59] x86: Put hot per CPU variables into a struct Message-ID: References: <20220902130625.217071627@infradead.org> <20220902130948.643735860@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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_NONE 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 On Fri, Sep 02, 2022 at 08:02:46PM +0200, Jann Horn wrote: > On Fri, Sep 2, 2022 at 3:54 PM Peter Zijlstra wrote: > > From: Thomas Gleixner > > > > The layout of per-cpu variables is at the mercy of the compiler. This > > can lead to random performance fluctuations from build to build. > > > > Create a structure to hold some of the hottest per-cpu variables, > > starting with current_task. > [...] > > -DECLARE_PER_CPU(struct task_struct *, current_task); > > +struct pcpu_hot { > > + union { > > + struct { > > + struct task_struct *current_task; > > + }; > > + u8 pad[64]; > > + }; > > +}; > > fixed_percpu_data::stack_canary is probably also a fairly hot per-cpu > variable on distro kernels with CONFIG_STACKPROTECTOR_STRONG (which > e.g. Debian enables), so perhaps it'd make sense to reuse > fixed_percpu_data as the struct for hot percpu variables? But I don't > have any numbers to actually back up that idea. Not a bad idea; but the immediate problem I see with this is that fixed_percpu_data is x86_64 only. Also; I'm thinking the current stack-protector thing is somewhat of a hack due to GCC limitations (per the comment there) and once that gets cleaned up it can come live in the pcpu_hot thing.