From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f46.google.com (mail-ej1-f46.google.com [209.85.218.46]) (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 DFF653054EF for ; Mon, 10 Aug 2026 13:38:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786369132; cv=none; b=k6YXgcJA3awGG9YfwweB5XG8wJvZKXr2qrs8slH7ZiI8ZQVGN0okdKOIdB9+ZXRVxCOcqgSnyD0ZN2jLM7Id9YZ0+Z0pXu5oE8WbRx7KTlazNLNQ2ZffP90hJGZRq2h0a5WeFQGTN40NY60h59S4PlOP4hJQEvMA11e5k4Y7dwY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786369132; c=relaxed/simple; bh=73et1he1Ni5RWLoLIORHvnjazinxFZVeyqeO82Dy28k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=otS994GH+GlEsY+N7l1cyWODNqg2FW8zHuFm/b5ZE+Ra0EIQ45sdnGbenl3O6hXp9rUPNPHMGdk7jnSJiHgIXxh5z6Ku+0oV2MpZ+r2AdjfYKxiqTQArPJhlHXkE2UGhUPNaTWjY1N6XHkSPDpXKaD0wGvONuxJk9SvCF4MZJOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=klhFX/zv; arc=none smtp.client-ip=209.85.218.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="klhFX/zv" Received: by mail-ej1-f46.google.com with SMTP id a640c23a62f3a-c15c42a45adso647817266b.0 for ; Mon, 10 Aug 2026 06:38:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786369128; x=1786973928; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=C03w05phe+r5fWT7l+Wdmc8yWe7jkEKyfez6GNDcYcw=; b=klhFX/zvNZ8iNsp+Mieb8Sn4Qh8jg42un7bbuS/yAYtpSjQ0Hl6zyQ7tyeildSJXxs bUOmJnXZEfUPlMwfN73IkQrw3kipXwWk3EntvxXxvWqEgHtZoSBlYaMj81qYnps4giuP +hyN1iWqo8vyIvyTIp180epSGog4QNaaAp2/XcUCEYiQ0jae+MWcUEVuehEcZ4tfaRMJ L/iFJzlRkVEpNIs3AakR2D27eMPK9thX9v4Xb8+7eQ1eAaBcEwYue8oC3Zhjn7vxBwg3 1VmPtCfJwCwEMW9uLOLkSQVZOc8yCjJkHTFKq3PBo+ycMB4u5LTK1S1N01rwv+sOir31 1azg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786369128; x=1786973928; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=C03w05phe+r5fWT7l+Wdmc8yWe7jkEKyfez6GNDcYcw=; b=NWqho3bEZ6GlYtzo0BpxF/3ZQncVEvcrn169a7d1BHbX0F+tvWaQkv18MIzVmvQOs3 5mS/VcHu5uTxEQfDXL1ciUlBRkb/d8EwHpSmNUCuHqogKp6nPSBuj33N7oASQQbCsHyN 4mn2I5ULIwAXhXDao1EXQmsen2fNti3DG9LZK26KId7f5V7MJBSajVexl5lg6H1jzBDE rg+vWvCbun2PESOlB9qWFWejpzMA/+F2Xsc52UawvFbt1yHsbD98jrpuvatFU8O5/D14 q1p/UAKVIyEDnBQlz2+Gty3rWo51NfMUfd+Z6EaSZM8/wwP0f9Z0PMbD+zoHH1oSV0gD +EWg== X-Forwarded-Encrypted: i=1; AHgh+RoptM23tAPZkXC01IsKfznGbG/u1ocsxLEg9ZtiSbcNdqJVi0areQBNE7EjpWrSgCR8Jd4zoeX9r//XnOU=@vger.kernel.org X-Gm-Message-State: AOJu0YzaOcMv++gEEp9bj9LQwrgxommXzLaFyTMeMrnffXkloing2+/J R3735gEsyNdX0Qbv5S2mlYSC5ibZLcLyJr5DQqaPFEZa3iDwG6KpvvtXF4de9u0ifg== X-Gm-Gg: AR+sD11ic20aGZg2p4jMEFsKd4XuNfGJ1DgN88vDC2aKDV8lOxNnIHkycwZ/XmmbLUp 4BLygv78EcSvHRK4gN5qS9KRbTF7midGONX5zeQ3caWN5s7w/st+XSS3WzJGW82bxMzgPYtmnzz Wk7UCUfQOn9ETPj/5ozTjEHXvKcmJnlcbpKRYa8bflUpVzhZpT6y4wsSPwh9V0wQXvjewVWloh1 CYWqm4q2ZaG7v7qOGUtX7VFSp8eNOdrSP9bXeZ5EVjCsX2mwn53z9ZBkq4jSjaM8u0mgyUV4BZ1 ENQ4BC/eDOa7hI/rFNmtDBym1MuoUd7iJKJSXWT3HlT9GN31jellt/NtHCAthvot7eJVQ5FKap9 AO/HVzeLnf12Jo5QblVxUWM+kIpthToOXKqQBc8OxNNQ1eQhVTZ/ZyDwWKl4/lE6A0ehMhulBFF eZG+DrNYRNo31U2uRK+8RGHOritBur2HJCLbJ+eZnaohTnd8PVtaoM8F6M2qEgkabSnvOsC0srt duOEeixyucfMVJUGmgdvAY0x2W78YnIPNMOKhiIucc= X-Received: by 2002:a17:906:fe02:b0:c16:785:cfb6 with SMTP id a640c23a62f3a-c208d2df2bfmr835635366b.3.1786369127239; Mon, 10 Aug 2026 06:38:47 -0700 (PDT) Received: from google.com (135.91.155.104.bc.googleusercontent.com. [104.155.91.135]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2080c90eb4sm385690066b.35.2026.08.10.06.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2026 06:38:45 -0700 (PDT) Date: Mon, 10 Aug 2026 14:38:41 +0100 From: Vincent Donnefort To: Steven Rostedt Cc: mhiramat@kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com, linux-kernel@vger.kernel.org, Sashiko Subject: Re: [PATCH 4/6] ring-buffer: Fix subbuf resize concurrency Message-ID: References: <20260806211306.3704194-1-vdonnefort@google.com> <20260806211306.3704194-5-vdonnefort@google.com> <20260808145854.4ff68a39@robin> <20260810092606.1742d25a@gandalf.local.home> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260810092606.1742d25a@gandalf.local.home> On Mon, Aug 10, 2026 at 09:26:06AM -0400, Steven Rostedt wrote: > On Mon, 10 Aug 2026 08:54:22 +0100 > Vincent Donnefort wrote: > > > This is probably the issue. > > > > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c > > index c2cbdb3ef727..a64cdc925078 100644 > > --- a/kernel/trace/ring_buffer.c > > +++ b/kernel/trace/ring_buffer.c > > @@ -3534,7 +3534,7 @@ rb_event_index(struct ring_buffer_per_cpu *cpu_buffer, struct ring_buffer_event > > { > > unsigned long addr = (unsigned long)event; > > > > - addr &= rb_subbuf_size(cpu_buffer->buffer) - 1; > > + addr &= (unsigned long)rb_subbuf_size(cpu_buffer->buffer) - 1; > > > > return addr - BUF_PAGE_HDR_SIZE; > > } > > @@ -4123,7 +4123,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer, > > new_index = rb_event_index(cpu_buffer, event); > > old_index = new_index + rb_event_ts_length(event); > > addr = (unsigned long)event; > > - addr &= ~(rb_subbuf_size(cpu_buffer->buffer) - 1); > > + addr &= ~((unsigned long)rb_subbuf_size(cpu_buffer->buffer) - 1); > > > > bpage = READ_ONCE(cpu_buffer->tail_page); > > > > @@ -5033,7 +5033,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer, > > struct buffer_page *bpage = cpu_buffer->commit_page; > > struct buffer_page *start; > > > > - addr &= ~(rb_subbuf_size(cpu_buffer->buffer) - 1); > > + addr &= ~((unsigned long)rb_subbuf_size(cpu_buffer->buffer) - 1); > > What about just making those functions return unsigned long instead of > having to add typecasts all over. It shouldn't hurt the places it's made an > int? Although I'm not sure if bots will complain. :-/ I thought about that, but it is used to assign to 32-bits variables, such as ring_buffer_cpu_meta::subbuf_size or in ring_buffer_subbuf_size_get(). so it felt the (unsigned long) cast wasn't that bad in the end. Alternatively, I could make all the "size" (_size, _capacity _max_data_size) related accessors "unsigned long" and do the same for the buffer_data_page and buffer_page accessors? And just WARN() if we set one of the meta data fields with more than U32_MAX? > > > > > /* Do the likely case first */ > > if (likely(bpage->page == (void *)addr)) { > > > > > > I will resend a V3 dropping the 3 first patches you have applied already. > > Yeah, they are already in Linus's tree. > > -- Steve I have sent the v3: https://lore.kernel.org/all/20260810125633.3344684-1-vdonnefort@google.com/ -- Vincent