From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 8FFCD392806 for ; Mon, 16 Mar 2026 12:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773662692; cv=none; b=nITnIoEqlLcGDsoC/5gODHWNoIsTV4k35Ow/lT97XqsImdqx4pTSdQurcWxsHxLfc3mWJfOU+Q106W1BP9jIBWV7SQCFnbw1NuDp5ekiLzJDng5VtEGpdmP38RBAlLz2LrWE8h2az2y/pBGpx2kqmieK8c0sByWfRr2LjhXM6gQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773662692; c=relaxed/simple; bh=CN3BB8jMqtpHX9v247an8eQx/ZrNnfSh/VbSD9NzPqs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tg3N82MmV2uNd3HIdSaI+IprQC1trGFjC3QyYjCsnLIDffFUoJU3WVwq1CB3sGlzmBkU3rJ2RznCSyW8kD+F509oyT8XQz2m6fKiYjGfsVaWSKM4vArLHXN63VQAwrgGywgSyd8nQVclFc+jCnkbaqvTO4cGpvccElbEKZ42DOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=B6qk/CCO; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=se7ezDlR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="B6qk/CCO"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="se7ezDlR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1773662689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=T1ThxgnukPZdnVsAXkBiIHRauBYKnXhO8ujaThY4wrs=; b=B6qk/CCOIDDu4d5C2GaX7UJl2f6iHespLdxQx8qAMfnYPIBR3gOmHIF20o64nh9t27Hx+y hXbgyrO5CN80v6ZPTLQ03FO1qRn2FkRC+pmG3UzRotTzsWwTHptYjuk/iASyqep6E9G5nY fhME/5CpAoHS6Fkv8pFGdNshpqMfwsc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-20-m6Ya3nHLOPuVxQ62njq8nQ-1; Mon, 16 Mar 2026 08:04:48 -0400 X-MC-Unique: m6Ya3nHLOPuVxQ62njq8nQ-1 X-Mimecast-MFC-AGG-ID: m6Ya3nHLOPuVxQ62njq8nQ_1773662687 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-439cbc5fd75so2886718f8f.0 for ; Mon, 16 Mar 2026 05:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1773662687; x=1774267487; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=T1ThxgnukPZdnVsAXkBiIHRauBYKnXhO8ujaThY4wrs=; b=se7ezDlRaUu4aJvrOrGEQkKwfWQSAZNbKwnjEXPDfNjBEjK3Chm5gLzEIdw7ttUecR JS3g5mDgA+XApXfR4Xr0pcB2HeCUNch32EXvSeyzIfGuo5dCAoazC1uPm8FzmjXH0tyK s2LhJ0yhfUixMgkw1FDM+paag6aTSOmcpeoqybVVm7lZUgbhVFVyt7P/5ub8zVNU57md w6g7zqES2nN3V/VoKZ4V+wEIJOCW8QYD/sa+aMXKjHnIEBcJAui46QA7k8dVTWpGEGgL AdGwQjAiDQeeJbgu3tWW/jyX7XSAiXUxLPiCGDwKspPF2ID9ppKColFVGCcYqwKYNDqQ 9UyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773662687; x=1774267487; h=in-reply-to:content-disposition: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; bh=T1ThxgnukPZdnVsAXkBiIHRauBYKnXhO8ujaThY4wrs=; b=Mbm86pILfL9+rMDHasBFtD4FmmW0vi1h+hu0wmMWKcCinjJmmZao2e/Rp8f7drucCf 8V7d5YSsVMXwFLlD5DBciOlFEakxsvAYMuXYSAFAsweqVNmIbD8MPLcaR/1tYCtNdIf6 8TzZwptuRCyqJFTSp2h0lBtXDEyJ2o8cVJrQWnP1WYRlUnSWKaYoazZ7LPA4lxmTk6BJ czaDUJdbhrabvwuDvakfBtM4rfxeowKmU6d9Re1Ul+Vt2T/gyuW/oAu0A3ijMF7ho7vb c+OOvboTQqkVB73w4F8vjPcqI8z3oj9LraBTR3tGvuneHJyMaY/BotUPzKzRdLOhVrES jVhA== X-Forwarded-Encrypted: i=1; AJvYcCUW4uHyZ1dmLa5JuZf/cYBbvU+F6Erp/j2V0/Rc+Ld0rC3OqJpERKdZjhTTmrxip/Bb1Z0SfyJhYO72Wms=@vger.kernel.org X-Gm-Message-State: AOJu0YzOaOOYdw4RxaepyXeDeRa+NIb6dnTxWkvLhWQNkaxgZgrwmbPD TLV3kY5d9PiVpNEQp83uwJ4lH3GwqMgeq1jzj3qIefH2gDkxGDFYjXPCW8STd1ObgAGWg93yUt5 2TlD/tO9M78fscXD/tM6ivStcKN4ZeVgwHKJJtivCgg3ZaUmf1ZAPo6JimmCp3gluEw== X-Gm-Gg: ATEYQzz2t4mIxlGjyh3NfEIVVHQrTmQtkyOh/ZSnZI8qTK+fCGyljuTLSO0Rq2y/gS8 h1vssPLSEBRfjAiTAUCBvnI6pkFkcW8hWc2cone/EWGRGy5e6c/X05BYD2vjhbIQVbi7QGkhOtG NoOF2PtCdo9e1jSH/DYex3TQ73X2/GLxDbIv5KzLw/GhLEUxN10DDpQU1ZAEOOCaOhVMyyRsKhv 8pWVOQZ0Yp5wV49XlX+RljR3HL7gz7t5e7ZHe/IEo8bh3D1DvrHTOkh1iWIm5vKhncQvxjNQzjt JRZYPKDcz1Juzt/6XysK4uv/d+RW4KyDMQciVnD8O80snaHIlOfc6yNDY7nPn2kfsELDTdfD4lF jzhylEN2TNlErY3R4eVmJ+IMyRcWwgdUVZlybKE7AOk31Qg== X-Received: by 2002:a05:6000:2383:b0:43b:41b5:e02e with SMTP id ffacd0b85a97d-43b41b5e19emr8017940f8f.4.1773662686998; Mon, 16 Mar 2026 05:04:46 -0700 (PDT) X-Received: by 2002:a05:6000:2383:b0:43b:41b5:e02e with SMTP id ffacd0b85a97d-43b41b5e19emr8017848f8f.4.1773662686464; Mon, 16 Mar 2026 05:04:46 -0700 (PDT) Received: from redhat.com (IGLD-80-230-79-166.inter.net.il. [80.230.79.166]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b45e5c233sm6464487f8f.33.2026.03.16.05.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 05:04:45 -0700 (PDT) Date: Mon, 16 Mar 2026 08:04:41 -0400 From: "Michael S. Tsirkin" To: Vishwanath Seshagiri Cc: Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Andrew Lunn , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Wei , Matteo Croce , Ilias Apalodimas , netdev@vger.kernel.org, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH net-next v11] virtio_net: add page_pool support for buffer allocation Message-ID: <20260316080419-mutt-send-email-mst@kernel.org> References: <20260310183107.2822016-1-vishs@meta.com> <20260316054232-mutt-send-email-mst@kernel.org> <20260316064256-mutt-send-email-mst@kernel.org> <6d43dbbb-7d04-4442-8743-3963b61195cd@meta.com> 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: <6d43dbbb-7d04-4442-8743-3963b61195cd@meta.com> On Mon, Mar 16, 2026 at 05:27:57PM +0530, Vishwanath Seshagiri wrote: > On 3/16/26 4:13 PM, Michael S. Tsirkin wrote: > > On Mon, Mar 16, 2026 at 05:56:20AM -0400, Michael S. Tsirkin wrote: > > > On Tue, Mar 10, 2026 at 11:31:04AM -0700, Vishwanath Seshagiri wrote: > > > > @@ -5857,7 +5863,7 @@ static int virtnet_xsk_pool_enable(struct net_device *dev, > > > > /* In big_packets mode, xdp cannot work, so there is no need to > > > > * initialize xsk of rq. > > > > */ > > > > - if (vi->big_packets && !vi->mergeable_rx_bufs) > > > > + if (!vi->rq[qid].page_pool) > > > > return -ENOENT; > > > > if (qid >= vi->curr_queue_pairs) > > > > > > > > > > > > It seems that a qid that exceeds curr_queue_pairs would previously get > > > -EINVAL and now gets -ENOENT. > > > > Or maybe this if (qid >= vi->curr_queue_pairs) is dead code? > > I looked at it some more and I can't find a path where this > > triggers. > > > > > Maybe reorder the checks: > > > > > > if (qid >= vi->curr_queue_pairs) > > > return -EINVAL; > > > > > > /* In big_packets mode, xdp cannot work, so there is no need to > > > * initialize xsk of rq. > > > */ > > > if (!vi->rq[qid].page_pool) > > > return -ENOENT; > > > > > > > > > Alternatively I think we can completely drop this chunk: we already seem > > > to init page_pull at all times except for big packets mode, so the > > > current code is fine I think. > > Yes, I agree qid >= curr_queue_pairs appears to be dead code. > xsk_reg_pool_at_qid() in the XSK core already validates > queue_id < max(real_num_rx_queues, real_num_tx_queues) before > ndo_bpf is called, and real_num_rx_queues == curr_queue_pairs is an > invariant in virtio_net. Both paths hold rtnl_lock so no race is > possible. That said, I'll adopt your suggested reorder for v12 to ensure > vi->rq[qid] isn't accessed before a bounds check, even if the check > is currently redundant. I think we can just take this as-is, and do more cleanups on top. Acked-by: Michael S. Tsirkin > > > > > > > > > -- > > > MST > >