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 Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81EF1C433F5 for ; Thu, 19 May 2022 11:16:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id ECF2141BA3; Thu, 19 May 2022 11:16:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iRnHWV33DfgB; Thu, 19 May 2022 11:16:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5315B41741; Thu, 19 May 2022 11:16:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23245C0032; Thu, 19 May 2022 11:16:45 +0000 (UTC) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id E09D3C002D for ; Thu, 19 May 2022 11:16:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id BFD9B60C23 for ; Thu, 19 May 2022 11:16:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp3.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=infradead.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QOozN6qBRv6R for ; Thu, 19 May 2022 11:16:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by smtp3.osuosl.org (Postfix) with ESMTPS id 47B2560AD0 for ; Thu, 19 May 2022 11:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=fwaHgMGpyKxUjfrphlTtFfZFCA36vjc6kx8Yyplbjpk=; b=RYDCMXNpjIlJnbpR6ajxa55hj9 BLxgLS+TW0KAVxKV4JaOWIwnjIdnLelGBL0amhS5m4Bj6RzVX88ZYv4ZnTYLQU2D2AXrBEXNbTXmE 5UPxBttFRv++AX6J1pfNJpVRGkFI41IgVezP8l3BQ65qAPDRGY3AZChhhVCtt/FZYt8FN/YmI5mcE 9UktynESLujWWXkmY4qq4fRUo+xa5bkKIefFafuZGBa7CHAxFJpl6jkuGN6nW7Rgs/GQ7d+UBzTFE aSXTOimSk22J98oidhup2X9gksk6VIYTjwwM0wx5BlnZzA93g8H6XrtmdIIBJwIA09gPKh0FyI3/P YS2nOp9Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nre8Y-0020tX-GR; Thu, 19 May 2022 11:16:11 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id CBE9F980E0B; Thu, 19 May 2022 13:16:08 +0200 (CEST) Date: Thu, 19 May 2022 13:16:08 +0200 From: Peter Zijlstra To: Christophe de Dinechin Subject: Re: [PATCH 1/3] sched/headers: Fix compilation error with GCC 12 Message-ID: <20220519111608.GF2578@worktop.programming.kicks-ass.net> References: <20220414150855.2407137-1-dinechin@redhat.com> <20220414150855.2407137-2-dinechin@redhat.com> <5AEAD35F-10E2-41A3-8269-E8358160D33B@dinechin.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <5AEAD35F-10E2-41A3-8269-E8358160D33B@dinechin.org> Cc: Juri Lelli , trivial@kernel.org, "Michael S. Tsirkin" , Zhen Lei , linux-kernel@vger.kernel.org, Steven Rostedt , virtualization@lists.linux-foundation.org, Ben Segall , Ingo Molnar , Mel Gorman , Paolo Bonzini , Christophe de Dinechin , Vincent Guittot , Andrew Morton , Daniel Bristot de Oliveira , Dietmar Eggemann X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" T24gTW9uLCBBcHIgMjUsIDIwMjIgYXQgMDQ6MDc6NDNQTSArMDIwMCwgQ2hyaXN0b3BoZSBkZSBE aW5lY2hpbiB3cm90ZToKCj4gPj4gZXh0ZXJuIHN0cnVjdCBzY2hlZF9jbGFzcyBfX2JlZ2luX3Nj aGVkX2NsYXNzZXNbXTsKPiA+PiBleHRlcm4gc3RydWN0IHNjaGVkX2NsYXNzIF9fZW5kX3NjaGVk X2NsYXNzZXNbXTsKPiA+PiAKPiA+PiAtI2RlZmluZSBzY2hlZF9jbGFzc19oaWdoZXN0IChfX2Vu ZF9zY2hlZF9jbGFzc2VzIC0gMSkKPiA+PiArLyoKPiA+PiArICogc2NoZWRfY2xhc3NfaGlnaGVz dHMgaXMgcmVhbGx5IF9fZW5kX3NjaGVkX2NsYXNzZXMgLSAxLCBidXQgd3JpdHRlbiBpbiBhIHdh eQo+ID4+ICsgKiB0aGF0IG1ha2VzIGl0IGNsZWFyIHRoYXQgaXQgaXMgd2l0aGluIF9fYmVnaW5f c2NoZWRfY2xhc3Nlc1tdIGFuZ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F0aW9ucyBnbyBvdXQgdGhl IHdpbmRvdyByZWFsIGZhc3QuCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fClZpcnR1YWxpemF0aW9uIG1haWxpbmcgbGlzdApWaXJ0dWFsaXphdGlvbkBsaXN0 cy5saW51eC1mb3VuZGF0aW9uLm9yZwpodHRwczovL2xpc3RzLmxpbnV4Zm91bmRhdGlvbi5vcmcv bWFpbG1hbi9saXN0aW5mby92aXJ0dWFsaXphdGlvbg== 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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E99F7C433EF for ; Thu, 19 May 2022 11:16:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbiESLQx (ORCPT ); Thu, 19 May 2022 07:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbiESLQt (ORCPT ); Thu, 19 May 2022 07:16:49 -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 032E552B37 for ; Thu, 19 May 2022 04:16:46 -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-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=fwaHgMGpyKxUjfrphlTtFfZFCA36vjc6kx8Yyplbjpk=; b=RYDCMXNpjIlJnbpR6ajxa55hj9 BLxgLS+TW0KAVxKV4JaOWIwnjIdnLelGBL0amhS5m4Bj6RzVX88ZYv4ZnTYLQU2D2AXrBEXNbTXmE 5UPxBttFRv++AX6J1pfNJpVRGkFI41IgVezP8l3BQ65qAPDRGY3AZChhhVCtt/FZYt8FN/YmI5mcE 9UktynESLujWWXkmY4qq4fRUo+xa5bkKIefFafuZGBa7CHAxFJpl6jkuGN6nW7Rgs/GQ7d+UBzTFE aSXTOimSk22J98oidhup2X9gksk6VIYTjwwM0wx5BlnZzA93g8H6XrtmdIIBJwIA09gPKh0FyI3/P YS2nOp9Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nre8Y-0020tX-GR; Thu, 19 May 2022 11:16:11 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id CBE9F980E0B; Thu, 19 May 2022 13:16:08 +0200 (CEST) Date: Thu, 19 May 2022 13:16:08 +0200 From: Peter Zijlstra To: Christophe de Dinechin Cc: Christophe de Dinechin , trivial@kernel.org, Ben Segall , "Michael S. Tsirkin" , Andrew Morton , Steven Rostedt , Ingo Molnar , Mel Gorman , Dietmar Eggemann , Vincent Guittot , Paolo Bonzini , Daniel Bristot de Oliveira , Jason Wang , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Zhen Lei , Juri Lelli Subject: Re: [PATCH 1/3] sched/headers: Fix compilation error with GCC 12 Message-ID: <20220519111608.GF2578@worktop.programming.kicks-ass.net> References: <20220414150855.2407137-1-dinechin@redhat.com> <20220414150855.2407137-2-dinechin@redhat.com> <5AEAD35F-10E2-41A3-8269-E8358160D33B@dinechin.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5AEAD35F-10E2-41A3-8269-E8358160D33B@dinechin.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 25, 2022 at 04:07:43PM +0200, Christophe de Dinechin wrote: > >> extern struct sched_class __begin_sched_classes[]; > >> extern struct sched_class __end_sched_classes[]; > >> > >> -#define sched_class_highest (__end_sched_classes - 1) > >> +/* > >> + * sched_class_highests is really __end_sched_classes - 1, but written in a way > >> + * that makes it clear that it is within __begin_sched_classes[] and not outside > >> + * of __end_sched_classes[]. > >> + */ > >> +#define sched_class_highest (__begin_sched_classes + \ > >> + (__end_sched_classes - __begin_sched_classes - 1)) > >> #define sched_class_lowest (__begin_sched_classes - 1) > >> > >> +/* The + 1 below places the pointers within the range of their array */ > >> #define for_class_range(class, _from, _to) \ > >> - for (class = (_from); class != (_to); class--) > >> + for (class = (_from); class + 1 != (_to) + 1; class--) > > > > Urgh, so now we get less readable code, > > You consider the original code readable? Yeah, because: x + y - x - 1 == y - 1, so wth would you want to write it with the x on. That's just silly. > It actually relies on a > precise layout that is not enforced in this code, not even documented, > but actually enforced by the linker script. It has a comment pointing at the linker script, and we have: /* Make sure the linker didn't screw up */ BUG_ON(&idle_sched_class + 1 != &fair_sched_class || &fair_sched_class + 1 != &rt_sched_class || &rt_sched_class + 1 != &dl_sched_class); #ifdef CONFIG_SMP BUG_ON(&dl_sched_class + 1 != &stop_sched_class); #endif On boot to verify the layout is as we expect. > > just because GCC is being > > stupid? > > I think that GCC is actually remarkably smart there. It tells you > that you are building pointers to A[] from B[], when there is a legit > way to say that the pointer is in A[] (which is what my patch does) We build with -fno-strict-aliasing, it must not assume anything like that, unless restrict is used. In this case, they're not two objects but the same one. Just because linker script can't really get us a sensible array definition. > > What's wrong with negative array indexes? memory is memory, stuff works. > > What’s wrong is that the compiler cannot prove theorems anymore. > These theorems are used to optimise code. When you write -1[B], the > compiler cannot optimise based on knowing this refers to A[B-A-1]. > > While at first, you might think that disabling a warning is a win, > what comes next is the compiler optimizing in a way you did not > anticipate, mysterious bugs showing up, and/or having to turn off some > potentially useful optimisation. We're usually fairly quick to call a compiler broken if doesn't do what we want it to. Dodgy optimizations go out the window real fast.