From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69347C433E0 for ; Wed, 17 Mar 2021 17:27:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 360B464E6B for ; Wed, 17 Mar 2021 17:27:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbhCQR0i (ORCPT ); Wed, 17 Mar 2021 13:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbhCQR02 (ORCPT ); Wed, 17 Mar 2021 13:26:28 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CF96C06174A for ; Wed, 17 Mar 2021 10:26:28 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id x29so11253pgk.6 for ; Wed, 17 Mar 2021 10:26:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yRiQsQ6pUg2QCbWA5SCXQRVHFpfpp11ZqT5ulDn3OSE=; b=BDs1CFsP16UpWuUQmn6Z7omU17z/mkVePMLETg7ZH+WWuDEgThO+cJZDOn6sw+3E3W i24+Y7VqrHumPGzq96Gcsu5MCZagNB9nfrvTvNq7mBkacvTuKpv8kK5UZEEc9LWUWRAo Mp4F3DpuWZzzhpg8bDF8to32GaOviPhNiL6YulCqobZbKJyMvJ2iJUO/f5XNAgA42L61 OH1Z8ZCoKiEcva02RAgvduop98TmOV9jSD5X9hJCi7xWf5F4RrNWu9Chj45zPrV8RlZB v9W/cr6WiDeCD2s0c+9/Fm7jM94n4x4Sktw0DF+sYUtOS6La2kLPFVY7jeXxzdDF9Q5N uTKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yRiQsQ6pUg2QCbWA5SCXQRVHFpfpp11ZqT5ulDn3OSE=; b=qLOsSsPE106cYw03XfultOuCHcMktAqCezp37ngsbs8dNoI/tUGRIyFRiLAqVPJJts jIj4RYfGITpv/gClOzpeqvDDkFiryxqyTIlf1bFLO8UtGGY7p5QwXC+xqbf1G9bditoj qBrjKBjpZiRkCBKfCJJNqgGSWez8f3kiLX4JX9SY7gzcJiW5hP7Ot8Qg2L+ll/W2D4o4 JIVK/2Gd2hgkRK2NNrNPFeP2nLgGef0EcwC+59BXZ/YSGD6uDtlAKg5UIYzpf50itD9+ EA/hWNhAmTggaYdlA2osPMv7WQKNxy16eHds7y7o1vE7yp16jSrAkQOvVS5/DSWoikZa o+CA== X-Gm-Message-State: AOAM533sXpDOLcn+Jj0fLb6y+urT2lE5gtrN26V4ORZUa1kLyw9OGQd7 khGnNkgane7oiWf22AT/ioZ2RCqZIYODJG8qmyM= X-Google-Smtp-Source: ABdhPJzq2VcA4r0KrgdBQHh/tEaa3PaxMFB4xgY03Flq9TQvv49/5ti8m6+20eCgwLFCK9iHLcvZ9yqwH82fi5XKBNw= X-Received: by 2002:a62:8485:0:b029:1fc:d912:67d6 with SMTP id k127-20020a6284850000b02901fcd91267d6mr90494pfd.80.1616001988115; Wed, 17 Mar 2021 10:26:28 -0700 (PDT) MIME-Version: 1.0 References: <20210310011905.ozz4xahpkqbfkkvd@ast-mbp.dhcp.thefacebook.com> In-Reply-To: From: Cong Wang Date: Wed, 17 Mar 2021 10:26:15 -0700 Message-ID: Subject: Re: bpf timer design To: Alexei Starovoitov Cc: bpf , Alexei Starovoitov , Dongdong Wang , duanxiongchun@bytedance.com, Yonghong Song , Andrii Nakryiko Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Tue, Mar 16, 2021 at 9:21 PM Cong Wang wrote: > We still need a timer map: > > struct { > __uint(type, BPF_MAP_TYPE_TIMER); > } map SEC(".maps"); > > However, its key is not a pointer to timer, it is a timer ID allocated with > > u32 bpf_timer_create(void *callback, void *arg, u64 flags); Hmm, we do not need a map at all, because the verifier could check whether create() and delete() are paired correctly, so we can just have the following API's: u32 bpf_timer_create(void *callback, void *arg, u32 flags); void bpf_timer_settime(u32 id, u64 expires); u64 bpf_timer_gettime(u32 id); int bpf_timer_delete(u32 id); Pretty much similar to Linux user-space timer API's. I will probably go this direction, unless there is any objection. Thanks.