From nobody Sat Oct 4 06:34:46 2025 Received: from out-170.mta1.migadu.com (out-170.mta1.migadu.com [95.215.58.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 288773043D7 for ; Tue, 19 Aug 2025 12:57:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755608262; cv=none; b=QM9Y0XNW3otzVQYT9gurL9JyRcLbgpdzjVX0CFTwujlln3Aeu3olQ9W4W1pycydh1eVSfNBQNN4kFLqJ9sui9PWmOugreMowKK6AEGzc7n9j38iyKfv1sO7AQXFPa3KNUqC8VwrNcnJVzkXUmWzFdzWSzj+7rHgQAUphAeZuWa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755608262; c=relaxed/simple; bh=FvU8+HnpnAE+HoIZCFz1dx5R8/F5SQPC+f1V3dtE1I8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iAuDgzT3ZyC2+ciUWFA79GD/7JKjSBzxExeAMMuIBsVd/leR4kEnBlBZCIZdHBhoTmoAnenmJUp59krdZkEaIh8e/9EKbNlpeWA0mjbBXf0+IFb/z68VnOXxzhk2ud724bbxkC30NBbizu9Zm5i7XslDxJTnIJZqaAildp4O/tY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=wkuiJp5P; arc=none smtp.client-ip=95.215.58.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="wkuiJp5P" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1755608248; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XrskpurdbhbEAEqLlf+PaKw7M2joz8cWTLGZUxQsWU8=; b=wkuiJp5PGUiA88cc8Sfctvd1ifCNMmkQMlSjJqhreOF7gke72KnZ9W3hWU6TmxO1QbsB4N xnEn+z6wXbCrpdvFLOlbdfXqyUPXC2iUAd6o4AEjGBNg2Gkbn3XtU1GcpNly+OT5Ym+wNU S3BlOJ/MzhdQ+fbBIqhtK5SvMrm2yMc= From: Tao Chen To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Tao Chen Subject: [PATCH bpf-next] bpf: Remove preempt_disable in bpf_try_get_buffers Date: Tue, 19 Aug 2025 20:56:38 +0800 Message-ID: <20250819125638.2544715-1-chen.dylane@linux.dev> 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 X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Now BPF program will run with migration disabled, so it is safe to access this_cpu_inc_return(bpf_bprintf_nest_level). Fixes: d9c9e4db186a ("bpf: Factorize bpf_trace_printk and bpf_seq_printf") Signed-off-by: Tao Chen --- kernel/bpf/helpers.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 6b4877e85a6..182886585d4 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -774,11 +774,9 @@ int bpf_try_get_buffers(struct bpf_bprintf_buffers **b= ufs) { int nest_level; =20 - preempt_disable(); nest_level =3D this_cpu_inc_return(bpf_bprintf_nest_level); if (WARN_ON_ONCE(nest_level > MAX_BPRINTF_NEST_LEVEL)) { this_cpu_dec(bpf_bprintf_nest_level); - preempt_enable(); return -EBUSY; } *bufs =3D this_cpu_ptr(&bpf_bprintf_bufs[nest_level - 1]); @@ -791,7 +789,6 @@ void bpf_put_buffers(void) if (WARN_ON_ONCE(this_cpu_read(bpf_bprintf_nest_level) =3D=3D 0)) return; this_cpu_dec(bpf_bprintf_nest_level); - preempt_enable(); } =20 void bpf_bprintf_cleanup(struct bpf_bprintf_data *data) --=20 2.48.1