pahole: Make encoding percpu vars into BTF optional.
v2 cover pahole: Make encoding percpu vars into BTF optional.
v1 -> v2:
- Use opt-out instead of opt-in. Rename the flag name to '--skip_encoding_btf_vars'
Previous commit f3d9054ba8ff ("btf_encoder: Teach pahole to store percpu variables in vmlinux BTF.") introduced a feature in btf_encoder that encodes global symbols in BTF. However, this feature is not protected by any flag. In order to avoid surprises after Pahole v1.18 rolls out, add a flag to toggle this feature off.
Also as a refactor, introduce '--btf_encode_force' to replace the old '--force' and '-j' option that is used to forcefully emit BTF.
Hao Luo (2):
btf_encoder: Allow disabling BTF var encoding.
btf_encoder: Introduce option '--btf_encode_force'
btf_encoder.c | 5 ++++- btf_encoder.h | 3 ++- pahole.c | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-)
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
PATCH v2 1/2 btf_encoder: Allow disabling BTF var encoding.
A new feature was introduced in commit f3d9054ba8ff ("btf_encoder:
Teach pahole to store percpu variables in vmlinux BTF.") which encodes kernel percpu variables into BTF. Add a flag --skip_encoding_btf_vars to allow users to toggle this feature off, so that the rollout of pahole v1.18 can be protected by potential bugs in this feature.
--- btf_encoder.c | 5 ++++- btf_encoder.h | 3 ++- pahole.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-)
btf_encoder.c +4 -1
@@ -237,7 +237,8 @@ static struct variable *hashaddr__find_variable(const struct hlist_head hashtablreturn NULL ; } -int cu__encode_btf (struct cu *cu,int verbose,bool force) +int cu__encode_btf (struct cu *cu,int verbose,bool force, +bool skip_encoding_vars) {bool add_index_type = false;uint32_t type_id_off;
@@ -314,6 +315,8 @@ int cu__encode_btf(struct cu *cu, int verbose, bool force) } } +if (skip_encoding_vars) + goto out;if (btfe->percpu_shndx ==0 || !btfe->symtab) goto out;
btf_encoder.h +2 -1
@@ -13,6 +13,7 @@ struct cu;int btf_encoder__encode (); -int cu__encode_btf (struct cu *cu,int verbose,bool force); +int cu__encode_btf (struct cu *cu,int verbose,bool force, +bool skip_encoding_vars);#endif /* _BTF_ENCODER_H_ */
pahole.c +10 -1
@@ -26,6 +26,7 @@static bool btf_encode;static bool ctf_encode;static bool first_obj_only; +static bool skip_encoding_btf_vars;static uint8_t class__include_anonymous;static uint8_t class__include_nested_anonymous;
@@ -809,6 +810,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;#define ARGP_header_type 314#define ARGP_size_bytes 315#define ARGP_range 316 +#define ARGP_skip_encoding_btf_vars 317static const struct argp_option pahole__options[] = { {
@@ -1087,6 +1089,11 @@ static const struct argp_option pahole__options[] = { .key = 'J', .doc = "Encode as BTF", }, + { + .name = "skip_encoding_btf_vars", + .key = ARGP_skip_encoding_btf_vars, + .doc ="Do not encode VARs in BTF." + }, { .name = "force", .key = 'j',
@@ -1207,6 +1214,8 @@ static error_t pahole__options_parser(int key, char *arg, conf.range = arg;break ;case ARGP_header_type: conf.header_type = arg;break ; +case ARGP_skip_encoding_btf_vars: + skip_encoding_btf_vars = true;break ;default :return ARGP_ERR_UNKNOWN ; }
@@ -2352,7 +2361,7 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, goto filter_it;if (btf_encode) { -cu__encode_btf (cu, global_verbose, force); +cu__encode_btf (cu, global_verbose, force, skip_encoding_btf_vars);return LSK__KEEPIT ; }
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
PATCH v2 2/2 btf_encoder: Introduce option '--btf_encode_force'
In reply to Hao LuoCommit f3d9054ba8ff ("btf_encoder: Teach pahole to store percpu variables in vmlinux BTF.") introduced an option '-j' that makes effort in emitting VAR entries in BTF. Before no one has been using this flag, replace the one-letter option '-j' with a full flag name '--btf_encode_force' to save '-j' for future uses.
--- pahole.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
pahole.c +8 -5
@@ -27,6 +27,7 @@ static bool btf_encode;static bool ctf_encode;static bool first_obj_only;static bool skip_encoding_btf_vars; +static bool btf_encode_force;static uint8_t class__include_anonymous;static uint8_t class__include_nested_anonymous;
@@ -62,7 +63,6 @@ static int show_reorg_steps;static const char *class_name;static LIST_HEAD (class_names);static char separator ='\t' ; -static bool force;static struct conf_fprintf conf = { .emit_stats =1 ,
@@ -811,6 +811,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;#define ARGP_size_bytes 315#define ARGP_range 316#define ARGP_skip_encoding_btf_vars 317 +#define ARGP_btf_encode_force 318static const struct argp_option pahole__options[] = { {
@@ -1095,8 +1096,8 @@ static const struct argp_option pahole__options[] = { .doc = "Do not encode VARs in BTF." }, { - .name = "force", - .key = 'j', + .name = "btf_encode_force", + .key = ARGP_btf_encode_force, .doc ="Ignore those symbols found invalid when encoding BTF." }, {
@@ -1143,7 +1144,6 @@ static error_t pahole__options_parser(int key, char *arg,case 'J' : btf_encode =1 ; conf_load.get_addr_info = true; no_bitfield_type_recode = true;break ; -case 'j' : force = true;break ;case 'l' : conf.show_first_biggest_size_base_type_member =1 ;break ;case 'M' : conf.show_only_data_members =1 ;break ;case 'm' : stats_formatter = nr_methods_formatter;break ;
@@ -1216,6 +1216,8 @@ static error_t pahole__options_parser(int key, char *arg, conf.header_type = arg;break ;case ARGP_skip_encoding_btf_vars: skip_encoding_btf_vars = true;break ; +case ARGP_btf_encode_force: + btf_encode_force = true;break ;default :return ARGP_ERR_UNKNOWN ; }
@@ -2361,7 +2363,8 @@ static enum load_steal_kind pahole_stealer(struct cu *cu, goto filter_it;if (btf_encode) { -cu__encode_btf (cu, global_verbose, force, skip_encoding_btf_vars); +cu__encode_btf (cu, global_verbose, btf_encode_force, + skip_encoding_btf_vars);return LSK__KEEPIT ; }
Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
Em Mon, Sep 21, 2020 at 12:53:08PM -0700, Hao Luo escreveu:
Quoted 13 lines
v1 -> v2:
- Use opt-out instead of opt-in. Rename the flag name to '--skip_encoding_btf_vars'Previous commit
f3d9054ba8ff("btf_encoder: Teach pahole to store percpu variables in vmlinux BTF.") introduced a feature inbtf_encoderthat encodes global symbols in BTF. However, this feature is not protected by any flag. In order to avoid surprises after Pahole v1.18 rolls out, add a flag to toggle this feature off.Also as a refactor, introduce '--btf_encode_force' to replace the old '--force' and '-j' option that is used to forcefully emit BTF.
Quoted 11 lines
Hao Luo (2):
btf_encoder: Allow disabling BTF var encoding.
btf_encoder: Introduce option '--btf_encode_force'btf_encoder.c | 5 ++++- btf_encoder.h | 3 ++- pahole.c | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-)Signature · 1 line
2.28.0.681.g6f77f65b4e-goog
You forgot to update the man page, I'll do it this time,
Thanks
- Arnaldo
Thanks, Arnaldo. I will remember to do it next time.
Hao
Quoted 32 lines · Arnaldo Carvalho de Melo
Em Mon, Sep 21, 2020 at 12:53:08PM -0700, Hao Luo escreveu:
Quoted 17 lines
v1 -> v2:
- Use opt-out instead of opt-in. Rename the flag name to '--skip_encoding_btf_vars'Previous commit
f3d9054ba8ff("btf_encoder: Teach pahole to store percpu variables in vmlinux BTF.") introduced a feature inbtf_encoderthat encodes global symbols in BTF. However, this feature is not protected by any flag. In order to avoid surprises after Pahole v1.18 rolls out, add a flag to toggle this feature off.Also as a refactor, introduce '--btf_encode_force' to replace the old '--force' and '-j' option that is used to forcefully emit BTF.
Hao Luo (2):
btf_encoder: Allow disabling BTF var encoding.
btf_encoder: Introduce option '--btf_encode_force'Quoted 7 lines
btf_encoder.c | 5 ++++- btf_encoder.h | 3 ++- pahole.c | 22 +++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-)--
2.28.0.681.g6f77f65b4e-googYou forgot to update the man page, I'll do it this time,
Thanks
- Arnaldo