mailweb.openeuler.org
Manage this list

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Kernel

Threads by month
  • ----- 2025 -----
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
kernel@openeuler.org

  • 44 participants
  • 18678 discussions
[PATCH OLK-6.6 v5 0/5] block: Add config to show info about opening a mounted device for write
by Li Lingfeng 09 Jan '24

09 Jan '24
v1->v2: 1) Replace BLK_DEV_DUMPINFO with BLK_DEV_WRITE_MOUNTED_QUIET, which is logically opposite; 2) Make BLK_DEV_WRITE_MOUNTED_QUIET dependent on BLK_DEV_WRITE_MOUNTED, and decide whether to set bd_writers by BLK_DEV_WRITE_MOUNTED_QUIET; 3) Move bdev_dump_info() into bdev_may_open(); 4) Add the cmdline interface to control whether to show info; 5) Pass the state of "writes blocked" to part0 when mounting a partition. v2->v3: Add restriction for modifying bd_writers. v3->v4: 1) Count bd_writers regardless of whether bdev_allow_write_mounted is set; 2) Expand the meaning of bdev_allow_write_mounted; 3) Add config option to detect writing to part0 while partitions mounted; 4) Add bd_mounters to record the number of times that part0 or partition is mounted; 5) Show info about opening a lower device for write while upper-layers mounted. v4->v5: Move introduction of bd_mounters to patch1. Li Lingfeng (5): block: Count writers and mounters regardless of whether bdev_allow_write_mounted is set block: Expand the meaning of bdev_allow_write_mounted block: Add config option to detect writing to part0 while partitions mounted block: Add config option to show info about opening a mounted device for write block: Show info about opening a lower device for write while upper-layers mounted block/Kconfig | 19 ++++++++ block/bdev.c | 100 +++++++++++++++++++++++++++++++++----- include/linux/blk_types.h | 1 + 3 files changed, 107 insertions(+), 13 deletions(-) -- 2.31.1
2 8
0 0
[PATCH OLK-6.6 v2] block: support to account io_ticks precisely
by Yu Kuai 09 Jan '24

09 Jan '24
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RIME CVE: NA ----------------------------------------------- Currently, io_ticks is accounted based on sampling, specifically update_io_ticks() will always account io_ticks by 1 jiffies from bdev_start_io_acct()/blk_account_io_start(), and the result can be inaccurate, for example(HZ is 250): Test script: fio -filename=/dev/sda -bs=4k -rw=write -direct=1 -name=test -thinktime=4ms Test result: util is about 90%, while the disk is really idle. In order to account io_ticks precisely, update_io_ticks() must know if there are IO inflight already, and this requires overhead slightly, hence precise io accounting is disabled by default, and user can enable it through sysfs entry. Noted that for rq-based devcie, part_stat_local_inc/dec() and part_in_flight() is used to track inflight instead of iterating tags, which is not supposed to be used in fast path because 'tags->lock' is grabbed in blk_mq_find_and_get_req(). Signed-off-by: Yu Kuai <yukuai3(a)huawei.com> --- Changes in v2: - some minor code changes, no functional change involed; Documentation/ABI/stable/sysfs-block | 8 ++++-- block/blk-core.c | 27 ++++++++++++++++-- block/blk-merge.c | 3 ++ block/blk-mq-debugfs.c | 2 ++ block/blk-mq.c | 11 +++++++- block/blk-sysfs.c | 42 ++++++++++++++++++++++++++-- block/blk.h | 1 + block/genhd.c | 2 +- include/linux/blk-mq.h | 1 + include/linux/blkdev.h | 3 ++ 10 files changed, 91 insertions(+), 9 deletions(-) diff --git a/Documentation/ABI/stable/sysfs-block b/Documentation/ABI/stable/sysfs-block index 1fe9a553c37b..79027bf2661a 100644 --- a/Documentation/ABI/stable/sysfs-block +++ b/Documentation/ABI/stable/sysfs-block @@ -358,8 +358,12 @@ What: /sys/block/<disk>/queue/iostats Date: January 2009 Contact: linux-block(a)vger.kernel.org Description: - [RW] This file is used to control (on/off) the iostats - accounting of the disk. + [RW] This file is used to control the iostats accounting of the + disk. If this value is 0, iostats accounting is disabled; If + this value is 1, iostats accounting is enabled, but io_ticks is + accounted by sampling and the result is not accurate; If this + value is 2, iostats accounting is enabled and io_ticks is + accounted precisely, but there will be slightly more overhead. What: /sys/block/<disk>/queue/logical_block_size diff --git a/block/blk-core.c b/block/blk-core.c index fdf25b8d6e78..13a27d1d8540 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -71,6 +71,21 @@ static struct kmem_cache *blk_requestq_cachep; */ static struct workqueue_struct *kblockd_workqueue; +static bool precise_iostat; + +static int __init precise_iostat_setup(char *str) +{ + bool precise; + + if (!strtobool(str, &precise)) { + precise_iostat = precise; + pr_info("precise iostat %d\n", precise_iostat); + } + + return 1; +} +__setup("precise_iostat=", precise_iostat_setup); + /** * blk_queue_flag_set - atomically set a queue flag * @flag: flag to be set @@ -441,6 +456,8 @@ struct request_queue *blk_alloc_queue(int node_id) blk_set_default_limits(&q->limits); q->nr_requests = BLKDEV_DEFAULT_RQ; + if (precise_iostat) + blk_queue_flag_set(QUEUE_FLAG_PRECISE_IO_STAT, q); return q; @@ -938,11 +955,15 @@ EXPORT_SYMBOL_GPL(iocb_bio_iopoll); void update_io_ticks(struct block_device *part, unsigned long now, bool end) { unsigned long stamp; + bool precise = blk_queue_precise_io_stat(part->bd_queue); again: stamp = READ_ONCE(part->bd_stamp); - if (unlikely(time_after(now, stamp))) { - if (likely(try_cmpxchg(&part->bd_stamp, &stamp, now))) - __part_stat_add(part, io_ticks, end ? now - stamp : 1); + if (unlikely(time_after(now, stamp)) && + likely(try_cmpxchg(&part->bd_stamp, &stamp, now))) { + if (end || (precise && part_in_flight(part))) + __part_stat_add(part, io_ticks, now - stamp); + else if (!precise) + __part_stat_add(part, io_ticks, 1); } if (part->bd_partno) { part = bdev_whole(part); diff --git a/block/blk-merge.c b/block/blk-merge.c index 65e75efa9bd3..5db8228c46fc 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -783,6 +783,9 @@ static void blk_account_io_merge_request(struct request *req) if (blk_do_io_stat(req)) { part_stat_lock(); part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); + if (req->rq_flags & RQF_PRECISE_IO_STAT) + part_stat_local_dec(req->part, + in_flight[op_is_write(req_op(req))]); part_stat_unlock(); } } diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index aa7a1357c3e1..9ad108307344 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -86,6 +86,7 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(FAIL_IO), QUEUE_FLAG_NAME(NONROT), QUEUE_FLAG_NAME(IO_STAT), + QUEUE_FLAG_NAME(PRECISE_IO_STAT), QUEUE_FLAG_NAME(NOXMERGES), QUEUE_FLAG_NAME(ADD_RANDOM), QUEUE_FLAG_NAME(SYNCHRONOUS), @@ -254,6 +255,7 @@ static const char *const rqf_name[] = { RQF_NAME(FAILED), RQF_NAME(QUIET), RQF_NAME(IO_STAT), + RQF_NAME(PRECISE_IO_STAT), RQF_NAME(PM), RQF_NAME(HASHED), RQF_NAME(STATS), diff --git a/block/blk-mq.c b/block/blk-mq.c index dd7c9e3eca1b..498a6306cbb5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -360,8 +360,11 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, if (data->flags & BLK_MQ_REQ_PM) data->rq_flags |= RQF_PM; - if (blk_queue_io_stat(q)) + if (blk_queue_io_stat(q)) { data->rq_flags |= RQF_IO_STAT; + if (blk_queue_precise_io_stat(q)) + data->rq_flags |= RQF_PRECISE_IO_STAT; + } rq->rq_flags = data->rq_flags; if (data->rq_flags & RQF_SCHED_TAGS) { @@ -994,6 +997,9 @@ static inline void blk_account_io_done(struct request *req, u64 now) update_io_ticks(req->part, jiffies, true); part_stat_inc(req->part, ios[sgrp]); part_stat_add(req->part, nsecs[sgrp], now - req->start_time_ns); + if (req->rq_flags & RQF_PRECISE_IO_STAT) + part_stat_local_dec(req->part, + in_flight[op_is_write(req_op(req))]); part_stat_unlock(); } } @@ -1016,6 +1022,9 @@ static inline void blk_account_io_start(struct request *req) part_stat_lock(); update_io_ticks(req->part, jiffies, false); + if (req->rq_flags & RQF_PRECISE_IO_STAT) + part_stat_local_inc(req->part, + in_flight[op_is_write(req_op(req))]); part_stat_unlock(); } } diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 63e481262336..e58b1574e023 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -303,7 +303,6 @@ queue_##name##_store(struct request_queue *q, const char *page, size_t count) \ QUEUE_SYSFS_BIT_FNS(nonrot, NONROT, 1); QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0); -QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0); QUEUE_SYSFS_BIT_FNS(stable_writes, STABLE_WRITES, 0); #undef QUEUE_SYSFS_BIT_FNS @@ -473,6 +472,45 @@ static ssize_t queue_dax_show(struct request_queue *q, char *page) return queue_var_show(blk_queue_dax(q), page); } +static ssize_t queue_iostats_show(struct request_queue *q, char *page) +{ + int val = 0; + + if (blk_queue_io_stat(q)) + val = blk_queue_precise_io_stat(q) ? 2 : 1; + + return queue_var_show(val, page); +} + +static ssize_t +queue_iostats_store(struct request_queue *q, const char *page, size_t count) +{ + unsigned long nr; + int ret = queue_var_store(&nr, page, count); + + if (ret < 0) + return ret; + + switch (nr) { + case 0: + blk_queue_flag_clear(QUEUE_FLAG_IO_STAT, q); + blk_queue_flag_clear(QUEUE_FLAG_PRECISE_IO_STAT, q); + break; + case 1: + blk_queue_flag_set(QUEUE_FLAG_IO_STAT, q); + blk_queue_flag_clear(QUEUE_FLAG_PRECISE_IO_STAT, q); + break; + case 2: + blk_queue_flag_set(QUEUE_FLAG_IO_STAT, q); + blk_queue_flag_set(QUEUE_FLAG_PRECISE_IO_STAT, q); + break; + default: + return -EINVAL; + } + + return count; +} + #define QUEUE_RO_ENTRY(_prefix, _name) \ static struct queue_sysfs_entry _prefix##_entry = { \ .attr = { .name = _name, .mode = 0444 }, \ @@ -494,6 +532,7 @@ QUEUE_RO_ENTRY(queue_max_segments, "max_segments"); QUEUE_RO_ENTRY(queue_max_integrity_segments, "max_integrity_segments"); QUEUE_RO_ENTRY(queue_max_segment_size, "max_segment_size"); QUEUE_RW_ENTRY(elv_iosched, "scheduler"); +QUEUE_RW_ENTRY(queue_iostats, "iostats"); QUEUE_RO_ENTRY(queue_logical_block_size, "logical_block_size"); QUEUE_RO_ENTRY(queue_physical_block_size, "physical_block_size"); @@ -539,7 +578,6 @@ static struct queue_sysfs_entry queue_hw_sector_size_entry = { }; QUEUE_RW_ENTRY(queue_nonrot, "rotational"); -QUEUE_RW_ENTRY(queue_iostats, "iostats"); QUEUE_RW_ENTRY(queue_random, "add_random"); QUEUE_RW_ENTRY(queue_stable_writes, "stable_writes"); diff --git a/block/blk.h b/block/blk.h index 08a358bc0919..67915b04b3c1 100644 --- a/block/blk.h +++ b/block/blk.h @@ -344,6 +344,7 @@ static inline bool blk_do_io_stat(struct request *rq) } void update_io_ticks(struct block_device *part, unsigned long now, bool end); +unsigned int part_in_flight(struct block_device *part); static inline void req_set_nomerge(struct request_queue *q, struct request *req) { diff --git a/block/genhd.c b/block/genhd.c index 4a16a424f57d..b3ff653f3e50 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -118,7 +118,7 @@ static void part_stat_read_all(struct block_device *part, } } -static unsigned int part_in_flight(struct block_device *part) +unsigned int part_in_flight(struct block_device *part) { unsigned int inflight = 0; int cpu; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 3d74f3e5b995..9dfee0644f9c 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -46,6 +46,7 @@ typedef __u32 __bitwise req_flags_t; #define RQF_QUIET ((__force req_flags_t)(1 << 11)) /* account into disk and partition IO statistics */ #define RQF_IO_STAT ((__force req_flags_t)(1 << 13)) +#define RQF_PRECISE_IO_STAT ((__force req_flags_t)(1 << 14)) /* runtime pm request */ #define RQF_PM ((__force req_flags_t)(1 << 15)) /* on IO scheduler merge hash */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 9f3bcbcb156d..bea0b5fdac74 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -536,6 +536,7 @@ struct request_queue { #define QUEUE_FLAG_NONROT 6 /* non-rotational device (SSD) */ #define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */ #define QUEUE_FLAG_IO_STAT 7 /* do disk/partitions IO accounting */ +#define QUEUE_FLAG_PRECISE_IO_STAT 8 /* do disk/partitions IO accounting precisely */ #define QUEUE_FLAG_NOXMERGES 9 /* No extended merges */ #define QUEUE_FLAG_ADD_RANDOM 10 /* Contributes to random pool */ #define QUEUE_FLAG_SYNCHRONOUS 11 /* always completes in submit context */ @@ -576,6 +577,8 @@ bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q); #define blk_queue_stable_writes(q) \ test_bit(QUEUE_FLAG_STABLE_WRITES, &(q)->queue_flags) #define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags) +#define blk_queue_precise_io_stat(q) \ + test_bit(QUEUE_FLAG_PRECISE_IO_STAT, &(q)->queue_flags) #define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags) #define blk_queue_zone_resetall(q) \ test_bit(QUEUE_FLAG_ZONE_RESETALL, &(q)->queue_flags) -- 2.39.2
1 0
0 0
[PATCH OLK-6.6] fs/dcache.c: avoid panic while lockref of dentry overflow
by Zizhi Wo 09 Jan '24

09 Jan '24
From: yangerkun <yangerkun(a)huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8JDP6 --------------------------- We use lockref for dentry reference without notice that so many negative dentry under one dir can lead to overflow of lockref. This can lead to system crash if we do this under root dir. Since there is not a perfect solution, we just limit max number of dentry count up to INT_MAX / 2. Also, it will cost a lot of time from INT_MAX / 2 to INT_MAX, so we no need to do this under protection of dentry lock. Also, we limit the FILES_MAX to INT_MAX / 2, since a lot open for same file can lead to overflow too. Changelog: v1->v2: add a function to do check / add a Macro to mean INT_MAX / 2 Signed-off-by: yangerkun <yangerkun(a)huawei.com> Signed-off-by: Zizhi Wo <wozizhi(a)huawei.com> --- fs/dcache.c | 32 ++++++++++++++++++++++++++++---- fs/filescontrol.c | 2 +- include/linux/fs.h | 3 +++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 25ac74d30bff..7cdd8bbedd1c 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1834,6 +1834,18 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) return dentry; } +static inline bool d_forbid_overflow(struct dentry *dentry) +{ + if (unlikely(d_count(dentry) >= D_COUNT_MAX)) { + shrink_dcache_parent(dentry); + + if (d_count(dentry) >= D_COUNT_MAX) + return false; + } + + return true; +} + /** * d_alloc - allocate a dcache entry * @parent: parent of entry to allocate @@ -1845,9 +1857,15 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) */ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) { - struct dentry *dentry = __d_alloc(parent->d_sb, name); + struct dentry *dentry = NULL; + + if (unlikely(!d_forbid_overflow(parent))) + goto out; + + dentry = __d_alloc(parent->d_sb, name); if (!dentry) - return NULL; + goto out; + spin_lock(&parent->d_lock); /* * don't need child lock because it is not subject @@ -1857,7 +1875,7 @@ struct dentry *d_alloc(struct dentry * parent, const struct qstr *name) dentry->d_parent = parent; list_add(&dentry->d_child, &parent->d_subdirs); spin_unlock(&parent->d_lock); - +out: return dentry; } EXPORT_SYMBOL(d_alloc); @@ -1870,11 +1888,17 @@ EXPORT_SYMBOL(d_alloc_anon); struct dentry *d_alloc_cursor(struct dentry * parent) { - struct dentry *dentry = d_alloc_anon(parent->d_sb); + struct dentry *dentry = NULL; + + if (unlikely(!d_forbid_overflow(parent))) + goto out; + + dentry = d_alloc_anon(parent->d_sb); if (dentry) { dentry->d_flags |= DCACHE_DENTRY_CURSOR; dentry->d_parent = dget(parent); } +out: return dentry; } diff --git a/fs/filescontrol.c b/fs/filescontrol.c index 610f13a36962..0947566b9119 100644 --- a/fs/filescontrol.c +++ b/fs/filescontrol.c @@ -27,7 +27,7 @@ #include <linux/sched/signal.h> #include <linux/module.h> -#define FILES_MAX ULONG_MAX +#define FILES_MAX D_COUNT_MAX #define FILES_MAX_STR "max" static bool no_acct; diff --git a/include/linux/fs.h b/include/linux/fs.h index fb5accebdcdf..67c2ac09e700 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -47,6 +47,9 @@ #include <asm/byteorder.h> #include <uapi/linux/fs.h> +#define D_COUNT_MAX (INT_MAX / 2) + + struct backing_dev_info; struct bdi_writeback; struct bio; -- 2.39.2
1 0
0 0
[PATCH RESEND OLK-6.6] kabi: reserve space for bpf related structures
by Pu Lehui 09 Jan '24

09 Jan '24
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8UOP9 -------------------------------- reserve space for bpf related structures. Signed-off-by: Pu Lehui <pulehui(a)huawei.com> --- include/linux/bpf.h | 115 +++++++++++++++++++++++++++++++++++ include/linux/bpf_verifier.h | 36 +++++++++++ include/uapi/linux/bpf.h | 16 +++++ 3 files changed, 167 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 392f581af2ce..f37e681cd4f5 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -29,6 +29,7 @@ #include <linux/rcupdate_trace.h> #include <linux/static_call.h> #include <linux/memcontrol.h> +#include <linux/kabi.h> struct bpf_verifier_env; struct bpf_verifier_log; @@ -163,6 +164,11 @@ struct bpf_map_ops { u64 (*map_mem_usage)(const struct bpf_map *map); + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + /* BTF id of struct allocated by map_alloc */ int *map_btf_id; @@ -288,6 +294,11 @@ struct bpf_map { bool bypass_spec_v1; bool frozen; /* write-once; write-protected by freeze_mutex */ s64 __percpu *elem_count; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static inline const char *btf_field_type_name(enum btf_field_type type) @@ -664,6 +675,13 @@ enum bpf_type_flag { /* DYNPTR points to xdp_buff */ DYNPTR_TYPE_XDP = BIT(16 + BPF_BASE_TYPE_BITS), +#ifdef CONFIG_KABI_RESERVE + BPF_TYPE_FLAG_RESERVE_1 = BIT(17 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_2 = BIT(18 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_3 = BIT(19 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_4 = BIT(20 + BPF_BASE_TYPE_BITS), +#endif + __BPF_TYPE_FLAG_MAX, __BPF_TYPE_LAST_FLAG = __BPF_TYPE_FLAG_MAX - 1, }; @@ -730,6 +748,13 @@ enum bpf_arg_type { /* Pointer to valid memory of size known at compile time. */ ARG_PTR_TO_FIXED_SIZE_MEM = MEM_FIXED_SIZE | ARG_PTR_TO_MEM, +#ifdef CONFIG_KABI_RESERVE + BPF_ARG_TYPE_RESERVE_1, + BPF_ARG_TYPE_RESERVE_2, + BPF_ARG_TYPE_RESERVE_3, + BPF_ARG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -760,6 +785,13 @@ enum bpf_return_type { RET_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID, RET_PTR_TO_BTF_ID_TRUSTED = PTR_TRUSTED | RET_PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_RET_TYPE_RESERVE_1, + BPF_RET_TYPE_RESERVE_2, + BPF_RET_TYPE_RESERVE_3, + BPF_RET_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -807,6 +839,9 @@ struct bpf_func_proto { }; int *ret_btf_id; /* return value btf_id */ bool (*allowed)(const struct bpf_prog *prog); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* bpf_context is intentionally undefined structure. Pointer to bpf_context is @@ -875,6 +910,13 @@ enum bpf_reg_type { PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK, PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_REG_TYPE_RESERVE_1, + BPF_REG_TYPE_RESERVE_2, + BPF_REG_TYPE_RESERVE_3, + BPF_REG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -895,6 +937,9 @@ struct bpf_insn_access_aux { }; }; struct bpf_verifier_log *log; /* for verbose logs */ + + KABI_RESERVE(1) + KABI_RESERVE(2) }; static inline void @@ -942,6 +987,11 @@ struct bpf_verifier_ops { int (*btf_struct_access)(struct bpf_verifier_log *log, const struct bpf_reg_state *reg, int off, int size); + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_prog_offload_ops { @@ -1121,6 +1171,9 @@ struct bpf_tramp_image { struct rcu_head rcu; struct work_struct work; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_trampoline { @@ -1149,6 +1202,11 @@ struct bpf_trampoline { /* Executable image of trampoline */ struct bpf_tramp_image *cur_image; struct module *mod; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_attach_target_info { @@ -1180,6 +1238,11 @@ struct bpf_dispatcher { struct static_call_key *sc_key; void *sc_tramp; #endif + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static __always_inline __nocfi unsigned int bpf_dispatcher_nop_func( @@ -1339,6 +1402,9 @@ static inline bool bpf_prog_has_trampoline(const struct bpf_prog *prog) struct bpf_func_info_aux { u16 linkage; bool unreliable; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; enum bpf_jit_poke_reason { @@ -1361,6 +1427,9 @@ struct bpf_jit_poke_descriptor { u8 adj_off; u16 reason; u32 insn_idx; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* reg_type info for ctx arguments */ @@ -1368,6 +1437,9 @@ struct bpf_ctx_arg_aux { u32 offset; enum bpf_reg_type reg_type; u32 btf_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct btf_mod_pair { @@ -1465,6 +1537,15 @@ struct bpf_prog_aux { struct work_struct work; struct rcu_head rcu; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) }; struct bpf_prog { @@ -1499,6 +1580,11 @@ struct bpf_prog { DECLARE_FLEX_ARRAY(struct sock_filter, insns); DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_array_aux { @@ -1507,6 +1593,9 @@ struct bpf_array_aux { struct bpf_map *map; struct mutex poke_mutex; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link { @@ -1516,6 +1605,9 @@ struct bpf_link { const struct bpf_link_ops *ops; struct bpf_prog *prog; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link_ops { @@ -1529,12 +1621,18 @@ struct bpf_link_ops { struct bpf_link_info *info); int (*update_map)(struct bpf_link *link, struct bpf_map *new_map, struct bpf_map *old_map); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_tramp_link { struct bpf_link link; struct hlist_node tramp_hlist; u64 cookie; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_shim_tramp_link { @@ -1554,6 +1652,9 @@ struct bpf_link_primer { struct file *file; int fd; u32 id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_struct_ops_value; @@ -1626,6 +1727,11 @@ struct bpf_struct_ops { struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; u32 type_id; u32 value_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) @@ -1727,6 +1833,9 @@ struct bpf_array { DECLARE_FLEX_ARRAY(void *, ptrs) __aligned(8); DECLARE_FLEX_ARRAY(void __percpu *, pptrs) __aligned(8); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; #define BPF_COMPLEXITY_LIMIT_INSNS 1000000 /* yes. 1M insns */ @@ -2222,6 +2331,9 @@ struct bpf_iter_aux_info { enum bpf_iter_task_type type; u32 pid; } task; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; typedef int (*bpf_iter_attach_target_t)(struct bpf_prog *prog, @@ -2252,6 +2364,9 @@ struct bpf_iter_reg { u32 feature; struct bpf_ctx_arg_aux ctx_arg_info[BPF_ITER_CTX_ARG_MAX]; const struct bpf_iter_seq_info *seq_info; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_iter_meta { diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index b6e58dab8e27..78ad34886e17 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -8,6 +8,7 @@ #include <linux/btf.h> /* for struct btf and btf_id() */ #include <linux/filter.h> /* for MAX_BPF_STACK */ #include <linux/tnum.h> +#include <linux/kabi.h> /* Maximum variable offset umax_value permitted when resolving memory accesses. * In practice this is far bigger than any realistic pointer offset; this limit @@ -225,6 +226,11 @@ struct bpf_reg_state { enum bpf_reg_liveness live; /* if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety */ bool precise; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; enum bpf_stack_slot_type { @@ -273,6 +279,11 @@ struct bpf_reference_state { * exiting a callback function. */ int callback_ref; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; /* state of the program: @@ -306,6 +317,11 @@ struct bpf_func_state { struct bpf_reference_state *refs; int allocated_stack; struct bpf_stack_state *stack; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_idx_pair { @@ -383,6 +399,11 @@ struct bpf_verifier_state { */ struct bpf_idx_pair *jmp_history; u32 jmp_history_cnt; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define bpf_get_spilled_reg(slot, frame) \ @@ -490,6 +511,11 @@ struct bpf_insn_aux_data { * this instruction, regardless of any heuristics */ bool force_checkpoint; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */ @@ -541,6 +567,11 @@ struct bpf_subprog_info { bool tail_call_reachable; bool has_ld_abs; bool is_async_cb; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_verifier_env; @@ -640,6 +671,11 @@ struct bpf_verifier_env { * e.g., in reg_type_str() to generate reg_type string */ char tmp_str_buf[TMP_STR_BUF_LEN]; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4924f0cde1bc..d0171d5461a5 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -944,6 +944,10 @@ enum bpf_map_type { BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_USER_RINGBUF, BPF_MAP_TYPE_CGRP_STORAGE, + BPF_MAP_TYPE_RESERVE_1, + BPF_MAP_TYPE_RESERVE_2, + BPF_MAP_TYPE_RESERVE_3, + BPF_MAP_TYPE_RESERVE_4, }; /* Note that tracing related programs such as @@ -988,6 +992,10 @@ enum bpf_prog_type { BPF_PROG_TYPE_SK_LOOKUP, BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ BPF_PROG_TYPE_NETFILTER, + BPF_PROG_TYPE_RESERVE_1, + BPF_PROG_TYPE_RESERVE_2, + BPF_PROG_TYPE_RESERVE_3, + BPF_PROG_TYPE_RESERVE_4, }; enum bpf_attach_type { @@ -1040,6 +1048,10 @@ enum bpf_attach_type { BPF_TCX_INGRESS, BPF_TCX_EGRESS, BPF_TRACE_UPROBE_MULTI, + BPF_ATTACH_TYPE_RESERVE_1, + BPF_ATTACH_TYPE_RESERVE_2, + BPF_ATTACH_TYPE_RESERVE_3, + BPF_ATTACH_TYPE_RESERVE_4, __MAX_BPF_ATTACH_TYPE }; @@ -1059,6 +1071,10 @@ enum bpf_link_type { BPF_LINK_TYPE_NETFILTER = 10, BPF_LINK_TYPE_TCX = 11, BPF_LINK_TYPE_UPROBE_MULTI = 12, + BPF_LINK_TYPE_RESERVE_1 = 13, + BPF_LINK_TYPE_RESERVE_2 = 14, + BPF_LINK_TYPE_RESERVE_3 = 15, + BPF_LINK_TYPE_RESERVE_4 = 16, MAX_BPF_LINK_TYPE, }; -- 2.34.1
1 0
0 0
[PATCH OLK-6.6] kabi: reserve space for bpf related structures
by Pu Lehui 09 Jan '24

09 Jan '24
From: Pu Lehui <pulehui(a)huaweicloud.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8UOP9 -------------------------------- reserve space for bpf related structures. Signed-off-by: Pu Lehui <pulehui(a)huawei.com> --- include/linux/bpf.h | 115 +++++++++++++++++++++++++++++++++++ include/linux/bpf_verifier.h | 36 +++++++++++ include/uapi/linux/bpf.h | 16 +++++ 3 files changed, 167 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 392f581af2ce..f37e681cd4f5 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -29,6 +29,7 @@ #include <linux/rcupdate_trace.h> #include <linux/static_call.h> #include <linux/memcontrol.h> +#include <linux/kabi.h> struct bpf_verifier_env; struct bpf_verifier_log; @@ -163,6 +164,11 @@ struct bpf_map_ops { u64 (*map_mem_usage)(const struct bpf_map *map); + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + /* BTF id of struct allocated by map_alloc */ int *map_btf_id; @@ -288,6 +294,11 @@ struct bpf_map { bool bypass_spec_v1; bool frozen; /* write-once; write-protected by freeze_mutex */ s64 __percpu *elem_count; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static inline const char *btf_field_type_name(enum btf_field_type type) @@ -664,6 +675,13 @@ enum bpf_type_flag { /* DYNPTR points to xdp_buff */ DYNPTR_TYPE_XDP = BIT(16 + BPF_BASE_TYPE_BITS), +#ifdef CONFIG_KABI_RESERVE + BPF_TYPE_FLAG_RESERVE_1 = BIT(17 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_2 = BIT(18 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_3 = BIT(19 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_4 = BIT(20 + BPF_BASE_TYPE_BITS), +#endif + __BPF_TYPE_FLAG_MAX, __BPF_TYPE_LAST_FLAG = __BPF_TYPE_FLAG_MAX - 1, }; @@ -730,6 +748,13 @@ enum bpf_arg_type { /* Pointer to valid memory of size known at compile time. */ ARG_PTR_TO_FIXED_SIZE_MEM = MEM_FIXED_SIZE | ARG_PTR_TO_MEM, +#ifdef CONFIG_KABI_RESERVE + BPF_ARG_TYPE_RESERVE_1, + BPF_ARG_TYPE_RESERVE_2, + BPF_ARG_TYPE_RESERVE_3, + BPF_ARG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -760,6 +785,13 @@ enum bpf_return_type { RET_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID, RET_PTR_TO_BTF_ID_TRUSTED = PTR_TRUSTED | RET_PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_RET_TYPE_RESERVE_1, + BPF_RET_TYPE_RESERVE_2, + BPF_RET_TYPE_RESERVE_3, + BPF_RET_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -807,6 +839,9 @@ struct bpf_func_proto { }; int *ret_btf_id; /* return value btf_id */ bool (*allowed)(const struct bpf_prog *prog); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* bpf_context is intentionally undefined structure. Pointer to bpf_context is @@ -875,6 +910,13 @@ enum bpf_reg_type { PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK, PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_REG_TYPE_RESERVE_1, + BPF_REG_TYPE_RESERVE_2, + BPF_REG_TYPE_RESERVE_3, + BPF_REG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -895,6 +937,9 @@ struct bpf_insn_access_aux { }; }; struct bpf_verifier_log *log; /* for verbose logs */ + + KABI_RESERVE(1) + KABI_RESERVE(2) }; static inline void @@ -942,6 +987,11 @@ struct bpf_verifier_ops { int (*btf_struct_access)(struct bpf_verifier_log *log, const struct bpf_reg_state *reg, int off, int size); + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_prog_offload_ops { @@ -1121,6 +1171,9 @@ struct bpf_tramp_image { struct rcu_head rcu; struct work_struct work; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_trampoline { @@ -1149,6 +1202,11 @@ struct bpf_trampoline { /* Executable image of trampoline */ struct bpf_tramp_image *cur_image; struct module *mod; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_attach_target_info { @@ -1180,6 +1238,11 @@ struct bpf_dispatcher { struct static_call_key *sc_key; void *sc_tramp; #endif + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static __always_inline __nocfi unsigned int bpf_dispatcher_nop_func( @@ -1339,6 +1402,9 @@ static inline bool bpf_prog_has_trampoline(const struct bpf_prog *prog) struct bpf_func_info_aux { u16 linkage; bool unreliable; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; enum bpf_jit_poke_reason { @@ -1361,6 +1427,9 @@ struct bpf_jit_poke_descriptor { u8 adj_off; u16 reason; u32 insn_idx; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* reg_type info for ctx arguments */ @@ -1368,6 +1437,9 @@ struct bpf_ctx_arg_aux { u32 offset; enum bpf_reg_type reg_type; u32 btf_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct btf_mod_pair { @@ -1465,6 +1537,15 @@ struct bpf_prog_aux { struct work_struct work; struct rcu_head rcu; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) }; struct bpf_prog { @@ -1499,6 +1580,11 @@ struct bpf_prog { DECLARE_FLEX_ARRAY(struct sock_filter, insns); DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_array_aux { @@ -1507,6 +1593,9 @@ struct bpf_array_aux { struct bpf_map *map; struct mutex poke_mutex; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link { @@ -1516,6 +1605,9 @@ struct bpf_link { const struct bpf_link_ops *ops; struct bpf_prog *prog; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link_ops { @@ -1529,12 +1621,18 @@ struct bpf_link_ops { struct bpf_link_info *info); int (*update_map)(struct bpf_link *link, struct bpf_map *new_map, struct bpf_map *old_map); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_tramp_link { struct bpf_link link; struct hlist_node tramp_hlist; u64 cookie; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_shim_tramp_link { @@ -1554,6 +1652,9 @@ struct bpf_link_primer { struct file *file; int fd; u32 id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_struct_ops_value; @@ -1626,6 +1727,11 @@ struct bpf_struct_ops { struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; u32 type_id; u32 value_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) @@ -1727,6 +1833,9 @@ struct bpf_array { DECLARE_FLEX_ARRAY(void *, ptrs) __aligned(8); DECLARE_FLEX_ARRAY(void __percpu *, pptrs) __aligned(8); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; #define BPF_COMPLEXITY_LIMIT_INSNS 1000000 /* yes. 1M insns */ @@ -2222,6 +2331,9 @@ struct bpf_iter_aux_info { enum bpf_iter_task_type type; u32 pid; } task; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; typedef int (*bpf_iter_attach_target_t)(struct bpf_prog *prog, @@ -2252,6 +2364,9 @@ struct bpf_iter_reg { u32 feature; struct bpf_ctx_arg_aux ctx_arg_info[BPF_ITER_CTX_ARG_MAX]; const struct bpf_iter_seq_info *seq_info; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_iter_meta { diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index b6e58dab8e27..78ad34886e17 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -8,6 +8,7 @@ #include <linux/btf.h> /* for struct btf and btf_id() */ #include <linux/filter.h> /* for MAX_BPF_STACK */ #include <linux/tnum.h> +#include <linux/kabi.h> /* Maximum variable offset umax_value permitted when resolving memory accesses. * In practice this is far bigger than any realistic pointer offset; this limit @@ -225,6 +226,11 @@ struct bpf_reg_state { enum bpf_reg_liveness live; /* if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety */ bool precise; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; enum bpf_stack_slot_type { @@ -273,6 +279,11 @@ struct bpf_reference_state { * exiting a callback function. */ int callback_ref; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; /* state of the program: @@ -306,6 +317,11 @@ struct bpf_func_state { struct bpf_reference_state *refs; int allocated_stack; struct bpf_stack_state *stack; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_idx_pair { @@ -383,6 +399,11 @@ struct bpf_verifier_state { */ struct bpf_idx_pair *jmp_history; u32 jmp_history_cnt; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define bpf_get_spilled_reg(slot, frame) \ @@ -490,6 +511,11 @@ struct bpf_insn_aux_data { * this instruction, regardless of any heuristics */ bool force_checkpoint; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */ @@ -541,6 +567,11 @@ struct bpf_subprog_info { bool tail_call_reachable; bool has_ld_abs; bool is_async_cb; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_verifier_env; @@ -640,6 +671,11 @@ struct bpf_verifier_env { * e.g., in reg_type_str() to generate reg_type string */ char tmp_str_buf[TMP_STR_BUF_LEN]; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4924f0cde1bc..d0171d5461a5 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -944,6 +944,10 @@ enum bpf_map_type { BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_USER_RINGBUF, BPF_MAP_TYPE_CGRP_STORAGE, + BPF_MAP_TYPE_RESERVE_1, + BPF_MAP_TYPE_RESERVE_2, + BPF_MAP_TYPE_RESERVE_3, + BPF_MAP_TYPE_RESERVE_4, }; /* Note that tracing related programs such as @@ -988,6 +992,10 @@ enum bpf_prog_type { BPF_PROG_TYPE_SK_LOOKUP, BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ BPF_PROG_TYPE_NETFILTER, + BPF_PROG_TYPE_RESERVE_1, + BPF_PROG_TYPE_RESERVE_2, + BPF_PROG_TYPE_RESERVE_3, + BPF_PROG_TYPE_RESERVE_4, }; enum bpf_attach_type { @@ -1040,6 +1048,10 @@ enum bpf_attach_type { BPF_TCX_INGRESS, BPF_TCX_EGRESS, BPF_TRACE_UPROBE_MULTI, + BPF_ATTACH_TYPE_RESERVE_1, + BPF_ATTACH_TYPE_RESERVE_2, + BPF_ATTACH_TYPE_RESERVE_3, + BPF_ATTACH_TYPE_RESERVE_4, __MAX_BPF_ATTACH_TYPE }; @@ -1059,6 +1071,10 @@ enum bpf_link_type { BPF_LINK_TYPE_NETFILTER = 10, BPF_LINK_TYPE_TCX = 11, BPF_LINK_TYPE_UPROBE_MULTI = 12, + BPF_LINK_TYPE_RESERVE_1 = 13, + BPF_LINK_TYPE_RESERVE_2 = 14, + BPF_LINK_TYPE_RESERVE_3 = 15, + BPF_LINK_TYPE_RESERVE_4 = 16, MAX_BPF_LINK_TYPE, }; -- 2.34.1
1 0
0 0
[PATCH OLK-6.6] kabi: reserve space for bpf related structures
by Pu Lehui 09 Jan '24

09 Jan '24
From: Pu Lehui <pulehui(a)huaweicloud.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8UOP9 -------------------------------- reserve space for bpf related structures. Signed-off-by: Pu Lehui <pulehui(a)huawei.com> --- include/linux/bpf.h | 115 +++++++++++++++++++++++++++++++++++ include/linux/bpf_verifier.h | 36 +++++++++++ include/uapi/linux/bpf.h | 16 +++++ 3 files changed, 167 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 392f581af2ce..f37e681cd4f5 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -29,6 +29,7 @@ #include <linux/rcupdate_trace.h> #include <linux/static_call.h> #include <linux/memcontrol.h> +#include <linux/kabi.h> struct bpf_verifier_env; struct bpf_verifier_log; @@ -163,6 +164,11 @@ struct bpf_map_ops { u64 (*map_mem_usage)(const struct bpf_map *map); + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + /* BTF id of struct allocated by map_alloc */ int *map_btf_id; @@ -288,6 +294,11 @@ struct bpf_map { bool bypass_spec_v1; bool frozen; /* write-once; write-protected by freeze_mutex */ s64 __percpu *elem_count; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static inline const char *btf_field_type_name(enum btf_field_type type) @@ -664,6 +675,13 @@ enum bpf_type_flag { /* DYNPTR points to xdp_buff */ DYNPTR_TYPE_XDP = BIT(16 + BPF_BASE_TYPE_BITS), +#ifdef CONFIG_KABI_RESERVE + BPF_TYPE_FLAG_RESERVE_1 = BIT(17 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_2 = BIT(18 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_3 = BIT(19 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_4 = BIT(20 + BPF_BASE_TYPE_BITS), +#endif + __BPF_TYPE_FLAG_MAX, __BPF_TYPE_LAST_FLAG = __BPF_TYPE_FLAG_MAX - 1, }; @@ -730,6 +748,13 @@ enum bpf_arg_type { /* Pointer to valid memory of size known at compile time. */ ARG_PTR_TO_FIXED_SIZE_MEM = MEM_FIXED_SIZE | ARG_PTR_TO_MEM, +#ifdef CONFIG_KABI_RESERVE + BPF_ARG_TYPE_RESERVE_1, + BPF_ARG_TYPE_RESERVE_2, + BPF_ARG_TYPE_RESERVE_3, + BPF_ARG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -760,6 +785,13 @@ enum bpf_return_type { RET_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID, RET_PTR_TO_BTF_ID_TRUSTED = PTR_TRUSTED | RET_PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_RET_TYPE_RESERVE_1, + BPF_RET_TYPE_RESERVE_2, + BPF_RET_TYPE_RESERVE_3, + BPF_RET_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -807,6 +839,9 @@ struct bpf_func_proto { }; int *ret_btf_id; /* return value btf_id */ bool (*allowed)(const struct bpf_prog *prog); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* bpf_context is intentionally undefined structure. Pointer to bpf_context is @@ -875,6 +910,13 @@ enum bpf_reg_type { PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK, PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_REG_TYPE_RESERVE_1, + BPF_REG_TYPE_RESERVE_2, + BPF_REG_TYPE_RESERVE_3, + BPF_REG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -895,6 +937,9 @@ struct bpf_insn_access_aux { }; }; struct bpf_verifier_log *log; /* for verbose logs */ + + KABI_RESERVE(1) + KABI_RESERVE(2) }; static inline void @@ -942,6 +987,11 @@ struct bpf_verifier_ops { int (*btf_struct_access)(struct bpf_verifier_log *log, const struct bpf_reg_state *reg, int off, int size); + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_prog_offload_ops { @@ -1121,6 +1171,9 @@ struct bpf_tramp_image { struct rcu_head rcu; struct work_struct work; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_trampoline { @@ -1149,6 +1202,11 @@ struct bpf_trampoline { /* Executable image of trampoline */ struct bpf_tramp_image *cur_image; struct module *mod; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_attach_target_info { @@ -1180,6 +1238,11 @@ struct bpf_dispatcher { struct static_call_key *sc_key; void *sc_tramp; #endif + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static __always_inline __nocfi unsigned int bpf_dispatcher_nop_func( @@ -1339,6 +1402,9 @@ static inline bool bpf_prog_has_trampoline(const struct bpf_prog *prog) struct bpf_func_info_aux { u16 linkage; bool unreliable; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; enum bpf_jit_poke_reason { @@ -1361,6 +1427,9 @@ struct bpf_jit_poke_descriptor { u8 adj_off; u16 reason; u32 insn_idx; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* reg_type info for ctx arguments */ @@ -1368,6 +1437,9 @@ struct bpf_ctx_arg_aux { u32 offset; enum bpf_reg_type reg_type; u32 btf_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct btf_mod_pair { @@ -1465,6 +1537,15 @@ struct bpf_prog_aux { struct work_struct work; struct rcu_head rcu; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) }; struct bpf_prog { @@ -1499,6 +1580,11 @@ struct bpf_prog { DECLARE_FLEX_ARRAY(struct sock_filter, insns); DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_array_aux { @@ -1507,6 +1593,9 @@ struct bpf_array_aux { struct bpf_map *map; struct mutex poke_mutex; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link { @@ -1516,6 +1605,9 @@ struct bpf_link { const struct bpf_link_ops *ops; struct bpf_prog *prog; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link_ops { @@ -1529,12 +1621,18 @@ struct bpf_link_ops { struct bpf_link_info *info); int (*update_map)(struct bpf_link *link, struct bpf_map *new_map, struct bpf_map *old_map); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_tramp_link { struct bpf_link link; struct hlist_node tramp_hlist; u64 cookie; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_shim_tramp_link { @@ -1554,6 +1652,9 @@ struct bpf_link_primer { struct file *file; int fd; u32 id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_struct_ops_value; @@ -1626,6 +1727,11 @@ struct bpf_struct_ops { struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; u32 type_id; u32 value_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) @@ -1727,6 +1833,9 @@ struct bpf_array { DECLARE_FLEX_ARRAY(void *, ptrs) __aligned(8); DECLARE_FLEX_ARRAY(void __percpu *, pptrs) __aligned(8); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; #define BPF_COMPLEXITY_LIMIT_INSNS 1000000 /* yes. 1M insns */ @@ -2222,6 +2331,9 @@ struct bpf_iter_aux_info { enum bpf_iter_task_type type; u32 pid; } task; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; typedef int (*bpf_iter_attach_target_t)(struct bpf_prog *prog, @@ -2252,6 +2364,9 @@ struct bpf_iter_reg { u32 feature; struct bpf_ctx_arg_aux ctx_arg_info[BPF_ITER_CTX_ARG_MAX]; const struct bpf_iter_seq_info *seq_info; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_iter_meta { diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index b6e58dab8e27..78ad34886e17 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -8,6 +8,7 @@ #include <linux/btf.h> /* for struct btf and btf_id() */ #include <linux/filter.h> /* for MAX_BPF_STACK */ #include <linux/tnum.h> +#include <linux/kabi.h> /* Maximum variable offset umax_value permitted when resolving memory accesses. * In practice this is far bigger than any realistic pointer offset; this limit @@ -225,6 +226,11 @@ struct bpf_reg_state { enum bpf_reg_liveness live; /* if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety */ bool precise; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; enum bpf_stack_slot_type { @@ -273,6 +279,11 @@ struct bpf_reference_state { * exiting a callback function. */ int callback_ref; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; /* state of the program: @@ -306,6 +317,11 @@ struct bpf_func_state { struct bpf_reference_state *refs; int allocated_stack; struct bpf_stack_state *stack; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_idx_pair { @@ -383,6 +399,11 @@ struct bpf_verifier_state { */ struct bpf_idx_pair *jmp_history; u32 jmp_history_cnt; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define bpf_get_spilled_reg(slot, frame) \ @@ -490,6 +511,11 @@ struct bpf_insn_aux_data { * this instruction, regardless of any heuristics */ bool force_checkpoint; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */ @@ -541,6 +567,11 @@ struct bpf_subprog_info { bool tail_call_reachable; bool has_ld_abs; bool is_async_cb; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_verifier_env; @@ -640,6 +671,11 @@ struct bpf_verifier_env { * e.g., in reg_type_str() to generate reg_type string */ char tmp_str_buf[TMP_STR_BUF_LEN]; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4924f0cde1bc..d0171d5461a5 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -944,6 +944,10 @@ enum bpf_map_type { BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_USER_RINGBUF, BPF_MAP_TYPE_CGRP_STORAGE, + BPF_MAP_TYPE_RESERVE_1, + BPF_MAP_TYPE_RESERVE_2, + BPF_MAP_TYPE_RESERVE_3, + BPF_MAP_TYPE_RESERVE_4, }; /* Note that tracing related programs such as @@ -988,6 +992,10 @@ enum bpf_prog_type { BPF_PROG_TYPE_SK_LOOKUP, BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ BPF_PROG_TYPE_NETFILTER, + BPF_PROG_TYPE_RESERVE_1, + BPF_PROG_TYPE_RESERVE_2, + BPF_PROG_TYPE_RESERVE_3, + BPF_PROG_TYPE_RESERVE_4, }; enum bpf_attach_type { @@ -1040,6 +1048,10 @@ enum bpf_attach_type { BPF_TCX_INGRESS, BPF_TCX_EGRESS, BPF_TRACE_UPROBE_MULTI, + BPF_ATTACH_TYPE_RESERVE_1, + BPF_ATTACH_TYPE_RESERVE_2, + BPF_ATTACH_TYPE_RESERVE_3, + BPF_ATTACH_TYPE_RESERVE_4, __MAX_BPF_ATTACH_TYPE }; @@ -1059,6 +1071,10 @@ enum bpf_link_type { BPF_LINK_TYPE_NETFILTER = 10, BPF_LINK_TYPE_TCX = 11, BPF_LINK_TYPE_UPROBE_MULTI = 12, + BPF_LINK_TYPE_RESERVE_1 = 13, + BPF_LINK_TYPE_RESERVE_2 = 14, + BPF_LINK_TYPE_RESERVE_3 = 15, + BPF_LINK_TYPE_RESERVE_4 = 16, MAX_BPF_LINK_TYPE, }; -- 2.34.1
1 0
0 0
[PATCH OLK-6.6] kabi: reserve space for bpf related structures
by Pu Lehui 09 Jan '24

09 Jan '24
From: Pu Lehui <pulehui(a)huaweicloud.com> hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8UOP9 -------------------------------- reserve space for bpf related structures. Signed-off-by: Pu Lehui <pulehui(a)huawei.com> --- include/linux/bpf.h | 115 +++++++++++++++++++++++++++++++++++ include/linux/bpf_verifier.h | 36 +++++++++++ include/uapi/linux/bpf.h | 16 +++++ 3 files changed, 167 insertions(+) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 392f581af2ce..f37e681cd4f5 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -29,6 +29,7 @@ #include <linux/rcupdate_trace.h> #include <linux/static_call.h> #include <linux/memcontrol.h> +#include <linux/kabi.h> struct bpf_verifier_env; struct bpf_verifier_log; @@ -163,6 +164,11 @@ struct bpf_map_ops { u64 (*map_mem_usage)(const struct bpf_map *map); + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + /* BTF id of struct allocated by map_alloc */ int *map_btf_id; @@ -288,6 +294,11 @@ struct bpf_map { bool bypass_spec_v1; bool frozen; /* write-once; write-protected by freeze_mutex */ s64 __percpu *elem_count; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static inline const char *btf_field_type_name(enum btf_field_type type) @@ -664,6 +675,13 @@ enum bpf_type_flag { /* DYNPTR points to xdp_buff */ DYNPTR_TYPE_XDP = BIT(16 + BPF_BASE_TYPE_BITS), +#ifdef CONFIG_KABI_RESERVE + BPF_TYPE_FLAG_RESERVE_1 = BIT(17 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_2 = BIT(18 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_3 = BIT(19 + BPF_BASE_TYPE_BITS), + BPF_TYPE_FLAG_RESERVE_4 = BIT(20 + BPF_BASE_TYPE_BITS), +#endif + __BPF_TYPE_FLAG_MAX, __BPF_TYPE_LAST_FLAG = __BPF_TYPE_FLAG_MAX - 1, }; @@ -730,6 +748,13 @@ enum bpf_arg_type { /* Pointer to valid memory of size known at compile time. */ ARG_PTR_TO_FIXED_SIZE_MEM = MEM_FIXED_SIZE | ARG_PTR_TO_MEM, +#ifdef CONFIG_KABI_RESERVE + BPF_ARG_TYPE_RESERVE_1, + BPF_ARG_TYPE_RESERVE_2, + BPF_ARG_TYPE_RESERVE_3, + BPF_ARG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -760,6 +785,13 @@ enum bpf_return_type { RET_PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | RET_PTR_TO_BTF_ID, RET_PTR_TO_BTF_ID_TRUSTED = PTR_TRUSTED | RET_PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_RET_TYPE_RESERVE_1, + BPF_RET_TYPE_RESERVE_2, + BPF_RET_TYPE_RESERVE_3, + BPF_RET_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -807,6 +839,9 @@ struct bpf_func_proto { }; int *ret_btf_id; /* return value btf_id */ bool (*allowed)(const struct bpf_prog *prog); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* bpf_context is intentionally undefined structure. Pointer to bpf_context is @@ -875,6 +910,13 @@ enum bpf_reg_type { PTR_TO_TCP_SOCK_OR_NULL = PTR_MAYBE_NULL | PTR_TO_TCP_SOCK, PTR_TO_BTF_ID_OR_NULL = PTR_MAYBE_NULL | PTR_TO_BTF_ID, +#ifdef CONFIG_KABI_RESERVE + BPF_REG_TYPE_RESERVE_1, + BPF_REG_TYPE_RESERVE_2, + BPF_REG_TYPE_RESERVE_3, + BPF_REG_TYPE_RESERVE_4, +#endif + /* This must be the last entry. Its purpose is to ensure the enum is * wide enough to hold the higher bits reserved for bpf_type_flag. */ @@ -895,6 +937,9 @@ struct bpf_insn_access_aux { }; }; struct bpf_verifier_log *log; /* for verbose logs */ + + KABI_RESERVE(1) + KABI_RESERVE(2) }; static inline void @@ -942,6 +987,11 @@ struct bpf_verifier_ops { int (*btf_struct_access)(struct bpf_verifier_log *log, const struct bpf_reg_state *reg, int off, int size); + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_prog_offload_ops { @@ -1121,6 +1171,9 @@ struct bpf_tramp_image { struct rcu_head rcu; struct work_struct work; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_trampoline { @@ -1149,6 +1202,11 @@ struct bpf_trampoline { /* Executable image of trampoline */ struct bpf_tramp_image *cur_image; struct module *mod; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_attach_target_info { @@ -1180,6 +1238,11 @@ struct bpf_dispatcher { struct static_call_key *sc_key; void *sc_tramp; #endif + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; static __always_inline __nocfi unsigned int bpf_dispatcher_nop_func( @@ -1339,6 +1402,9 @@ static inline bool bpf_prog_has_trampoline(const struct bpf_prog *prog) struct bpf_func_info_aux { u16 linkage; bool unreliable; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; enum bpf_jit_poke_reason { @@ -1361,6 +1427,9 @@ struct bpf_jit_poke_descriptor { u8 adj_off; u16 reason; u32 insn_idx; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; /* reg_type info for ctx arguments */ @@ -1368,6 +1437,9 @@ struct bpf_ctx_arg_aux { u32 offset; enum bpf_reg_type reg_type; u32 btf_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct btf_mod_pair { @@ -1465,6 +1537,15 @@ struct bpf_prog_aux { struct work_struct work; struct rcu_head rcu; }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) }; struct bpf_prog { @@ -1499,6 +1580,11 @@ struct bpf_prog { DECLARE_FLEX_ARRAY(struct sock_filter, insns); DECLARE_FLEX_ARRAY(struct bpf_insn, insnsi); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_array_aux { @@ -1507,6 +1593,9 @@ struct bpf_array_aux { struct bpf_map *map; struct mutex poke_mutex; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link { @@ -1516,6 +1605,9 @@ struct bpf_link { const struct bpf_link_ops *ops; struct bpf_prog *prog; struct work_struct work; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_link_ops { @@ -1529,12 +1621,18 @@ struct bpf_link_ops { struct bpf_link_info *info); int (*update_map)(struct bpf_link *link, struct bpf_map *new_map, struct bpf_map *old_map); + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_tramp_link { struct bpf_link link; struct hlist_node tramp_hlist; u64 cookie; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_shim_tramp_link { @@ -1554,6 +1652,9 @@ struct bpf_link_primer { struct file *file; int fd; u32 id; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_struct_ops_value; @@ -1626,6 +1727,11 @@ struct bpf_struct_ops { struct btf_func_model func_models[BPF_STRUCT_OPS_MAX_NR_MEMBERS]; u32 type_id; u32 value_id; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) @@ -1727,6 +1833,9 @@ struct bpf_array { DECLARE_FLEX_ARRAY(void *, ptrs) __aligned(8); DECLARE_FLEX_ARRAY(void __percpu *, pptrs) __aligned(8); }; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; #define BPF_COMPLEXITY_LIMIT_INSNS 1000000 /* yes. 1M insns */ @@ -2222,6 +2331,9 @@ struct bpf_iter_aux_info { enum bpf_iter_task_type type; u32 pid; } task; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; typedef int (*bpf_iter_attach_target_t)(struct bpf_prog *prog, @@ -2252,6 +2364,9 @@ struct bpf_iter_reg { u32 feature; struct bpf_ctx_arg_aux ctx_arg_info[BPF_ITER_CTX_ARG_MAX]; const struct bpf_iter_seq_info *seq_info; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct bpf_iter_meta { diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index b6e58dab8e27..78ad34886e17 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h @@ -8,6 +8,7 @@ #include <linux/btf.h> /* for struct btf and btf_id() */ #include <linux/filter.h> /* for MAX_BPF_STACK */ #include <linux/tnum.h> +#include <linux/kabi.h> /* Maximum variable offset umax_value permitted when resolving memory accesses. * In practice this is far bigger than any realistic pointer offset; this limit @@ -225,6 +226,11 @@ struct bpf_reg_state { enum bpf_reg_liveness live; /* if (!precise && SCALAR_VALUE) min/max/tnum don't affect safety */ bool precise; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; enum bpf_stack_slot_type { @@ -273,6 +279,11 @@ struct bpf_reference_state { * exiting a callback function. */ int callback_ref; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; /* state of the program: @@ -306,6 +317,11 @@ struct bpf_func_state { struct bpf_reference_state *refs; int allocated_stack; struct bpf_stack_state *stack; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_idx_pair { @@ -383,6 +399,11 @@ struct bpf_verifier_state { */ struct bpf_idx_pair *jmp_history; u32 jmp_history_cnt; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define bpf_get_spilled_reg(slot, frame) \ @@ -490,6 +511,11 @@ struct bpf_insn_aux_data { * this instruction, regardless of any heuristics */ bool force_checkpoint; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; #define MAX_USED_MAPS 64 /* max number of maps accessed by one eBPF program */ @@ -541,6 +567,11 @@ struct bpf_subprog_info { bool tail_call_reachable; bool has_ld_abs; bool is_async_cb; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; struct bpf_verifier_env; @@ -640,6 +671,11 @@ struct bpf_verifier_env { * e.g., in reg_type_str() to generate reg_type string */ char tmp_str_buf[TMP_STR_BUF_LEN]; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log, diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 4924f0cde1bc..d0171d5461a5 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -944,6 +944,10 @@ enum bpf_map_type { BPF_MAP_TYPE_BLOOM_FILTER, BPF_MAP_TYPE_USER_RINGBUF, BPF_MAP_TYPE_CGRP_STORAGE, + BPF_MAP_TYPE_RESERVE_1, + BPF_MAP_TYPE_RESERVE_2, + BPF_MAP_TYPE_RESERVE_3, + BPF_MAP_TYPE_RESERVE_4, }; /* Note that tracing related programs such as @@ -988,6 +992,10 @@ enum bpf_prog_type { BPF_PROG_TYPE_SK_LOOKUP, BPF_PROG_TYPE_SYSCALL, /* a program that can execute syscalls */ BPF_PROG_TYPE_NETFILTER, + BPF_PROG_TYPE_RESERVE_1, + BPF_PROG_TYPE_RESERVE_2, + BPF_PROG_TYPE_RESERVE_3, + BPF_PROG_TYPE_RESERVE_4, }; enum bpf_attach_type { @@ -1040,6 +1048,10 @@ enum bpf_attach_type { BPF_TCX_INGRESS, BPF_TCX_EGRESS, BPF_TRACE_UPROBE_MULTI, + BPF_ATTACH_TYPE_RESERVE_1, + BPF_ATTACH_TYPE_RESERVE_2, + BPF_ATTACH_TYPE_RESERVE_3, + BPF_ATTACH_TYPE_RESERVE_4, __MAX_BPF_ATTACH_TYPE }; @@ -1059,6 +1071,10 @@ enum bpf_link_type { BPF_LINK_TYPE_NETFILTER = 10, BPF_LINK_TYPE_TCX = 11, BPF_LINK_TYPE_UPROBE_MULTI = 12, + BPF_LINK_TYPE_RESERVE_1 = 13, + BPF_LINK_TYPE_RESERVE_2 = 14, + BPF_LINK_TYPE_RESERVE_3 = 15, + BPF_LINK_TYPE_RESERVE_4 = 16, MAX_BPF_LINK_TYPE, }; -- 2.34.1
1 0
0 0
[PATCH V4 OLK-6.6 0/8] Spark SQL scenario bpf readahead optimization synchronization to OLK-6.6
by ZhaoLong Wang 09 Jan '24

09 Jan '24
CONFIG: CONFIG_DEBUG_INFO_BTF=y CONFIG_BPF_SYSCALL=y CONFIG_NF_CONNTRACK=y CONFIG_NF_CONNTRACK_MARK=y V2: - Using helpers function, such as i_size_read(), round_up - Fix commit log Signature - Fix the user-mode test program V3 - Do not use the round_up helper function. Use the correct calculation - err = -errno before printf V4 - Drop the "Conflict" in the commit log. Hou Tao (5): vfs: add bare tracepoints for vfs read and release fs: add helper fs_file_read_do_trace() xfs: add trace for read and release of regular file ext4: add trace for the read and release of regular file selftests/bpf: add demo for file read pattern detection Yufen Yu (1): readahead: introduce FMODE_CTL_WILLNEED to read first 2MB of file ZhaoLong Wang (2): VFS: Rolling Back the fmode macro definition and structure members selftests/bpf: Update the demo file_read_pattern to run on libbpf 1.0+ fs/ext4/file.c | 4 + fs/read_write.c | 38 +++++ fs/xfs/xfs_file.c | 3 + include/linux/fs.h | 37 +++++ include/trace/events/fs.h | 33 +++++ mm/readahead.c | 40 ++++- tools/testing/selftests/bpf/Makefile | 1 + .../testing/selftests/bpf/file_read_pattern.c | 76 ++++++++++ .../bpf/progs/file_read_pattern_prog.c | 137 ++++++++++++++++++ 9 files changed, 368 insertions(+), 1 deletion(-) create mode 100644 include/trace/events/fs.h create mode 100644 tools/testing/selftests/bpf/file_read_pattern.c create mode 100644 tools/testing/selftests/bpf/progs/file_read_pattern_prog.c -- 2.39.2
1 8
0 0
[PATCH OLK-6.6 0/1] arm64: Add non nmi ipi backtrace support
by Liao Chen 09 Jan '24

09 Jan '24
Dependencies: CONFIG_DETECT_HUNG_TASK=y CONFIG_WATCHDOG=y Li Zhengyu (1): arm64: Add non nmi ipi backtrace support arch/arm64/Kconfig | 8 +++++ arch/arm64/configs/openeuler_defconfig | 1 + arch/arm64/kernel/ipi_nmi.c | 41 ++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 5 deletions(-) -- 2.34.1
1 1
0 0
[PATCH OLK-6.6] kabi: Reserve space for perf subsystem related structures
by Yang Jihong 09 Jan '24

09 Jan '24
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8UOCZ -------------------------------- Reserve kabi space for `struct pmu`, `struct perf_event`, `struct perf_event_context`, `struct perf_cgroup_info` and `struct perf_sample_data`. Signed-off-by: Yang Jihong <yangjihong1(a)huawei.com> --- include/linux/perf_event.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index e846f87e2d09..a24aa95de1fc 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -62,6 +62,7 @@ struct perf_guest_info_callbacks { #include <linux/security.h> #include <linux/static_call.h> #include <linux/lockdep.h> +#include <linux/kabi.h> #include <asm/local.h> struct perf_callchain_entry { @@ -324,6 +325,11 @@ struct pmu { /* number of address filters this PMU can do */ unsigned int nr_addr_filters; + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + /* * Fully disable/enable this PMU, can be used to protect from the PMI * as well as for lazy/batch writing of the MSRs. @@ -540,6 +546,11 @@ struct pmu { * Check period value for PERF_EVENT_IOC_PERIOD ioctl. */ int (*check_period) (struct perf_event *event, u64 value); /* optional */ + + KABI_RESERVE(5) + KABI_RESERVE(6) + KABI_RESERVE(7) + KABI_RESERVE(8) }; enum perf_addr_filter_action_t { @@ -839,6 +850,13 @@ struct perf_event { * user. */ __u32 orig_type; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) + KABI_RESERVE(5) + KABI_RESERVE(6) #endif /* CONFIG_PERF_EVENTS */ }; @@ -965,6 +983,11 @@ struct perf_event_context { * that until the signal is delivered. */ local_t nr_pending; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) }; /* @@ -1040,6 +1063,9 @@ struct perf_cgroup_info { u64 timestamp; u64 timeoffset; int active; + + KABI_RESERVE(1) + KABI_RESERVE(2) }; struct perf_cgroup { @@ -1192,6 +1218,11 @@ struct perf_sample_data { u64 data_page_size; u64 code_page_size; u64 aux_size; + + KABI_RESERVE(1) + KABI_RESERVE(2) + KABI_RESERVE(3) + KABI_RESERVE(4) } ____cacheline_aligned; /* default value for data source */ -- 2.34.1
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 1360
  • 1361
  • 1362
  • 1363
  • 1364
  • 1365
  • 1366
  • ...
  • 1868
  • Older →

HyperKitty Powered by HyperKitty