From patchwork Tue Feb 2 22:10:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 11108 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 9AE77BD160 for ; Tue, 2 Feb 2021 22:11:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 355CC68432; Tue, 2 Feb 2021 23:11:21 +0100 (CET) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 849F060307 for ; Tue, 2 Feb 2021 23:11:20 +0100 (CET) X-Halon-ID: 8be8f55e-65a3-11eb-b73f-0050569116f7 Authorized-sender: niklas.soderlund@fsdn.se Received: from bismarck.berto.se (p4fca2458.dip0.t-ipconnect.de [79.202.36.88]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 8be8f55e-65a3-11eb-b73f-0050569116f7; Tue, 02 Feb 2021 23:11:14 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Feb 2021 23:10:48 +0100 Message-Id: <20210202221051.1740237-1-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 0/3] cam: Fix races in event loop and long request processing times X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hello, Using cam to writing requests to (slow) media sometimes lock cam in an unbreakable loop. At the heart of the problem is that when request processing was moved from the camera to the main thread subtle races in the cam event loop implementation where exposed. The races are easily trigged by having callbacks injected into the even loop that takes a long time to process. The only callbacks cam currently injects to the event loop are processing of completed requests. So by increasing there processing time by writing them to disk the races where trigged. This series aims to solve this by integrating the cam event loop closer with libevent. As a bonus cam can be made more strict about how it operates under the --capture=N mode. Niklas Söderlund (3): cam: event_loop: Rename event_ to base_ cam: event_loop: Execute events in the libevent loop cam: Only queue the exact number of requests asked for src/cam/capture.cpp | 16 +++++++++++--- src/cam/capture.h | 2 ++ src/cam/event_loop.cpp | 49 ++++++++++++++++++++---------------------- src/cam/event_loop.h | 8 ++----- 4 files changed, 40 insertions(+), 35 deletions(-)