On 11/3/21 6:08 PM, Andrii Nakryiko wrote: > Allow to control number of BPF_PROG_LOAD attempts from outside the > sys_bpf_prog_load() helper. > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > --- > tools/lib/bpf/bpf.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c > index c09cbb868c9f..8e6a23c42560 100644 > --- a/tools/lib/bpf/bpf.c > +++ b/tools/lib/bpf/bpf.c > @@ -74,14 +74,15 @@ static inline int sys_bpf_fd(enum bpf_cmd cmd, union bpf_attr *attr, > return ensure_good_fd(fd); > } > > -static inline int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size) > +#define PROG_LOAD_ATTEMPTS 5 > + > +static inline int sys_bpf_prog_load(union bpf_attr *attr, unsigned int size, int attempts) nit: Should attempts be unsigned? Although, with the pre-decrement below, I can see the case for leaving as is. Regardless, Acked-by: Dave Marchevsky <davemarchevsky@xxxxxx> > { > - int retries = 5; > int fd; > > do { > fd = sys_bpf_fd(BPF_PROG_LOAD, attr, size); > - } while (fd < 0 && errno == EAGAIN && retries-- > 0); > + } while (fd < 0 && errno == EAGAIN && --attempts > 0); > > return fd; > } [...]