> On Apr 1, 2021, at 10:28 AM, Cong Wang <xiyou.wangcong@xxxxxxxxx> wrote: > > On Wed, Mar 31, 2021 at 11:38 PM Song Liu <songliubraving@xxxxxx> wrote: >> >> >> >>> On Mar 31, 2021, at 9:26 PM, Cong Wang <xiyou.wangcong@xxxxxxxxx> wrote: >>> >>> From: Cong Wang <cong.wang@xxxxxxxxxxxxx> >>> >>> (This patch is still in early stage and obviously incomplete. I am sending >>> it out to get some high-level feedbacks. Please kindly ignore any coding >>> details for now and focus on the design.) >> >> Could you please explain the use case of the timer? Is it the same as >> earlier proposal of BPF_MAP_TYPE_TIMEOUT_HASH? >> >> Assuming that is the case, I guess the use case is to assign an expire >> time for each element in a hash map; and periodically remove expired >> element from the map. >> >> If this is still correct, my next question is: how does this compare >> against a user space timer? Will the user space timer be too slow? > > Yes, as I explained in timeout hashmap patchset, doing it in user-space > would require a lot of syscalls (without batching) or copying (with batching). > I will add the explanation here, in case people miss why we need a timer. How about we use a user space timer to trigger a BPF program (e.g. use BPF_PROG_TEST_RUN on a raw_tp program); then, in the BPF program, we can use bpf_for_each_map_elem and bpf_map_delete_elem to scan and update the map? With this approach, we only need one syscall per period. Thanks, Song