Re: [PATCH v8 bpf-next 09/10] bpf: Add kfunc filter function to 'struct btf_kfunc_id_set'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/17/23 10:59 AM, Aditi Ghag wrote:
  static int btf_populate_kfunc_set(struct btf *btf, enum btf_kfunc_hook hook,
-				  struct btf_id_set8 *add_set)
+				  const struct btf_kfunc_id_set *kset)
  {
+	struct btf_kfunc_hook_filter *hook_filter;
+	struct btf_id_set8 *add_set = kset->set;
  	bool vmlinux_set = !btf_is_module(btf);
+	bool add_filter = !!kset->filter;
  	struct btf_kfunc_set_tab *tab;
  	struct btf_id_set8 *set;
  	u32 set_cnt;
@@ -7737,6 +7747,20 @@ static int btf_populate_kfunc_set(struct btf *btf, enum btf_kfunc_hook hook,
  		return 0;
tab = btf->kfunc_set_tab;
+
+	if (tab && add_filter) {
+		int i;
+
+		hook_filter = &tab->hook_filters[hook];
+		for (i = 0; i < hook_filter->nr_filters; i++) {
+			if (hook_filter->filters[i] == kset->filter)
+				add_filter = false;

Just noticed that this missed a "break;" that can save some unnecessary loops.

It seems it needs to respin one more time to clarify the patch 1 commit message. Please also move patch 9 before patch 6 adding the 'bpf: Add bpf_sock_destroy kfunc'. Patch 6 requires patch 9 to be safe. Then the patch 10 selftests can be combined with patch 8 selftests as the last patch of the set.

Others lgtm.

+		}
+
+		if (add_filter && hook_filter->nr_filters == BTF_KFUNC_FILTER_MAX_CNT)
+			return -E2BIG;
+	}
+
  	if (!tab) {
  		tab = kzalloc(sizeof(*tab), GFP_KERNEL | __GFP_NOWARN);
  		if (!tab)





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux