Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5019284rwp; Sun, 16 Jul 2023 17:13:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBi4AygltibtdALgMpw9jvHk5sCdTnOH2sD1Y4rIIVE6ulFUK3+ne8eWowOXA82bE7v/7P X-Received: by 2002:a05:6a00:e0a:b0:668:834d:4bd with SMTP id bq10-20020a056a000e0a00b00668834d04bdmr6364534pfb.0.1689552782288; Sun, 16 Jul 2023 17:13:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689552782; cv=none; d=google.com; s=arc-20160816; b=BqBLIk3tyB7QHHbHOsBU8NkLKnDQbxjpJKyJeOlZQXQm97WwO/EW3O6wBsRs1GV1lS YUImWzhC5bhHviA5iPj+22fwYz7Q21HClqgbak7l/ECXXHxhvotwfZZg46g5M0bxbuLE 1el6nrmFVQ9IxUinmzf0IvsPHjy9Med3ImHMnqJksZJE5dsPPAqRuUK5cive0BPXj0Nk 8wyEkDm+/OpszNBLxu8YMRFpES8IonLbTTix+thi8Y3FnEfeS1JN7fWDaWxu2Rer/qkZ AZTPyI+0DEQL4D6Xx2JtfwRZT4qRs0Ug+AnL2ODx9saAiHwem3wwW/Kd/5bLJuB1MgX2 yiLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=eOpmZqk4kshACiKbeC0h2kjWGIm4GcaIEOU1JIxfu3A=; fh=1QkAkWgYseOEp3feMHSbEKGRtG0x+g70vUG3GXq7rGY=; b=b5n31GXJFWucskCrjUGZtBvfc2t6qFaPB7MA4/gLFN5WGcQlat4l0RHNLIYn5lnwC6 xmYM9GBjuRplwOQ0FgHs20EVKXZpKU+zoZvRZwaiB9j03tF+ROHq8filHtor3KJfRiUH GSk6WqdAFClDBhZwXiK1InujFVSeCxew7uv02cklmKNZ3pGeXAYQdoeF7NiCMJ/PIRiU TQWeRyKesVCXfbDmMZ18CHN9B+H5MrB0kpNgFrQ0uVRg5No84RFaQXusHKlZVjx10HfG x1C+OhrPisZPzhjMMdh77qyI9bKj3BAfHy53/KGSU61cxU1nurRXGIDsnDz4vJmXnfKM 8RxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TBFRNmSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be7-20020a056a001f0700b0065addb172d1si10834918pfb.380.2023.07.16.17.12.48; Sun, 16 Jul 2023 17:13:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TBFRNmSh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbjGPX5R (ORCPT + 99 others); Sun, 16 Jul 2023 19:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbjGPX5Q (ORCPT ); Sun, 16 Jul 2023 19:57:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6D2E2; Sun, 16 Jul 2023 16:57:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D969860EDF; Sun, 16 Jul 2023 23:57:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F19C433C7; Sun, 16 Jul 2023 23:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689551833; bh=+2BhqY9zrhKuYyQ9etJS5H8r5edL7fVLVmdomTcsJy0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=TBFRNmShB+QtUymfhfsuzlj3mrAUiU+5Hg+ldphDuktGwVKO+KxXQagpUkGBQJbWl hXyeF+Rfg6ewUcNhDMsuBvqcdWqvqawpVMD6yWImZiyxQtdvTYWzL+kMpw5xzqpRhG zeXaT0cOS+lRpVDZ6s045vluNNr6NG8cNDQ0AcffxOFmBiEOaCwDgVYYnRJ3T4sqWQ wzLuT7zwBFRFCBLF6Pt82BWVaS82xTXICHEGNuTljfml0iqwe6rpTBHVuINaJ0uP2a 1u6ABa3DonIrUNt5odDi+lmA05AzQN6US36BEfW0zBjuLP3/0xlzgySFmJCGVXiatb uc5uAgsCg/N8w== Message-ID: <73971895-6fa7-a5e1-542d-3faccbc4a830@kernel.org> Date: Sun, 16 Jul 2023 16:57:07 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [RFC PATCH 06/10] net: add SO_DEVMEM_DONTNEED setsockopt to release RX pages Content-Language: en-US To: Mina Almasry , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, netdev@vger.kernel.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: Sumit Semwal , =?UTF-8?Q?Christian_K=c3=b6nig?= , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Ilias Apalodimas , Arnd Bergmann , David Ahern , Willem de Bruijn , Shuah Khan , jgg@ziepe.ca References: <20230710223304.1174642-1-almasrymina@google.com> <20230710223304.1174642-7-almasrymina@google.com> From: Andy Lutomirski In-Reply-To: <20230710223304.1174642-7-almasrymina@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/10/23 15:32, Mina Almasry wrote: > Add an interface for the user to notify the kernel that it is done reading > the NET_RX dmabuf pages returned as cmsg. The kernel will drop the > reference on the NET_RX pages to make them available for re-use. > > Signed-off-by: Mina Almasry > --- > + for (i = 0; i < num_tokens; i++) { > + for (j = 0; j < tokens[i].token_count; j++) { > + struct page *pg = xa_erase(&sk->sk_pagepool, > + tokens[i].token_start + j); > + > + if (pg) > + put_page(pg); > + else > + /* -EINTR here notifies the userspace > + * that not all tokens passed to it have > + * been freed. > + */ > + ret = -EINTR; Unless I'm missing something, this type of error reporting is unrecoverable -- userspace doesn't know how many tokens have been freed. I think you should either make it explicitly unrecoverable (somehow shut down dmabuf handling entirely) or tell userspace how many tokens were successfully freed. --Andy