Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4881436rwb; Tue, 6 Sep 2022 14:26:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nfISGlSOndCuQ33+IriCFcReACFYDa548PCeRKpVDWOPTkEP+UbbYLPUcA4JPphfqzra/ X-Received: by 2002:a17:906:f88f:b0:731:463d:4b15 with SMTP id lg15-20020a170906f88f00b00731463d4b15mr279276ejb.299.1662499611628; Tue, 06 Sep 2022 14:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662499611; cv=none; d=google.com; s=arc-20160816; b=KZ9i7yS/FIiQio9jKe/AhXBPg+lfE92LuuYlpM39wLRx6iVtiljW9zjSPGg2ABCMxK 4o3D0Ma1pAWG2P36JWRFoLQIKJv7mbpRB/kstradqiVmZNqd39Ep6z3hfubJJBz4EvOG Slh2FvgPbg2VFZE8nzSfaNmqwXLH2MYdjyTqDJDBfhsdkCTYNnk/hnua1sKufUF7eHKC k1TR3JKQH3syGSXYEx2oqKWTPf9/V+fq9U09DzH29HXTVwOxc/zc4u/aig6WNwf/7Qwz LlTT8L7gzQGfyzNYiV3WBpTcbz0ljJTC9vMzwihxnx1tSvD4FiS6fNyOIMeAhlUeMB8G qJ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=uFGRrOq/51NXIcdfjbdqGyuEN8JjUWMtBLgpVH9tTbM=; b=M6kJVlueumJhnJkXBeZP12qS5L2DPig3zXUZ3i4A/nwEW06eUYamN4kyuQFPyszpGl LSjCTWlnOLwfWiK9QOnYYFE5gzjxgKuZJst6Kt61UgHY1cOMoz5AjK0z/17+dP1DqHgo AY2EZX+GYl0vrsPQygFPe9HZJnlrmlhaJ09IIfcie6DNYAXf4RLQUsmwlPBnXyByOhUC 72l9nmCf+7NR6DxtMX6y7twTDd9vKE94Jw3AuenItwpKY9CCSbbxGoK9y8k5pLIqi/b7 chh/vKnHKE7zjVMWUEDoYcOazevaXs4XW8ExywXehoTHNNDxcywYCHjm20HGUpY/U8wj aRFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="s0ip9PP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a170906688300b0073dd6da172csi8598779ejr.446.2022.09.06.14.26.25; Tue, 06 Sep 2022 14:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="s0ip9PP/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231228AbiIFUFY (ORCPT + 99 others); Tue, 6 Sep 2022 16:05:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231166AbiIFUE4 (ORCPT ); Tue, 6 Sep 2022 16:04:56 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B18CCB5E79; Tue, 6 Sep 2022 13:00:32 -0700 (PDT) Received: from pwmachine.numericable.fr (85-170-34-72.rev.numericable.fr [85.170.34.72]) by linux.microsoft.com (Postfix) with ESMTPSA id 36F4E204A062; Tue, 6 Sep 2022 12:58:55 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 36F4E204A062 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1662494339; bh=uFGRrOq/51NXIcdfjbdqGyuEN8JjUWMtBLgpVH9tTbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0ip9PP/e7tNFhTzW5Qi5hmgISsGF5ZqFozbagJLd9QyP2nb8fQwXdiRQ3lp6yhyo SYD9DSLv8MQk1PstZ+J+YXCj5NpaCpaBeetft2N5Pr3g5S/kp4+m2LBnYNKboOS+bO C7/FC7B8CQ4ZEjDDb3eC26nfWjqax71Es0yYlFR8= From: Francis Laniel To: bpf@vger.kernel.org Cc: Francis Laniel , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jonathan Corbet , Mykola Lysenko , Shuah Khan , Joanne Koong , Dave Marchevsky , Lorenzo Bianconi , Maxim Mikityanskiy , Geliang Tang , "Naveen N. Rao" , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [RFC PATCH v2 3/5] docs/bpf: Add documentation for overwritable ring buffer. Date: Tue, 6 Sep 2022 21:56:44 +0200 Message-Id: <20220906195656.33021-4-flaniel@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220906195656.33021-1-flaniel@linux.microsoft.com> References: <20220906195656.33021-1-flaniel@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add documentation to precise behavior of overwritable BPF ring buffer compared to conventionnal ones. Signed-off-by: Francis Laniel --- Documentation/bpf/ringbuf.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Documentation/bpf/ringbuf.rst b/Documentation/bpf/ringbuf.rst index 6a615cd62bda..e062381ff604 100644 --- a/Documentation/bpf/ringbuf.rst +++ b/Documentation/bpf/ringbuf.rst @@ -124,7 +124,7 @@ buffer. Currently 4 are supported: - ``BPF_RB_AVAIL_DATA`` returns amount of unconsumed data in ring buffer; - ``BPF_RB_RING_SIZE`` returns the size of ring buffer; -- ``BPF_RB_CONS_POS``/``BPF_RB_PROD_POS`` returns current logical possition +- ``BPF_RB_CONS_POS``/``BPF_RB_PROD_POS`` returns current logical position of consumer/producer, respectively. Returned values are momentarily snapshots of ring buffer state and could be @@ -204,3 +204,19 @@ buffer. For extreme cases, when BPF program wants more manual control of notifications, commit/discard/output helpers accept ``BPF_RB_NO_WAKEUP`` and ``BPF_RB_FORCE_WAKEUP`` flags, which give full control over notifications of data availability, but require extra caution and diligence in using this API. + +Specific case of overwritable ring buffer +----------------------------------------- + +Using ``BFP_F_RB_OVERWRITABLE`` when creating the ring buffer will make it +overwritable. +As a consequence, the producers will never be stopped from writing data, *i.e.* +in this mode ``bpf_ringbuf_reserve()`` never blocks and returns NULL, but oldest +events will be replaced by newest ones. + +In terms of implementation, this feature uses the same logic than overwritable +perf ring buffer. +The ring buffer is written backward, while it should be read forward from the +producer position. +As a consequence, in this mode, the consumer position has no meaning and can be +used freely by userspace implementation. -- 2.25.1