1 From e6a71160cc145e18ab45195abf89884112e02dfb Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Wed, 18 Jan 2023 12:21:35 -0800
4 Subject: gcc-plugins: Reorganize gimple includes for GCC 13
6 The gimple-iterator.h header must be included before gimple-fold.h
7 starting with GCC 13. Reorganize gimple headers to work for all GCC
10 Reported-by: Palmer Dabbelt <palmer@rivosinc.com>
11 Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
12 Link: https://lore.kernel.org/all/20230113173033.4380-1-palmer@rivosinc.com/
13 Cc: linux-hardening@vger.kernel.org
14 Signed-off-by: Kees Cook <keescook@chromium.org>
16 scripts/gcc-plugins/gcc-common.h | 4 ++--
17 1 file changed, 2 insertions(+), 2 deletions(-)
19 diff --git a/scripts/gcc-plugins/gcc-common.h b/scripts/gcc-plugins/gcc-common.h
20 index 9a1895747b153..84c730da36dd3 100644
21 --- a/scripts/gcc-plugins/gcc-common.h
22 +++ b/scripts/gcc-plugins/gcc-common.h
25 #include "stor-layout.h"
26 #include "internal-fn.h"
28 #include "gimple-expr.h"
29 +#include "gimple-iterator.h"
30 #include "gimple-fold.h"
32 #include "tree-ssa-alias.h"
38 #include "tree-phinodes.h"
40 -#include "gimple-iterator.h"
41 #include "gimple-ssa.h"
42 #include "ssa-iterators.h"
47 From ff1cc97b1f4c10db224f276d9615b22835b8c424 Mon Sep 17 00:00:00 2001
48 From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
49 Date: Tue, 13 Dec 2022 13:08:26 +0100
50 Subject: block/blk-iocost (gcc13): keep large values in a new enum
52 Since gcc13, each member of an enum has the same type as the enum [1]. And
53 that is inherited from its members. Provided:
54 VTIME_PER_SEC_SHIFT = 37,
55 VTIME_PER_SEC = 1LLU << VTIME_PER_SEC_SHIFT,
57 AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
58 the named type is unsigned long.
60 This generates warnings with gcc-13:
61 block/blk-iocost.c: In function 'ioc_weight_prfill':
62 block/blk-iocost.c:3037:37: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int'
64 block/blk-iocost.c: In function 'ioc_weight_show':
65 block/blk-iocost.c:3047:34: error: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'
67 So split the anonymous enum with large values to a separate enum, so
68 that they don't affect other members.
70 [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36113
72 Cc: Martin Liska <mliska@suse.cz>
73 Cc: Tejun Heo <tj@kernel.org>
74 Cc: Josef Bacik <josef@toxicpanda.com>
75 Cc: Jens Axboe <axboe@kernel.dk>
76 Cc: cgroups@vger.kernel.org
77 Cc: linux-block@vger.kernel.org
78 Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
79 Link: https://lore.kernel.org/r/20221213120826.17446-1-jirislaby@kernel.org
80 Signed-off-by: Jens Axboe <axboe@kernel.dk>
82 block/blk-iocost.c | 2 ++
83 1 file changed, 2 insertions(+)
85 (limited to 'block/blk-iocost.c')
87 diff --git a/block/blk-iocost.c b/block/blk-iocost.c
88 index d1bdc12deaa70..549ddc9e0c6f4 100644
89 --- a/block/blk-iocost.c
90 +++ b/block/blk-iocost.c
91 @@ -232,7 +232,9 @@ enum {
93 /* 1/64k is granular enough and can easily be handled w/ u32 */
99 * As vtime is used to calculate the cost of each IO, it needs to
100 * be fairly high precision. For example, it should be able to
104 From 5f2779dfa7b8cc7dfd4a1b6586d86e0d193266f3 Mon Sep 17 00:00:00 2001
105 From: Arnd Bergmann <arnd@arndb.de>
106 Date: Wed, 18 Jan 2023 09:07:01 +0100
107 Subject: blk-iocost: avoid 64-bit division in ioc_timer_fn
109 The behavior of 'enum' types has changed in gcc-13, so now the
110 UNBUSY_THR_PCT constant is interpreted as a 64-bit number because
111 it is defined as part of the same enum definition as some other
112 constants that do not fit within a 32-bit integer. This in turn
113 leads to some inefficient code on 32-bit architectures as well
116 arm-linux-gnueabi/bin/arm-linux-gnueabi-ld: block/blk-iocost.o: in function `ioc_timer_fn':
117 blk-iocost.c:(.text+0x68e8): undefined reference to `__aeabi_uldivmod'
118 arm-linux-gnueabi-ld: blk-iocost.c:(.text+0x6908): undefined reference to `__aeabi_uldivmod'
120 Split the enum definition to keep the 64-bit timing constants in
121 a separate enum type from those constants that can clearly fit
122 within a smaller type.
124 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
125 Acked-by: Tejun Heo <tj@kernel.org>
126 Link: https://lore.kernel.org/r/20230118080706.3303186-1-arnd@kernel.org
127 Signed-off-by: Jens Axboe <axboe@kernel.dk>
129 block/blk-iocost.c | 8 +++++---
130 1 file changed, 5 insertions(+), 3 deletions(-)
134 diff --git a/block/blk-iocost.c b/block/blk-iocost.c
135 index 6955605629e4f..b691b6bb498f3 100644
136 --- a/block/blk-iocost.c
137 +++ b/block/blk-iocost.c
138 @@ -258,6 +258,11 @@ enum {
139 VRATE_MIN = VTIME_PER_USEC * VRATE_MIN_PPM / MILLION,
140 VRATE_CLAMP_ADJ_PCT = 4,
142 + /* switch iff the conditions are met for longer than this */
143 + AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
147 /* if IOs end up waiting for requests, issue less */
148 RQ_WAIT_BUSY_PCT = 5,
150 @@ -296,9 +301,6 @@ enum {
151 /* don't let cmds which take a very long time pin lagging for too long */
152 MAX_LAGGING_PERIODS = 10,
154 - /* switch iff the conditions are met for longer than this */
155 - AUTOP_CYCLE_NSEC = 10LLU * NSEC_PER_SEC,
158 * Count IO size in 4k pages. The 12bit shift helps keeping
159 * size-proportional components of cost calculation in closer