From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 1942A2F8EB7 for ; Sun, 2 Aug 2026 18:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785695172; cv=none; b=BN09cATobmCpoqoB7ANjJAMicwJybVjYqe5weJHaomaLgwj04fhWeecKxxbtO/FepUtVJ0xwksst00DgxMgNPT71Io4xV8cFK4MGaDKO90rYK56wm0KyKLIlNvgFDoWp8WIR7Hmo5p87SyFXS6Noj1hmRxuoYSfb2RR9EBcnPBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785695172; c=relaxed/simple; bh=NcgeiwU7XtP+X2N/eIMpr5wojeooUp+d4m1LkY64UIM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SZoGwmHbl8h1zmnMwy4le3gKR/qm+DzZVJOROU7OAC0H8bVeQQJ1wX+Geoi9maq/uZfQDHsX9fUTnhVBDp7eqGU25l2CDAjGVnqSYX9gRQzWanOpMj+yYjBJwm1tpBNenfQ/RPiQc91XJRSGFw2P+1eow+rglNFQbFPxOApP3U0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TvivUZPt; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TvivUZPt" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5b01910b499so2255022e87.0 for ; Sun, 02 Aug 2026 11:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785695169; x=1786299969; 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=4aT1GV4BpO2FLXf9Q+ITvU4YQjpIH2TSzUI5akvyW+E=; b=TvivUZPtiP+g4w+RUUCK5WbHFd0S3+SnegygjoWEiPWm27Yh60/tv0RrkMa3g+hE6D nFgeQlksuXjf4wrlMP7ROy3rxAzNZwjokccaWiCScx5bbJVcItlG2sfjeUJo2dkO5gq/ 2RjkqGDXsedTQjUZUmQ/xcAlwfizKLJyt9YeMNDJyd7R5SKsT+NrXPl+NnOKpWvofKmR N6Tah1e3+3h2/GduodgGYdwvjWCn+Q2rgFiWONfnGVKtvcR1bIt93ePrvjeuhGRIt6EC w3Wi4qVBQFuLh4E/YQi8b5/26ao/rfvt4o3IvJIIWSFTfK5D5mVAPj+3DsiSbCBH2IiA PBCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785695169; x=1786299969; 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=4aT1GV4BpO2FLXf9Q+ITvU4YQjpIH2TSzUI5akvyW+E=; b=qyscX+80vRhJpmj/VRcZK3pbRXjFhENAqH4aP3H9TL511vdDOAnRFoojDlUIhurTY6 ah4XM3QY4KeD6lx2sDRdFHz03+3uNIx/ve3xv3WnTpLoEnNdzmoEquPgb4izcQyIdlCI uV57iEI+blwY/EAeo2HlPLmtq6qf1s0zXfKCcmFvZAptoj8vosBXOqPOaRR5tuXrAvIE j97R7EA6ehPXJ7/4muGKFo+szPY6q/g12LVecKBKApfksKLmWt2Hu9zZJA8Zl0WqxScp jb3n3feHYmLTA/mGbM/lCbpiOVMBu/efy2pp0qY0Tk80SBwe0LVsZ7gST/wvgTuhEpTs WEqA== X-Forwarded-Encrypted: i=1; AHgh+RrI/cHV7wS0P5eUPXuV8sLJfSGQJFI69l+pzYZlt3kL/HOspusUQfRa+7u516pfKf8mXUhOilbeRYGJzTE=@vger.kernel.org X-Gm-Message-State: AOJu0YznJJctXEzhT5StgZZ1UZuw680ioJAIaB8bCCPws/USg1h4FVBY HxyRqkT+Gv8G3d/VoKU8gwduM1e7mtsBO5ibJnFG1N5vKugqhYo28daj X-Gm-Gg: AR+sD135lBRGg5rxLAHnoUTeKQ9r7fstCSyVac0Xb99LVZUANPa5Ms2VbjxRZOLHqC6 WKitjEhuk1CSzxmTAYBTV3eOm8/Rzova4eVPjpxl5O+U2OzqBOSilvxY0dZA+Qc8BIBlnt5Oi+Q 3Gdh690DHS6D9apRfqAK5H5Y/lIZ/SRjnHyVw0DsQVwd6meOOyaArd7DSPqWoNSJoePY5JM5/+s 8gwM008QSKqk7xsVJoqyaa2u7lhdwVoEaiBiv4aWrrkVyC9FypSWSpCiulgA0zA6wxrUyf87GrB eGycKdQMT9rmEUbZneYMuIAZKqxzBFo5T8CGYwno+Q2SfF78CvvBd5ypeFo8LGpuZhkq8J7yGQL f9j5uK4tvCpq6m6BhKozzdjmqf+dG95VjG4u3ltdydtCMeqMVLI51V7x9xc9HnMZzvAF0CeUNT+ XxEsM6DZqaFOtryuL+eb55oKtID3hlOGgFhwFJZ0eJgrFM0YqvjRG0LuanUFYcnnhZvkubt5f9z 7OGYK6yO9y4GS4ns+e59Q== X-Received: by 2002:a05:6512:688c:10b0:5ae:b6cf:c745 with SMTP id 2adb3069b0e04-5b2e4f3e92amr639235e87.17.1785695168806; Sun, 02 Aug 2026 11:26:08 -0700 (PDT) Received: from localhost ([77.237.184.74]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5b2e23c46ebsm1578827e87.10.2026.08.02.11.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 11:26:08 -0700 (PDT) Date: Sun, 2 Aug 2026 21:55:58 +0330 From: Ali Nasrolahi To: Mauro Carvalho Chehab Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, mchehab@kernel.org Subject: Re: [RFC] Discussion: VIDEO_NUM_DEVICES limit in v4l2-dev.c Message-ID: References: <20260802125734.198631b5@foz.lan> 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: <20260802125734.198631b5@foz.lan> On 26/08/02 12:57PM, Mauro Carvalho Chehab wrote: > On Sun, 2 Aug 2026 08:24:29 +0330 > Ali Nasrolahi wrote: > > I'm working on a project involving high density video processing on a > > single server using a large number of v4l2 loopback devices to route > > virtual video streams to tenants. > > > > While doing so, I ran into the hard limit imposed by `VIDEO_NUM_DEVICES` > > (currently 256) in `drivers/media/v4l2-core/v4l2-dev.c`. Looking through > > the code and git history, this limit has been there for quite a long time. > > However, after searching the mailing list archives, I couldn't find any > > previous discussion regarding this limitation. > > > > May I ask: > > > > 1. Is there any internal design constraint that requires limiting the > > number of V4L2 devices to 256 on modern kernels? > > There was a constraint at the very beginning due to the way minors > were generated. If I'm not mistaken, this was long gone. > > Still, having a maximum limit is desirable as there is a hard limit > in terms of the memory. > > > 2. Has this limit been discussed previously, or is there any relevant > > discussion that I may have missed? > > Probably, but likely very years ago. I can't recall last time we > discussed this particular limit. > > > If the current limit is no longer intentional and there's no historical > > context that I might've missed, I'd be happy to work on a patch series to > > address it, and I would appreciate any guidance on the preferred direction. > > What is the maximum limit your hardware has? Can you provide some > documentation related to it? Assuming I understood your question correctly, because the workloads run on a server, theoretically, there is no fixed limit on the number of virtual video devices that could be used. As long as there is enough cpu power, memory, and i/o bandwidth available, it is beneficial to be able to add devices and, consequently, run more workloads. That being said, to give some rough numbers, I think supporting at least 1000 to 2000 devices would likely cover most practical cases. This is why I was wondering whether making this limit dynamically allocated or at least configurable might be beneficial, so, for example, mahcines with limited memory would not have to reserve an unnecessarily large array, while systems with more resources could scale accordingly. For some additional context, the video streams are received over the network from various sources such as cameras and WebRTC. These streams are then routed to v4l2loopback devices, which are used by the workloads for processing. Regards, -Ali