Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp862439lqb; Wed, 29 May 2024 12:49:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXCCUoINa0Axx29byNJwBD5ARRfP5B6YyQ6s9smiCySfhdgoQLOorxa9AhidzGfQ34sJmabeiFTzlTTgEv49eaJribh7yWpiTwp8mJQJA== X-Google-Smtp-Source: AGHT+IFHB5CaWyzoes62Dov9yD7tT/SCEN3ryMxArIwXQvSgARjk1qWPTwtY+dMgy3IY/NxmrSN1 X-Received: by 2002:a05:6e02:1c2a:b0:374:5e74:4bd4 with SMTP id e9e14a558f8ab-3745e744ea1mr88809125ab.20.1717012192297; Wed, 29 May 2024 12:49:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717012192; cv=pass; d=google.com; s=arc-20160816; b=w/HlNfCJFKMUvdQGU9q8CrOlhr3Hl4iZ9G794KoaovqrhFV5RbzCt70Hr4H7DBtaAH bfaoe9wXkZvIiurEDcZdQQ99CMYptA4+Z9PdjooFxFSQfOk6vWNPGWSeKRF8ksU581Qi CVXtCCokLU7FlIKc5x3g4VY5iU+Ja3lpmPHs/lTGtFg5RrolP3e82MzYptxDXcaUTIH2 5QP3nB/TnnO5SI8phbSTp7nYrd9920K93ZlOv9GG7j9K5rgcfQgS7uBmDEow1oIKtaEj ShdI19OZeqUBPFDGui8/X/CVCQN38wmgh7fN3A/SJ2Q5Z2WG02e/KYicGYZTV9uysoJt FvyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Mc6m1mM9m4Ud5DdSGHmt9Zcx4NpBQQ1agEgintMCgFk=; fh=WnUVemCIvQAiSLc3aIJbKKZu3t2JSlIElHj4T/KOuTs=; b=jpmUkx3sfXWwrGzctdaT3FCUptfj5LULDU9qu7BYlZ3WdiVMjNHKvNwkHiPJAMdRBO pG5AZGBHwVZokS11aBrGusl+u5KZYJYs9uU+VQe8ItPugnXcODKE6FqTJQ/2nS0LUXea uEHPl83cB2cPy6KlNFRxc/vw/tqOQ2aIV0/sNgwk9X85nXlpDNbdN5D/4FkKGdDa1I59 B1E4rFt1JEzmvIovlW29jTIqO0JMjZV//49QQmMSjA5Rq9yhhb6Kc2qrRpZTKGdAMPu8 6ENbmU9brTbRjlD8YVf/hI4i83cpYyYJit4B7NUjbA18t/CEwrGPoEefwgFUlKr2x5xW Z8+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WaKJxj2r; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-194624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822bbc73fdsi28624a12.886.2024.05.29.12.49.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 May 2024 12:49:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-194624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=WaKJxj2r; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-194624-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-194624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6D66EB23323 for ; Wed, 29 May 2024 19:49:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9DAA1C232B; Wed, 29 May 2024 19:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WaKJxj2r" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (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 38F101C6886 for ; Wed, 29 May 2024 19:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717012167; cv=none; b=hilnwhUC30m5HLbVICG0P65ivGDHjghap6nuwNLDVtzy8qNgsMEhne66i19Cqmm4ilLZsWt0F7UuzerLiUehltHA1CGUc+BE6obTfPVXd1hHOvu1aL1XyXhABfKgy1giwYntmz+n1OlEoPHrMs4HUdm62lVTOc425XjlvKwBpwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717012167; c=relaxed/simple; bh=6SM4nGMq6YXwjPx3hzOgTtkr8rnEX3Vki2GtQ9/v/Tg=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MVLWBzmsfmqrqTarowKB9W60YcJVv68BdL7cWPZoXC1vlWbrGbqfVkb+mO891v1C+KWtJZydbfDwy7l3tZtJPfoygE6/V0E5cd41qlLCVnu9P5GimmB4Ke7FshJFqUkQpBzzyxtdBEff4GZJXvlcqC52XKXJbB5J3yEDGahFZ5A= 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=WaKJxj2r; arc=none smtp.client-ip=209.85.208.41 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 Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-57857e0f464so151102a12.0 for ; Wed, 29 May 2024 12:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1717012162; x=1717616962; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Mc6m1mM9m4Ud5DdSGHmt9Zcx4NpBQQ1agEgintMCgFk=; b=WaKJxj2rSmiptfxPuIpvUd4DO37VpSMk36dQcSjU2nfbhLrs/6sj+L957ozHRkSxyE TahFIlyXavs4CwVkXbGgibHaZ78nBGAoNz1E+2HWXC9+7wpBE9x3fU/+vVUNcUW6rJqc n0wSQUBi2d3dc4nr8ulLpmSegCq86rCBEhG/icMRdmocKpO4NWAppHoIuWkJ8uNPH+jX o2ArPykUTi8L9m/w0vlaDn5Dc8OxRXwlaoO9jd/ezYSXQJ3I6lBNJtlfF/AcwBvjH0to Qv6SqMuA/Yte/M52TzTy7XMHZ3YE8iF0RhhZ/93YZjD2Ch6+/yU4fVLtCjI9qC9Bx0KN 3KUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717012162; x=1717616962; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mc6m1mM9m4Ud5DdSGHmt9Zcx4NpBQQ1agEgintMCgFk=; b=TDjyuGB2TXMIeGbDDGEW0KwlwO+BnT7XftaH/zXqaquxmhM+Z3UygI+5HJCS5gbegS 6RQABStIFdDJdyLk5L/6kUTmSZkN1ZgQnfug10dhQ0Y/lsevBJoPTUcrZDcUTzX5Lu5B PbN7CtfE1lyl9uuZgMDBZZQUS3brJ+QquLL4qyaWEn12QSRdEIGd8RgtSWUmag+iOliW s8usszZdQfuYeT1HlvO2FNeCFdCG1lzgBFlkfdDPRidjmItrOxHhGl+WS+2SLAXX5wwl mHfisLKmV8R22zI5NZx8mCFHwXdtfRBeyWcyCQUdT9ECUMqofuXJLMCYJnRNffEf2luY +cuQ== X-Forwarded-Encrypted: i=1; AJvYcCWuLcQIoBpxMTkEgxs9N+0lhKh2MflmYWX9KyKaIl/D9ep5f3Ncdbysf/NUyeoiarzgCASoxwpc6Gz6j8/7aWYSUu10p6FQfKBhIAvD X-Gm-Message-State: AOJu0YxaXEc/Uum/QxaQaYVe49OHwVt5tUAIQNB6KxceFlga8cEVxcRo +IFJIPX+DaaXVA8gJIDxxI6H/OYu8OqA+/ZCc9CTsK63doogSO6jxiEafw46M6PlTBJjWH1ajB2 bBvBJo7qJCsImVS+jUyPvWuhq97aDp5eeoMoh X-Received: by 2002:a17:906:c18f:b0:a63:49a5:9390 with SMTP id a640c23a62f3a-a65e8f74d3dmr11845366b.41.1717012162364; Wed, 29 May 2024 12:49:22 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240510232128.1105145-1-almasrymina@google.com> <20240510232128.1105145-5-almasrymina@google.com> In-Reply-To: From: Mina Almasry Date: Wed, 29 May 2024 12:49:08 -0700 Message-ID: Subject: Re: [PATCH net-next v9 04/14] netdev: support binding dma-buf to netdevice To: David Wei Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-alpha@vger.kernel.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, sparclinux@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-arch@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, Donald Hunter , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Andreas Larsson , Jesper Dangaard Brouer , Ilias Apalodimas , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Arnd Bergmann , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Steffen Klassert , Herbert Xu , David Ahern , Willem de Bruijn , Shuah Khan , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Pavel Begunkov , Jason Gunthorpe , Yunsheng Lin , Shailend Chand , Harshitha Ramamurthy , Shakeel Butt , Jeroen de Borst , Praveen Kaligineedi , Willem de Bruijn , Kaiyuan Zhang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, May 18, 2024 at 11:46=E2=80=AFAM David Wei wrote: > > On 2024-05-10 16:21, Mina Almasry wrote: > > +void net_devmem_unbind_dmabuf(struct net_devmem_dmabuf_binding *bindin= g) > > +{ > > + struct netdev_rx_queue *rxq; > > + unsigned long xa_idx; > > + unsigned int rxq_idx; > > + > > + if (!binding) > > + return; > > + > > + if (binding->list.next) > > + list_del(&binding->list); > > + > > + xa_for_each(&binding->bound_rxq_list, xa_idx, rxq) { > > + if (rxq->mp_params.mp_priv =3D=3D binding) { > > + /* We hold the rtnl_lock while binding/unbinding > > + * dma-buf, so we can't race with another thread = that > > + * is also modifying this value. However, the pag= e_pool > > + * may read this config while it's creating its > > + * rx-queues. WRITE_ONCE() here to match the > > + * READ_ONCE() in the page_pool. > > + */ > > + WRITE_ONCE(rxq->mp_params.mp_ops, NULL); > > + WRITE_ONCE(rxq->mp_params.mp_priv, NULL); > > + > > + rxq_idx =3D get_netdev_rx_queue_index(rxq); > > + > > + netdev_rx_queue_restart(binding->dev, rxq_idx); > > What if netdev_rx_queue_restart() fails? Depending on where it failed, a > queue might still be filled from struct net_devmem_dmabuf_binding. This > is one downside of the current situation with netdev_rx_queue_restart() > needing to do allocations each time. > > Perhaps a full reset if individual queue restart fails? > Sorry for the late reply, I've been out on vacation for a few days and caught up to some other work. Yes, netdev_rx_queue_restart() can fail, but I'm not sure how to recover. Full reset would be an option, but it may be way too big of a hammer to do a full reset on this failure. Also, last I discussed with Jakub, AFAIU, there is no way for core to reset the driver? I had suggested to Jakub to use ndo_stop/ndo_open to reset the driver on queue binding/unbinding, but he rejected that as it could cause the driver to fail to come back up, which would leave the machine stranded from the network. This is why we implemented the queue API, as a way to do the binding/unbinding without risking the machine stranding via a full reset. This is the previous convo from months back[1]. So, all in all, I don't see anything amazing we can do here to recover. How about just log? I will add a warning in the next iteration. (I applied most of the rest of your suggestions btw). [1] https://patchwork.kernel.org/project/netdevbpf/patch/20231106024413.280= 1438-13-almasrymina@google.com/#25590262 --=20 Thanks, Mina