From nobody Thu Apr 2 06:10:17 2026 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 270443C3BE4 for ; Mon, 30 Mar 2026 12:17:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774873081; cv=none; b=MQHWbGHvRTrYptP/aC4+JqsjGZ4sED3oFiPSHM/1Kgbz3dYWEmQXcm1WERaHW36HuTbni4KKw65mPgLFVoPEXcCXMXPZU3A8+dxsbwTVB5gSdgo6DndxX9H31V9PJUBrCfo/QoGbuop73JdOFwUZMt2qr9mcZVCiQB2lCTzu5cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774873081; c=relaxed/simple; bh=HKP1+unkmlsUXuZbvqKdy3bzckwvgDpC2yh+SeHXOF8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=feyFc69vi2u72qxaY0N4aKTnO29o2ro+22X+5xfPiEg6I1YfRDmRROfXBJWYkPKg4HOyDgf/yuc7/cbAPaE+5zMAIFgJGWyJEQ3MAYAmGAOyiy0Gu10Ud/LI+DDfC8mtq5wp61zY63nJwXXyMW8AHCPQgd//fUnnHRO0n8v5RU8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T2ztSMxF; arc=none smtp.client-ip=74.125.82.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T2ztSMxF" Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-12776bebe9fso412006c88.1 for ; Mon, 30 Mar 2026 05:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1774873079; x=1775477879; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jZtJUBFKT2xiUVosjATVKuQj4x9H6qJm82elkbbuJNI=; b=T2ztSMxFOpGv/B4Nm1G4qzLsqLWpLfiWpu7Gq6CVACS+oPWt8gKYC8vt+O1bVZuLki DmyZvru3mEJDVLEgIvNiF2TsVLg8xEZobhdHpHzmTOxagRuqiVqxbuwMpdn2u8cjAwgo WfAfHLxgS4Rd6axbM13Ju9Ceo+8TBBOwB7vaSdAZUZiXL32oo34Egx/xTDl4IHhBKEqL yMracCYeUI4OJg3mNqQ6qq6drRbausxWiKPWkgFN2k5J+3y4JiIXqPDvQ1S/1FNqgBXI 0iIhsTP8wTyRJBmyki5iSDLk0d3KvMvWxTVR3+23A9GruOITjJAlY67TDxSUeV95sRu5 RrhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774873079; x=1775477879; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jZtJUBFKT2xiUVosjATVKuQj4x9H6qJm82elkbbuJNI=; b=kEYAaudF1ItiqqIkJRq9veWxVWSO8toi1AlCJmnMCjrn5tyIqvSxqI4cR1hqIPI6hC IzNlqv01djII8dvKDvY0VrsTE9PHb127+rG2hjYy8q/TLE5Ti74ll2rhaE4bnPUhn4X/ 6HqW8Ftqi1E4lzvO/9jRuGlVcXCaSd/HYvsm4xNJRzrHOUJnzhgtnseOMqOma1qi4W2O 6C7r0XiLMIc89TaJ0e1vQ3MEUwNwBVG0IK+7z5Y3IgE0DxUmKqdoQyF2e7JlgB5nXIZO VxZPxRbq+GQGy6MvUnj51QaEhNxP1ERuROCHwbsvF0IPCWuP91G8FcoFR7mFbQ7COSDa 1lSg== X-Forwarded-Encrypted: i=1; AJvYcCUpctRNsPpYPDjCBsblzzV7uBoxYNSlSagCz4dLJk6Ri1QJAjDxaCswTDbK4uavj0elHKtCj/UGS5Ox62A=@vger.kernel.org X-Gm-Message-State: AOJu0YypFWEk8jt/CpAoMhhe37IdBV4NJQRJl5OVv6y9JtAAiiNUzoSl a+F34DLdQEnmyX3p2WKDU2/duFqhLTI3bdVQN7lpMfYnKbBd5AP3tNLe X-Gm-Gg: ATEYQzzEycjTmSNlPVulhx93OhZAtaD+rk5BKrBRoZMmnfxOthEGB9/ikoOxYaZASrK gMTH/V+47P9wV3AIuOyCEb+rnUrIKwGWMNZSl1n3kHjVk3rN9A81m9+uzwP+YksC4snbFjcU5Cb DQ+SwL4AckPo8JEfjzzzFJSsSMWHTdVqtCpMmtbcWaaq6A7QC2V33tswvPQSmuX/YhvBIpEx3v0 4HOA1XMN3qAT9EOzf6x2zFyuMRPx+otxdFMOl2qmJXYueEc+BQ/kwAHCnGdxC574GslzCMvu3mc JiTJAhiRAeFkpSccbweOE2TRPBheNZ7fuC71EpcT/VvyA/6Ia17ozQ2na8shYeQ1M6mm4efmIQw 2Wz7BLB0GbAawYoJ0vM8Y7HTMOqEtEOnvDvmFp2BDU43ncJGtVdYWE6R9U/9cWhc4syqBDBBujt C2DkvPJzp1UEBVSEv3Sco= X-Received: by 2002:a05:7022:ea30:b0:128:d7a7:5261 with SMTP id a92af1059eb24-12ab28eba7bmr7986482c88.30.1774873079115; Mon, 30 Mar 2026 05:17:59 -0700 (PDT) Received: from animal.. ([104.35.26.140]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-12ab970da7fsm7623128c88.0.2026.03.30.05.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Mar 2026 05:17:58 -0700 (PDT) From: Eyal Birger To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, memxor@gmail.com, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, paul.chaignon@gmail.com, chen.dylane@linux.dev, kpsingh@kernel.org, a.s.protopopov@gmail.com, yatsenko@meta.com, ameryhung@gmail.com, tklauser@distanz.ch, shmulik.ladkani@gmail.com Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Eyal Birger Subject: [PATCH bpf-next] bpf: warn against BPF_RB_NO_WAKEUP in bpf_ringbuf_discard() Date: Mon, 30 Mar 2026 05:17:32 -0700 Message-ID: <20260330121732.1601352-1-eyal.birger@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Document that BPF_RB_NO_WAKEUP is not recommended for bpf_ringbuf_discard(). A discard done with BPF_RB_NO_WAKEUP can suppress a later adaptive wakeup from a valid record, leaving an epoll-based userspace consumer asleep even though data is available in the ring buffer. Scenario: epoll_wait(rb_fd); // blocks rec =3D bpf_ringbuf_reserve(&rb, ...); bpf_ringbuf_discard(rec, BPF_RB_NO_WAKEUP); rec =3D bpf_ringbuf_reserve(&rb, ...); bpf_ringbuf_submit(rec, 0); // valid record, but no wakeup This behavior is surprising in the context of bpf_ringbuf_discard() as it seems natural not to want to wake userspace. Reported-by: Shmulik Ladkani Signed-off-by: Eyal Birger --- include/uapi/linux/bpf.h | 3 ++- tools/include/uapi/linux/bpf.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index c8d400b7680a..c46b06d45904 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -4645,7 +4645,8 @@ union bpf_attr { * Description * Discard reserved ring buffer sample, pointed to by *data*. * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification - * of new data availability is sent. + * of new data availability is sent, which is not recommended as + * it can suppress a later adaptive wakeup from a subsequent submit. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. * If **0** is specified in *flags*, an adaptive notification diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 5e38b4887de6..96de37c3b896 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -4645,7 +4645,8 @@ union bpf_attr { * Description * Discard reserved ring buffer sample, pointed to by *data*. * If **BPF_RB_NO_WAKEUP** is specified in *flags*, no notification - * of new data availability is sent. + * of new data availability is sent, which is not recommended as + * it can suppress a later adaptive wakeup from a subsequent submit. * If **BPF_RB_FORCE_WAKEUP** is specified in *flags*, notification * of new data availability is sent unconditionally. * If **0** is specified in *flags*, an adaptive notification --=20 2.43.0