Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp920453pxf; Wed, 7 Apr 2021 15:05:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIDJVpdGz1WHI58qVIVdwU/3xbuyG0GuDQclCaZNlADpA7SDs1cfo4x1Unu+vnZcVBmqaH X-Received: by 2002:a62:1757:0:b029:23e:9917:7496 with SMTP id 84-20020a6217570000b029023e99177496mr4840261pfx.51.1617833154562; Wed, 07 Apr 2021 15:05:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617833154; cv=none; d=google.com; s=arc-20160816; b=OWJouPV6c0jouJwj4SQNWroHgjOwK+ivC2ty0iHAZjsZsjsvk6JR0WRkD4DmstGh+t sOBRk8J+WEZgeOi7kkg0W+qDpgOFfZBlyCWw6mZLKxuOiLsLOar6M3pCLzNif6CFeAhL D6DOsS2gRzOGc8U47TyLewNomx9vGhqQ4X+WWx3Y7yG4xXwT/Vfstq6j+14nby2DWG+x 3wUw3LP4ukNfV8RcfL1verbx8TRsUI0B9bhumioO7E+XHscOxuVFjnbrAUyFwqizzJz/ IxtutxRnlRHMf2o6nxp8mJqp7qT7ntLItyhPW5UsZmcMdANn6FfDnPJiklLdTHJ0Uol2 sMpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3O1UY45/jWO/BQZWJoj52TQjaRoRPI7XxTD27HudHmQ=; b=gYQlVGLe5MWWfyGED7sjGwiSyWule/6V0jzQvC8MFes08ddPBulIzawXxuJ1as7/sK v79HuzLPDhaxDbagjU9ZcYUG/awb8ImzxLRFPUbp7Ez486fP1go7AnDap9mj/gLDajXi XIWrgxmI+gJRS1zRFNz8Twi5Pwrl73ztmsCG0KxKw1em05IcQBrLTD5nl4Qwj5xvVerr KSrTNXhQ8u3W3oWJUmlyNDF7NFUJilHue2K+trbc6g0Wt1et9EnsfJY06ZT9QO2wZxEX /psJLG/7pk+gW/FJDtUnTaCXIHi+hQRalY1tyuFb6Cn/KAbtYDpxyi3Av/7PhFioo2Vb Qbbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=icwGjw1O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n16si7253044pfv.271.2021.04.07.15.05.41; Wed, 07 Apr 2021 15:05:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=icwGjw1O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231998AbhDGVRL (ORCPT + 99 others); Wed, 7 Apr 2021 17:17:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbhDGVRI (ORCPT ); Wed, 7 Apr 2021 17:17:08 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73030C061760; Wed, 7 Apr 2021 14:16:58 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id n12so250114ybf.8; Wed, 07 Apr 2021 14:16:58 -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:content-transfer-encoding; bh=3O1UY45/jWO/BQZWJoj52TQjaRoRPI7XxTD27HudHmQ=; b=icwGjw1OD0LnP09NN6vVmx5HYkxTM8IMdOPHZYcxyyuC9bb3I0N20RzdBPnsbptuwZ TjTR8JuUZQI1Z7t5flMqu1FF8SZJbdoj3dnP4fDLG2sCzncQNczlmugjiwG3NjsAzP5c On4NWF85O2j0vUH3cwmOZYYyp5GI5x67AY6VaD5b3p6npgFTv8Xh5nV6ivf62VS7E4dp FMrhsWu0ZDc/nimY783MvtkuS/yiXWIrPYgiMQ2hGfX6pmRJz4QW0z0z1fhqethpjQ/X DeTXJQ5fSEoLyICs7W69FI3J/L+i4GJEE3+oZdgTLeo8ljButapPk3a2zNIindfXbf5s onww== 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:content-transfer-encoding; bh=3O1UY45/jWO/BQZWJoj52TQjaRoRPI7XxTD27HudHmQ=; b=Y6vIuOs6CLXYFQikup3vZRuHfwkc9nOtByRu+0hCj4Hk1XPmhKZoQFRWGDnhl4MSbB TnoXhuUolERF+1piBjIV3/e6RYqH5sOmuvPpIxcx/xkcOV3dQfRGabi8bYk1+dgcjiL5 /ZP1QVke+wlz7Q2lc3cH6eemR3hSx7IzldIFsS/jfzSwYbXEEIdxbjCwIqUgyWKMcTNe jo4v1Mo6TkGataDC1uiIdF385eQGwr2DDW1ME64uV4Zog2JQ3VAOcsVc2nl/dZT0D+Vb fDgJ8UFIF8GLSnDTtekcjWJu643kAX2xBQel+9jCwZGvAn8lc8nO4EyPQqGNoRh3qz8g tJvQ== X-Gm-Message-State: AOAM530ihiddrIkcUIuSokXGizUUPZUL+z00dFPPN1agWyC6FKjPe2oq N6Zy6zX2HZus/LIw+66cnBH2YaGDClPTtKbxvFs= X-Received: by 2002:a25:d87:: with SMTP id 129mr7291662ybn.260.1617830217744; Wed, 07 Apr 2021 14:16:57 -0700 (PDT) MIME-Version: 1.0 References: <20210406185806.377576-1-pctammela@mojatatu.com> In-Reply-To: From: Andrii Nakryiko Date: Wed, 7 Apr 2021 14:16:46 -0700 Message-ID: Subject: Re: [PATCH bpf-next] libbpf: clarify flags in ringbuf helpers To: Pedro Tammela Cc: Joe Stringer , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Quentin Monnet , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" , open list , Pedro Tammela Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 7, 2021 at 1:10 PM Pedro Tammela wrote: > > Em qua., 7 de abr. de 2021 =C3=A0s 16:58, Andrii Nakryiko > escreveu: > > > > On Wed, Apr 7, 2021 at 11:43 AM Joe Stringer wrote: > > > > > > Hi Pedro, > > > > > > On Tue, Apr 6, 2021 at 11:58 AM Pedro Tammela w= rote: > > > > > > > > In 'bpf_ringbuf_reserve()' we require the flag to '0' at the moment= . > > > > > > > > For 'bpf_ringbuf_{discard,submit,output}' a flag of '0' might send = a > > > > notification to the process if needed. > > > > > > > > Signed-off-by: Pedro Tammela > > > > --- > > > > include/uapi/linux/bpf.h | 7 +++++++ > > > > tools/include/uapi/linux/bpf.h | 7 +++++++ > > > > 2 files changed, 14 insertions(+) > > > > > > > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > > > > index 49371eba98ba..8c5c7a893b87 100644 > > > > --- a/include/uapi/linux/bpf.h > > > > +++ b/include/uapi/linux/bpf.h > > > > @@ -4061,12 +4061,15 @@ union bpf_attr { > > > > * of new data availability is sent. > > > > * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*,= notification > > > > * of new data availability is sent unconditionally. > > > > + * If **0** is specified in *flags*, notification > > > > + * of new data availability is sent if needed. > > > > > > Maybe a trivial question, but what does "if needed" mean? Does that > > > mean "when the buffer is full"? > > > > I used to call it ns "adaptive notification", so maybe let's use that > > term instead of "if needed"? It means that in kernel BPF ringbuf code > > will check if the user-space consumer has caught up and consumed all > > the available data. In that case user-space might be waiting > > (sleeping) in epoll_wait() already and not processing samples > > actively. That means that we have to send notification, otherwise > > user-space might never wake up. But if the kernel sees that user-space > > is still processing previous record (consumer position < producer > > position), then we can bypass sending another notification, because > > user-space consumer protocol dictates that it needs to consume all the > > record until consumer position =3D=3D producer position. So no > > notification is necessary for the newly submitted sample, as > > user-space will eventually see it without notification. > > > > Of course there is careful writes and memory ordering involved to make > > sure that we never miss notification. > > > > Does someone want to try to condense it into a succinct description? ;) > > OK. > > I can try to condense this and perhaps add it as code in the comment? Sure, though there is already a brief comment to that effect. But having high-level explanation in uapi/linux/bpf.h would be great for users, though.