Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp453082lqp; Mon, 10 Jun 2024 08:59:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWFjamymVK0jG01Msw28GNq+LfEE5ow/XeFrnVXFj1ponxqzHf6+CQAUBWlcjJ1eK/oW2brWdWvQ16uZb+epSI5tDflDsEXi085X047Q== X-Google-Smtp-Source: AGHT+IF5q2qSQxvWuiv5tQClLpqJA9t4jmWgUOTqi5c/Tev3ISJfFXsh/yqx6txe4e6+jFy57VQC X-Received: by 2002:a05:6a20:3ca8:b0:1b6:c527:7e42 with SMTP id adf61e73a8af0-1b6c527811amr4151200637.3.1718035146554; Mon, 10 Jun 2024 08:59:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718035146; cv=pass; d=google.com; s=arc-20160816; b=uN15V7BcRnod4AM2kUunnaZzpVYEdCM8Ko/EtdlMw54wgqVxGYzdCvrvkUpJ3eBv9s i9DUWmxF3d9cxkydMlSiNUgz5Tkk5pA5jQaEJnPHbFyGShlzNKn9ENcs+H/0xkkzxVws VmaZTw2x9RYX74cARS/mL+X3sUDN6qz927fjZHe0M6aT/Teab1n781NiJ4ifk/EfHSzy 5UhSHJYgeteB/UF4CQfl8FnfZka2PSn+cZB1Rhq+8txk05cFf9y1JWktUSi7bXguoNpa 5L0OqMColivfplValjc8w6ZGb2BH9iOyPcmp0QflggCPd99OU1lzVZ0Y3TuRQLhrwMdE nuYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=BIUzr0ZExg6jPnSE74d71eTmn3fIa3SvQfQ4xEceAMo=; fh=Su4EHRkylUFTOhrLamiyGeNyzf5PJwqMb8PbJoWZ+Ig=; b=X+7twPOGnWeHfJsHRVrEDJfrsFrkHO8OYFQFPVjj9Bb/lvQci5CxU+lbi+Ejmvh2Tf eC75icvWXXsVy6NLBNqy/q1hi7J+7xcFDNr1ivXidTCjIJvxP+v6rmKUc4GVotbEKQ2E wmN+HQtX5foHA6VP8GJ9d7T8J12vRZYGRm30g/sntMatTBk6nGfbhchN7GLrHkvPjBD4 HqlRzZOIUhPOBeRiZrMf7fBf14AEWF1n0TelCcrvThEiJBAOqsGbpkX6bp8ufcQ5TNEZ s77gWq5uERoOrFoc2o5lk/HhLqSZoTj3HAPDf1HlTpjdFiiGzqIolahlPdd6L3gTK+AJ JvXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-208521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208521-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6f3771f88f5si1113939a12.740.2024.06.10.08.59.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 08:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-208521-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208521-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A8BBE285045 for ; Mon, 10 Jun 2024 15:57:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EC1C142E9F; Mon, 10 Jun 2024 15:57:01 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A06ED13F458; Mon, 10 Jun 2024 15:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718035020; cv=none; b=skx72BHklSJvIcuKBhFky+uEjNjLt3OajTDIMMJy8YhMVIjbtmWuiPcop0C/kDWVIipAPEpUJyaE42/kdr5iOsrbfg0oix71NZtUQQvGnvFGDBizQ7ubr8ErqKgifJne3ILHI1mwB6zvRJol9S0+kmXXFj9gHudOYF3hT0dVWmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718035020; c=relaxed/simple; bh=BIUzr0ZExg6jPnSE74d71eTmn3fIa3SvQfQ4xEceAMo=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ov4HMEcX7Q3NSzgNXEBf5k0d1S11FdbECPOzW32Sp06CmMLAaykLD8sIb95E6rSvxTxrRZOssW6ku+zTUz3bjf20mSGy3t5RnODFKqoam0r6Lo32kccskuRJ0pvDb9tO0IZdoF/YCJoHrLbRBayrVM0gAxqhE2PJfY3dRk75qTs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67034C2BBFC; Mon, 10 Jun 2024 15:56:59 +0000 (UTC) Date: Mon, 10 Jun 2024 11:56:58 -0400 From: Steven Rostedt To: Petr Pavlu Cc: Masami Hiramatsu , Mathieu Desnoyers , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-users Subject: Re: [PATCH 2/2] ring-buffer: Fix a race between readers and resize checks Message-ID: <20240610115658.27623de4@rorschach.local.home> In-Reply-To: <8f5dca5a-330d-4258-8e01-0734ffda361d@suse.com> References: <20240517134008.24529-1-petr.pavlu@suse.com> <20240517134008.24529-3-petr.pavlu@suse.com> <20240520095037.33a7fde6@gandalf.local.home> <2b920bab-23a2-4a8d-95c2-b69472d38373@suse.com> <20240527194356.5078b56f@rorschach.local.home> <8f5dca5a-330d-4258-8e01-0734ffda361d@suse.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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-Transfer-Encoding: 7bit On Fri, 7 Jun 2024 10:29:03 +0200 Petr Pavlu wrote: > Another option could be to try traversing the whole list in smaller > parts and give up the reader_lock in between them. This would need some > care to make sure that the operation completes, e.g. the code would need > to bail out if it detects a change on cpu_buffer->pages_read. I think I like this approach the most. Perhaps even have a counter that gets incremented everything a new reader page is taken. And if it detects that, it restarts the check? To prevent a DOS, we restart 3 times at most, and then just say "the list is OK" and exit. So basically, we release the lock within the loop per each sub-buffer, and then check if the reader touch it when reacquiring the lock. -- Steve