Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2718005pxb; Mon, 19 Apr 2021 12:05:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVYvw4F/L/SPX6F6/c+6mZV9AwNaecb6xdWAGnnOKK/kiMpMfsKhFmHQqV1vRIohKKKdZC X-Received: by 2002:a05:6402:214:: with SMTP id t20mr27764184edv.229.1618859101469; Mon, 19 Apr 2021 12:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618859101; cv=none; d=google.com; s=arc-20160816; b=TLDDqrF+LgDVhaj/4ThFJQzbdWHRbF0qJDH376mnGg3iKF73/ypEa/lD0Dhlij7JYG +t1Y/HHwLy42GY3UVbh9OdxD6wnNux+LvbT8GHdXcyYsmgXQ6P6q3XDZw3WGmAkr8qku V91BmqLlcorZJje/awRCH1oyAQcWghWyVlU73o+PDgfoCxeSKb7BUT6/jpPtYLTXN6eZ fQbkElVmL7BtbT3SAnIlv0AwuaabPG7afwF9Q6duiGOuTDfCjAfZBYmbHVB9dCsI+Jfg O8uY4FTbeUAEzFeNIO7rmETAm1UQvSCzICkzADpY4pmfGxxLAw2ocAVfsMukNLuNsnY6 CRig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bOY9m1eIVASQIMnSbwflGhIUTyPWYD03S/dD7MA55Qc=; b=Sim8ktRS6GaST2URZWAfugEAeLxiASYD+K3eX2nr6zPA4qnLIrSg2gWQIIemzr1ZRW KZJBf//mPfaUkt4m+8L4EXgjTYCZixVqaYpP3WqKern+y4z8DvvzmDGPE+ywQPxE9arB 30ewEhRMROsv2nyL9vixGFgjBqqget2hEQPuPfT6kPGmAC/FK9tsDYPzqMhl5YDnI3S1 RljofaACbKPla4lzgx3loQ6OyhMyouZpvWSvPkCZKtFaKHda0P1w4TzXtR9dwDrguT8y 0rnHleUMUDFgyUPHmQDltJRSwbTPu45z0ag/EpIuC1q2JXxT9k8k5fz1cziLPEnrM4Kb KMpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rgKpT44z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg20si11110334ejc.614.2021.04.19.12.04.23; Mon, 19 Apr 2021 12:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rgKpT44z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238385AbhDSO5r (ORCPT + 99 others); Mon, 19 Apr 2021 10:57:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbhDSO5q (ORCPT ); Mon, 19 Apr 2021 10:57:46 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00000C06174A for ; Mon, 19 Apr 2021 07:57:16 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id n8so56536593lfh.1 for ; Mon, 19 Apr 2021 07:57:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bOY9m1eIVASQIMnSbwflGhIUTyPWYD03S/dD7MA55Qc=; b=rgKpT44z5gZPH7IcDqEdCS5YbgmApA+chMspbQ+JZGvC+YpgKwQzzX5A4jzxNEjvmG MLlDYm4e7iCaE5IHqjOyN/ifzjPweOwwRpEg2SJB0fXvLMt8562VpY9TMa7hc7yb2lA1 2PVEZpoklcaU3AfYgP9KRx34WMyKtu4e/QsEtsbYZgOl6h8Xq+0WvD0oBFTfJC4iVd4L 6j0H/BV7sKihqk2a+lubMh5VtlxaVk/jrOh+titVm4bmXsc3XMgR5O5X+2oCsdriqvyU BMBRSMvjklWjnZ9g9t6FGjScAawV2e+WWEzp+KcGRgjhYZ/E3Qe13rckj3cpUlBiF3sb St4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bOY9m1eIVASQIMnSbwflGhIUTyPWYD03S/dD7MA55Qc=; b=IIYyh7w/pd9i5gwocs/qBVwIZn2s+mm91Pct5HrYPD7A4f+Z4UdQwRy59tBjZvH1MZ 5IzAz0Ykb/aXmnZ0oJE0RkWyYVIGsxh2cAH/rYg5rS1/u93T1H18qLloW3AiTxp6vIxj 8xdxSmHySK4lcowVusCTOwRDwC42sG5FCUqgbqBCD6p1rPVWTtqxIWqmfSF1GMes8pmF cYoQ73VS97C4fFFAFlUcDDwsy3xPdoANqqeebEG1oHHA74r/rRJZaC+Qv3Rs6bJmy+0W eLB/pgzfekpZTedVz/SWqrcYbWmjCOO9TLCa1qyeQKcIeoAEko4DFbFpHVL8Hj/NFOQD 0joA== X-Gm-Message-State: AOAM533tDPzuH8L85csHbQY/G/xr+IIuEhk07M9xGI8k8zLjlLZKD9CS l6tSmWwDtncXPGvPEkPrJPnDbSlmwVXkXnAg1Vkgmg== X-Received: by 2002:a05:6512:92e:: with SMTP id f14mr6712386lft.347.1618844235220; Mon, 19 Apr 2021 07:57:15 -0700 (PDT) MIME-Version: 1.0 References: <20210409223801.104657-1-mcroce@linux.microsoft.com> <20210409223801.104657-3-mcroce@linux.microsoft.com> <20210410154824.GZ2531743@casper.infradead.org> <20210414214132.74f721dd@carbon> In-Reply-To: From: Shakeel Butt Date: Mon, 19 Apr 2021 07:57:03 -0700 Message-ID: Subject: Re: [PATCH net-next v3 2/5] mm: add a signature in struct page To: Ilias Apalodimas Cc: Jesper Dangaard Brouer , Matthew Wilcox , Matteo Croce , netdev , Linux MM , Ayush Sawal , Vinay Kumar Yadav , Rohit Maheshwari , "David S. Miller" , Jakub Kicinski , Thomas Petazzoni , Marcin Wojtas , Russell King , Mirko Lindner , Stephen Hemminger , Tariq Toukan , Jesper Dangaard Brouer , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Boris Pismenny , Arnd Bergmann , Andrew Morton , "Peter Zijlstra (Intel)" , Vlastimil Babka , Yu Zhao , Will Deacon , Michel Lespinasse , Fenghua Yu , Roman Gushchin , Hugh Dickins , Peter Xu , Jason Gunthorpe , Guoqing Jiang , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , Aleksandr Nogikh , Jakub Sitnicki , Marco Elver , Willem de Bruijn , Miaohe Lin , Yunsheng Lin , Guillaume Nault , LKML , linux-rdma@vger.kernel.org, bpf , Eric Dumazet , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 18, 2021 at 10:12 PM Ilias Apalodimas wrote: > > On Wed, Apr 14, 2021 at 01:09:47PM -0700, Shakeel Butt wrote: > > On Wed, Apr 14, 2021 at 12:42 PM Jesper Dangaard Brouer > > wrote: > > > > > [...] > > > > > > > > > > Can this page_pool be used for TCP RX zerocopy? If yes then PageType > > > > > can not be used. > > > > > > > > Yes it can, since it's going to be used as your default allocator for > > > > payloads, which might end up on an SKB. > > > > > > I'm not sure we want or should "allow" page_pool be used for TCP RX > > > zerocopy. > > > For several reasons. > > > > > > (1) This implies mapping these pages page to userspace, which AFAIK > > > means using page->mapping and page->index members (right?). > > > > > > > No, only page->_mapcount is used. > > > > I am not sure I like leaving out TCP RX zerocopy. Since we want driver to > adopt the recycling mechanism we should try preserving the current > functionality of the network stack. > > The question is how does it work with the current drivers that already have an > internal page recycling mechanism. > I think the current drivers check page_ref_count(page) to decide to reuse (or not) the already allocated pages. Some examples from the drivers: drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:ixgbe_can_reuse_rx_page() drivers/net/ethernet/intel/igb/igb_main.c:igb_can_reuse_rx_page() drivers/net/ethernet/mellanox/mlx5/core/en_rx.c:mlx5e_rx_cache_get() > > > (2) It feels wrong (security wise) to keep the DMA-mapping (for the > > > device) and also map this page into userspace. > > > > > > > I think this is already the case i.e pages still DMA-mapped and also > > mapped into userspace. > > > > > (3) The page_pool is optimized for refcnt==1 case, and AFAIK TCP-RX > > > zerocopy will bump the refcnt, which means the page_pool will not > > > recycle the page when it see the elevated refcnt (it will instead > > > release its DMA-mapping). > > > > Yes this is right but the userspace might have already consumed and > > unmapped the page before the driver considers to recycle the page. > > Same question here. I'll have a closer look in a few days and make sure we are > not breaking anything wrt zerocopy. > Pages mapped into the userspace have their refcnt elevated, so the page_ref_count() check by the drivers indicates to not reuse such pages. > > > > > > > > (4) I remember vaguely that this code path for (TCP RX zerocopy) uses > > > page->private for tricks. And our patch [3/5] use page->private for > > > storing xdp_mem_info. > > > > > > IMHO when the SKB travel into this TCP RX zerocopy code path, we should > > > call page_pool_release_page() to release its DMA-mapping. > > > > > > > I will let TCP RX zerocopy experts respond to this but from my high > > level code inspection, I didn't see page->private usage. > > Shakeel are you aware of any 'easy' way I can have rx zerocopy running? > I would recommend tools/testing/selftests/net/tcp_mmap.c.