From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed2-f12.google.com (mail-ed2-f12.google.com [74.125.228.76]) (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 2AFE945D900 for ; Tue, 15 Sep 2026 07:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789456587; cv=none; b=QImhSqsIcR5QH6y1cs2RUfE8p+h+AtPAbfFeCR8TfJmsolfYblJnAhz7+hTr6u4lIXzcCBntGlc74RlOpPGXHAWfb7f5E4tRTtOyFosWOCzjxgGeyGyzaZzLwchLxL2wB24XV1VrlSpfe0gmybZNOFtLdr2IkfdPIVJiY4EVZak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789456587; c=relaxed/simple; bh=0OEldKzHhvkbzoc57SjOq6JvGavLCHquBbc6Yq5zze0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LdYq9nZcJXdTTqp5vHqquhsa8SrvNQQG2F22vgTPwyn/9HXMZR+SnQBk5svyPh5w2vM+hgiatY7eMTu3bL8qnpSXcLGBmAMSfHmhqVtw6VQoyMC+TSuhDmpo+MY5WasSu6tG4HeI3dBfwGYHYPoaFTZ7NV+Jy/49ONT+dAciKFU= 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=Hq0qtWYa; arc=none smtp.client-ip=74.125.228.76 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="Hq0qtWYa" Received: by mail-ed2-f12.google.com with SMTP id 4fb4d7f45d1cf-6a99c5de614so4137451a12.2 for ; Tue, 15 Sep 2026 00:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1789456580; x=1790061380; 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=W+PRomH3eBPy4oMEKXIP3fH6Wa2h0KkiuNEK9e340p8=; b=Hq0qtWYaKxMcGScWSb4W4GIoFRYwCWnxQY6BfK32sxrCGPJj5n7v3iWpw+cyPQ8aN5 ctafwXNTKj9a/C6qYpMS757///HMhMWlRua7XqWSj2RKvqV1cwHvK9JlDEd1yfDu8Tj0 y1OutLwvT5+VaDKbBKYT6c3ffZu5Q7n2OvrSvh/onUG9poi83WNfmkgZOzahuVJxO1g/ 5XK+P0xKnCnczTiSkwM3HuEBK2FI3S6tx/RVxSWZj09z6RTG8NqsV1JSN+gJBYH14tIi jcO2VHeZhGdpwSiH1CaoMy3zituJFlBeiRQTt3kkLef+nV0l2v3so9A1J4Nly5FWcimj UJRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789456580; x=1790061380; 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=W+PRomH3eBPy4oMEKXIP3fH6Wa2h0KkiuNEK9e340p8=; b=G909RJqPB9LGpmHfq2Cn+EMZPBv/crTwlYgvlLygujdEaBa1TPynSdiRRucpw0sz2o OxBLn4aWYMoGSQj9fdxNL2JF8Mi0NeY1j7Q1pycyMAmn2pC4s51xRXTFQgaXns1yl5/T JtoOxQHtrradMIkk7+4nDZU6CMBms50eG+64jXtsecIaE3WvBSpfDpYnMRE/n8soFg6E C/a35qdCYZ/fPN979koixDTu5EaoZYms0RKlg8iy6n9xm2aLQsusS37fUqtTNh1K1yTE dYnYKt/8srrecAwuqQTFY83ADb0g+afrFCkn9+l9GySZY2uI0QajMAqsbe5f0UtRpEkT Ar7w== X-Forwarded-Encrypted: i=1; AKwUvBwpDXIJ1p39X+xtUkuNG771yvr/gcl/k7oBuQRxMixWFSZyox1hCcjJ0Kf0dkVQvxOUpDEUCRODEb6RrCD0JwGNvMw=@vger.kernel.org X-Gm-Message-State: AFuF++nPC3vJnOPFxXEt97O0yG032x+/2ZU2q5Z/hZsrWpVl8c3eX2Ce 49iwyGixK0GKNPr2B9FV3yUtRYtYmeyVNZzKHVSoaxj0FXsu4H2oS3tPFEJSxfVMPA== X-Gm-Gg: AYBFou2caoYDUg+nYorhVJUaItLf5bgcFhj64A3PGHrJz01B2yIn9tBX8wP6NgUQf9K 59tFuDPtynRGJ8oADzPeJ94qkFvaPOVWl3xPUAuOzbiQ9yZaEAvuL5JBuureE3y3gHbfkm4Ds+y L4ICnTQsHycAVTQ2W+pFcbS+/A1TykkLbTZOH4FzWTWXI0TmGP3vHGdJ8UG/zLAsnINBfrdsbvK pV94iUhyBN1egyuT9EG+JyVG8/ntuOiYh89LzyYRilFc5BF5eECrQLW/ArNwcwNPVz/t5HeVPOi U8oaVO7C44LHP9SzmOKyXw+KkcL+snUwL659aHqm9scXfccwo0cEwM+uyklaLiPuWj65gVW5ys/ E59fWEDImEak40nLW7OSFYfeH9dLqVzzE0SXGRiHzwrTjAZfktJOGqH9FWoaek+0+uSbmaNof5n Kw1bYwatjFMO2P8DpKx1z1spDN5DjC03sbeKe7fE3K95nZrZflzvN9jZTnWoyLcROl57tY/vCyP HgbV/T5nq/oBi6DIIv90JHgeWPDgJAJKJlknIICMhA= X-Received: by 2002:a05:6402:4617:b0:6a5:f4eb:df3 with SMTP id 4fb4d7f45d1cf-6a9f61e4e87mr7464066a12.2.1789456579785; Tue, 15 Sep 2026 00:16:19 -0700 (PDT) Received: from google.com (135.91.155.104.bc.googleusercontent.com. [104.155.91.135]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6a9d0ef7228sm3569166a12.9.2026.09.15.00.16.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2026 00:16:18 -0700 (PDT) Date: Tue, 15 Sep 2026 08:16:15 +0100 From: Vincent Donnefort To: David Carlier Cc: rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] ring-buffer: Take cpus_read_lock() when changing the subbuf order Message-ID: References: <20260914182850.21449-1-devnexen@gmail.com> Precedence: bulk X-Mailing-List: linux-trace-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: <20260914182850.21449-1-devnexen@gmail.com> On Mon, Sep 14, 2026 at 07:28:43PM +0100, David Carlier wrote: > A CPU coming online during ring_buffer_subbuf_order_set() can be added nit: a "new" CPU or "A CPU we've never seen before"? Offlined CPUs aren't removed from ->cpumask. > to buffer->cpumask after the allocation loop, and the install loop then > uses its empty new_pages list, corrupting the buffer. > > Take cpus_read_lock() as ring_buffer_resize() does. > > Fixes: f9b94daa542a ("ring-buffer: Set new size of the ring buffer sub page") > Cc: stable@vger.kernel.org > Signed-off-by: David Carlier > --- > kernel/trace/ring_buffer.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c > index 04bb94c29f58..445931bc9ae0 100644 > --- a/kernel/trace/ring_buffer.c > +++ b/kernel/trace/ring_buffer.c > @@ -7464,6 +7464,12 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order) > if (psize > RB_WRITE_MASK + 1) > return -EINVAL; > > + /* > + * Keep CPUs from coming online while changing the order to > + * synchronize with new per CPU buffers being created. > + */ Can we drop this comment? cpus_read_lock is self-explanatory. > + guard(cpus_read_lock)(); > + > /* prevent another thread from changing buffer sizes */ > guard(mutex)(&buffer->mutex); > > -- > 2.55.0 > -- Vincent