Skip to content

Commit a816f83

Browse files
Xunlei Pangcasparant
authored andcommitted
alinux: hotfix: Add Cloud Kernel hotfix enhancement
We reserve some fields beforehand for core structures prone to change, so that we won't hurt when extra fields have to be added for hotfix, thereby inceasing the success rate, we even can hot add features with this enhancement. After reserving, normally cache does not matter as the reserved fields (usually at tail) are not accessed at all. Currently involve the following structures: MM: struct zone struct pglist_data struct mm_struct struct vm_area_struct struct mem_cgroup struct writeback_control Block: struct gendisk struct backing_dev_info struct bio struct queue_limits struct request_queue struct blkcg struct blkcg_policy struct blk_mq_hw_ctx struct blk_mq_tag_set struct blk_mq_queue_data struct blk_mq_ops struct elevator_mq_ops struct inode struct dentry struct address_space struct block_device struct hd_struct struct bio_set Network: struct sk_buff struct sock struct net_device_ops struct xt_target struct dst_entry struct dst_ops struct fib_rule Scheduler: struct task_struct struct cfs_rq struct rq struct sched_statistics struct sched_entity struct signal_struct struct task_group struct cpuacct cgroup: struct cgroup_root struct cgroup_subsys_state struct cgroup_subsys struct css_set Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Signed-off-by: Xunlei Pang <xlpang@linux.alibaba.com> [ caspar: use SPDX-License-Identifier ] Signed-off-by: Caspar Zhang <caspar@linux.alibaba.com>
1 parent ec642e3 commit a816f83

29 files changed

+231
-0
lines changed

include/linux/ali_hotfix.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* SPDX-License-Identifier: GPL-2.0
2+
*
3+
* Copyright (c) 2019 Xunlei Pang <xlpang@linux.alibaba.com>
4+
*/
5+
6+
#ifndef _LINUX_ALI_HOTFIX_H
7+
#define _LINUX_ALI_HOTFIX_H
8+
9+
#include <linux/compiler.h>
10+
11+
/*
12+
* ALI_HOTFIX_RESERVE* - reserve fields for core structures prone to change
13+
* ALI_HOTFIX_USE* - use the reserved field in your hotfix
14+
* ALI_HOTFIX_REPLACE - replacement of _orig with a union of _orig and _new
15+
*/
16+
17+
#define _ALI_HOTFIX_REPLACE(_orig, _new) \
18+
union { \
19+
_new; \
20+
struct { \
21+
_orig; \
22+
} __UNIQUE_ID(ali_hotfix_hide); \
23+
}
24+
25+
#define ALI_HOTFIX_REPLACE(_orig, _new) _ALI_HOTFIX_REPLACE(_orig, _new);
26+
27+
/*
28+
* We tried to standardize on alikernel reserved names. These wrappers leverage
29+
* those common names making it easier to read and find in the code.
30+
*/
31+
#define _ALI_HOTFIX_RESERVE(n) unsigned long ali_reserved##n
32+
#define _ALI_HOTFIX_RESERVE_P(n) void (*ali_reserved##n)(void)
33+
34+
#define ALI_HOTFIX_RESERVE(n) _ALI_HOTFIX_RESERVE(n);
35+
#define ALI_HOTFIX_RESERVE_P(n) _ALI_HOTFIX_RESERVE_P(n);
36+
37+
/*
38+
* Wrappers to replace standard alikernel reserved elements.
39+
*/
40+
#define ALI_HOTFIX_USE(n, _new) \
41+
ALI_HOTFIX_REPLACE(_ALI_HOTFIX_RESERVE(n), _new)
42+
#define ALI_HOTFIX_USE_P(n, _new) \
43+
ALI_HOTFIX_REPLACE(_ALI_HOTFIX_RESERVE_P(n), _new)
44+
45+
/*
46+
* Macros for breaking up a reserved element into two smaller chunks using an
47+
* anonymous struct inside an anonymous union.
48+
*/
49+
#define ALI_HOTFIX_USE2(n, _new1, _new2) \
50+
ALI_HOTFIX_REPLACE(_ALI_HOTFIX_RESERVE(n), struct{ _new1; _new2; })
51+
#define ALI_HOTFIX_USE2_P(n, _new1, _new2) \
52+
ALI_HOTFIX_REPLACE(_ALI_HOTFIX_RESERVE_P(n), struct{ _new1; _new2; })
53+
54+
#endif /* _LINUX_ALI_HOTFIX_H */

include/linux/backing-dev-defs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ struct bdi_writeback {
162162
struct rcu_head rcu;
163163
};
164164
#endif
165+
166+
ALI_HOTFIX_RESERVE(1)
167+
ALI_HOTFIX_RESERVE(2)
165168
};
166169

167170
struct backing_dev_info {
@@ -205,6 +208,9 @@ struct backing_dev_info {
205208
struct dentry *debug_dir;
206209
struct dentry *debug_stats;
207210
#endif
211+
212+
ALI_HOTFIX_RESERVE(1)
213+
ALI_HOTFIX_RESERVE(2)
208214
};
209215

210216
enum {

include/linux/bio.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,9 @@ struct bio_set {
775775
struct bio_list rescue_list;
776776
struct work_struct rescue_work;
777777
struct workqueue_struct *rescue_workqueue;
778+
779+
ALI_HOTFIX_RESERVE(1)
780+
ALI_HOTFIX_RESERVE(2)
778781
};
779782

780783
struct biovec_slab {

include/linux/blk-cgroup.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ struct blkcg {
5858
struct list_head cgwb_list;
5959
refcount_t cgwb_refcnt;
6060
#endif
61+
62+
ALI_HOTFIX_RESERVE(1)
63+
ALI_HOTFIX_RESERVE(2)
64+
ALI_HOTFIX_RESERVE(3)
65+
ALI_HOTFIX_RESERVE(4)
6166
};
6267

6368
/*
@@ -178,6 +183,9 @@ struct blkcg_policy {
178183
blkcg_pol_free_pd_fn *pd_free_fn;
179184
blkcg_pol_reset_pd_stats_fn *pd_reset_stats_fn;
180185
blkcg_pol_stat_pd_fn *pd_stat_fn;
186+
187+
ALI_HOTFIX_RESERVE_P(1)
188+
ALI_HOTFIX_RESERVE_P(2)
181189
};
182190

183191
extern struct blkcg blkcg_root;

include/linux/blk-mq.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ struct blk_mq_hw_ctx {
7070
struct dentry *sched_debugfs_dir;
7171
#endif
7272

73+
ALI_HOTFIX_RESERVE(1)
74+
ALI_HOTFIX_RESERVE(2)
75+
ALI_HOTFIX_RESERVE(3)
76+
ALI_HOTFIX_RESERVE(4)
77+
7378
/* Must be the last member - see also blk_mq_hw_ctx_size(). */
7479
struct srcu_struct srcu[0];
7580
};
@@ -90,11 +95,18 @@ struct blk_mq_tag_set {
9095

9196
struct mutex tag_list_lock;
9297
struct list_head tag_list;
98+
99+
ALI_HOTFIX_RESERVE(1)
100+
ALI_HOTFIX_RESERVE(2)
101+
ALI_HOTFIX_RESERVE(3)
102+
ALI_HOTFIX_RESERVE(4)
93103
};
94104

95105
struct blk_mq_queue_data {
96106
struct request *rq;
97107
bool last;
108+
109+
ALI_HOTFIX_RESERVE(1)
98110
};
99111

100112
typedef blk_status_t (queue_rq_fn)(struct blk_mq_hw_ctx *,
@@ -181,6 +193,9 @@ struct blk_mq_ops {
181193
*/
182194
void (*show_rq)(struct seq_file *m, struct request *rq);
183195
#endif
196+
197+
ALI_HOTFIX_RESERVE_P(1)
198+
ALI_HOTFIX_RESERVE_P(2)
184199
};
185200

186201
enum {

include/linux/blk_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <linux/ktime.h>
1212
#include <linux/sched/clock.h>
1313

14+
#include <linux/ali_hotfix.h>
15+
1416
struct bio_set;
1517
struct bio;
1618
struct bio_integrity_payload;
@@ -212,6 +214,9 @@ struct bio {
212214

213215
struct bio_set *bi_pool;
214216

217+
ALI_HOTFIX_RESERVE(1)
218+
ALI_HOTFIX_RESERVE(2)
219+
215220
/*
216221
* We can inline a number of vecs at the end of the bio, to avoid
217222
* double allocations for a small number of bio_vecs. This member

include/linux/blkdev.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,9 @@ struct queue_limits {
396396
unsigned char cluster;
397397
unsigned char raid_partial_stripes_expensive;
398398
enum blk_zoned_model zoned;
399+
400+
ALI_HOTFIX_RESERVE(1)
401+
ALI_HOTFIX_RESERVE(2)
399402
};
400403

401404
#ifdef CONFIG_BLK_DEV_ZONED
@@ -677,6 +680,11 @@ struct request_queue {
677680

678681
#define BLK_MAX_WRITE_HINTS 5
679682
u64 write_hints[BLK_MAX_WRITE_HINTS];
683+
684+
ALI_HOTFIX_RESERVE(1)
685+
ALI_HOTFIX_RESERVE(2)
686+
ALI_HOTFIX_RESERVE(3)
687+
ALI_HOTFIX_RESERVE(4)
680688
};
681689

682690
#define QUEUE_FLAG_QUEUED 0 /* uses generic tag queueing */

include/linux/cgroup-defs.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ struct cgroup_subsys_state {
161161
struct work_struct destroy_work;
162162
struct rcu_work destroy_rwork;
163163

164+
ALI_HOTFIX_RESERVE(1)
165+
ALI_HOTFIX_RESERVE(2)
166+
164167
/*
165168
* PI: the parent css. Placed here for cache proximity to following
166169
* fields of the containing structure.
@@ -262,6 +265,9 @@ struct css_set {
262265

263266
/* For RCU-protected deletion */
264267
struct rcu_head rcu_head;
268+
269+
ALI_HOTFIX_RESERVE(1)
270+
ALI_HOTFIX_RESERVE(2)
265271
};
266272

267273
struct cgroup_base_stat {
@@ -489,6 +495,9 @@ struct cgroup_root {
489495
/* IDs for cgroups in this hierarchy */
490496
struct idr cgroup_idr;
491497

498+
ALI_HOTFIX_RESERVE(1)
499+
ALI_HOTFIX_RESERVE(2)
500+
492501
/* The path to use for release notifications. */
493502
char release_agent_path[PATH_MAX];
494503

@@ -614,6 +623,9 @@ struct cgroup_subsys {
614623
void (*release)(struct task_struct *task);
615624
void (*bind)(struct cgroup_subsys_state *root_css);
616625

626+
ALI_HOTFIX_RESERVE_P(1)
627+
ALI_HOTFIX_RESERVE_P(2)
628+
617629
bool early_init:1;
618630

619631
/*

include/linux/dcache.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <linux/stringhash.h>
1515
#include <linux/wait.h>
1616

17+
#include <linux/ali_hotfix.h>
18+
1719
struct path;
1820
struct vfsmount;
1921

@@ -117,6 +119,9 @@ struct dentry {
117119
struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */
118120
struct rcu_head d_rcu;
119121
} d_u;
122+
123+
ALI_HOTFIX_RESERVE(1)
124+
ALI_HOTFIX_RESERVE(2)
120125
} __randomize_layout;
121126

122127
/*

include/linux/elevator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ struct elevator_mq_ops {
119119
struct request *(*next_request)(struct request_queue *, struct request *);
120120
void (*init_icq)(struct io_cq *);
121121
void (*exit_icq)(struct io_cq *);
122+
123+
ALI_HOTFIX_RESERVE_P(1)
124+
ALI_HOTFIX_RESERVE_P(2)
122125
};
123126

124127
#define ELV_NAME_MAX (16)

0 commit comments

Comments
 (0)