From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 E7FDE33B96B for ; Sat, 15 Aug 2026 10:26:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789617; cv=none; b=O57TtjaLZSAVjo0Y6OKXP6ZjLJd3jul9AnDyk6EFcC7BHrlpPBPx+9bXzixs5Wl2gBVbAcJXn4sUNFyeq13Oap+WK8N9w6t1QyCh4/cnAyqXwRycrE8dPTtDc8RQGz2cLWYBRWv3bd1y9DXlpVzfQR4NaghrRx/JkE8ZnZY2O/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786789617; c=relaxed/simple; bh=zvfg1aMBcL7aeIVRRxcfIP0e06KZv6Y19r5yBA73lWU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DsZur6AbHYDmYty+CMxNi4RhvB0nfKovoKrcmHBwMCftjVW6OOI5CIZlvNFPVngADZUdE3VE7Bcn+Wg8ymXgzhtwIP+K1HeSzcOQ0oQcXojs7LblGGgcN7EkwoZmQY4z9pJLVR0/Zpa/nmi3tWwi3h87z/oTNbj6Q6hxr/DdDwQ= 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=Vs1+9eCm; arc=none smtp.client-ip=209.85.128.44 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="Vs1+9eCm" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4956242332dso19127865e9.2 for ; Sat, 15 Aug 2026 03:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786789614; x=1787394414; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=5LwofxgwMbfokzic1LQKB96aMSrs/A5ouH+Ep8Gghec=; b=Vs1+9eCmJ7mDa/4iyK1WrQaifKAPpTCuvgg2MVNLFMpEGRKZoyESomJkOO7CcBSvu4 DXqgYsSJHcyUaktZQtlTUP5ObXtS4XKrekvnFCm9GF3ox0z5zUgaElpWXcJGB1rkOBhC b8lAPDs8+OuBdUsyVyp085QXRxVt13wlrl3HCTB2hfZfZzeErMyHbA/njnDsl3uLaHnk F0ZG4kARTeICqZ32aAmUcY+90mIDBlaTBrhN5QaFy6YO5G5dtae/zIMr4HwjqhVRGncs M4AozHiEmwkt2U0L6hhmPt6gzKIDOdM24pcgVzlGFQpZ/KN5HIcNPNpzQvEBUYabGnF8 FpNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786789614; x=1787394414; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5LwofxgwMbfokzic1LQKB96aMSrs/A5ouH+Ep8Gghec=; b=UKNZzreCL9SPPkkdMeSdWZ3gOpMnSfOJceCcn/F3JFs1K8ntF+3DK6HgVuIi3uv9by zTVAxDvtrB/ipGuRBeCwEkW6w+9wYChuSG7OdGpY2QH/mEbJKtHFmvoMBuzkjkiETHa1 Jo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KgMfvPsitU= X-Received: by 2002:a7b:cbd3:0:b0:493:cefc:d113 with SMTP id 5b1f17b1804b1-4998794c02emr116543425e9.5.1786789614006; Sat, 15 Aug 2026 03:26:54 -0700 (PDT) Received: from ?IPV6:2a01:4b00:bd21:4f00:7cc6:d3ca:494:116c? ([2a01:4b00:bd21:4f00:7cc6:d3ca:494:116c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49987b1a31esm139109285e9.2.2026.08.15.03.26.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 15 Aug 2026 03:26:53 -0700 (PDT) Message-ID: Date: Sat, 15 Aug 2026 11:26:50 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] io_uring/bpf-ops: wake up the loop task on eject To: Sidong Yang , io-uring@vger.kernel.org Cc: Jens Axboe , linux-kernel@vger.kernel.org References: <20260814030421.61216-1-sidong.yang@furiosa.ai> Content-Language: en-US From: Pavel Begunkov In-Reply-To: <20260814030421.61216-1-sidong.yang@furiosa.ai> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/14/26 04:04, Sidong Yang wrote: > io_eject_bpf() clears ctx->loop_step while a loop may be sleeping in > io_loop_wait(), which releases ->uring_lock before schedule(). Nothing > wakes the submitter task after the BPF ops are unregistered through link > destruction or ring teardown, so the task stays blocked in > io_uring_enter() until an unrelated CQE event or signal arrives. If there is nothing to wake it up after bpf removal, it wouldn't be woken up without it either, it's a mess up on the user's side. What's the use case? Especially since you wouldn't normally be removing it from another thread in the current form of the interface. > Since BPF ops require IORING_SETUP_DEFER_TASKRUN, only > ctx->submitter_task can run the loop, so wake it directly. The loop > rechecks loop_step after waking up and exits with -EFAULT. A spurious > wakeup is harmless because io_loop_wait() rechecks the wait condition > before sleeping again. > > Fixes: 98f37634b12b ("io_uring/bpf-ops: implement bpf ops registration") > Signed-off-by: Sidong Yang > --- > io_uring/bpf-ops.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/io_uring/bpf-ops.c b/io_uring/bpf-ops.c > index 5a50f0675fe5..87148dbd3b3e 100644 > --- a/io_uring/bpf-ops.c > +++ b/io_uring/bpf-ops.c > @@ -210,6 +210,13 @@ static void io_eject_bpf(struct io_ring_ctx *ctx) > ops->priv = NULL; > ctx->bpf_ops = NULL; > ctx->loop_step = NULL; > + /* > + * A loop may be sleeping in io_loop_wait() with ->uring_lock > + * released. It'll see loop_step == NULL after waking up, but > + * nothing wakes it otherwise. > + */ > + if (ctx->submitter_task) > + wake_up_state(ctx->submitter_task, TASK_INTERRUPTIBLE); > } > > static void bpf_io_unreg(void *kdata, struct bpf_link *link) -- Pavel Begunkov