From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E21D4C433ED for ; Wed, 12 May 2021 14:39:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F6E861407 for ; Wed, 12 May 2021 14:39:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbhELOku (ORCPT ); Wed, 12 May 2021 10:40:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230474AbhELOkt (ORCPT ); Wed, 12 May 2021 10:40:49 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95329C061760 for ; Wed, 12 May 2021 07:39:40 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id e7so5349333wrc.11 for ; Wed, 12 May 2021 07:39:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Rfei5MEg9bMEdOxZz3i9gp/4Xf63nRd6sW81/rNWaPA=; b=zkeeqiVHma3XJR/YrkY21U3s61+aPn20UKjLvK2B6kIuhVHYPMLf+YCIAZYOV2cOwA GCgI9Iac036xWy7Ttp1TDN5cXN2sFNjE1DBNA6/3sokb7tEXhvTjVxhfdpOH1/PUHIvs iJqiIzJ7sTSwwNgkCAwMRI+pHWYdLA1e53lomjMrZPFdBg0ENDrUoo0IxnlaUWGALyeJ gDCUwT0IoJ6hnLYeIs3/GdcDVteMS9mmUc0AuillQR8knPOjzmpuZiZ/kldaw1b4hjb5 hZoHP0FJK5G4bZ8L8afAbmJ9y6WG5t5gxL1ak3NvCE5Ts3cPtUzH+nlUKLGJ5SfS+6yZ 3lrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Rfei5MEg9bMEdOxZz3i9gp/4Xf63nRd6sW81/rNWaPA=; b=j1KeURFH/nagy7pPaQCDKNzYZA3uoKofY9zR3K2T3Z+f1+tIRxly+eOrb053LXr175 q19yUnT+h6PQnfEM50IcSUEeB2ArVtffeHFXdvokg2RY4x6i4n89IgVMTA4NYKzm4jD2 xG3L313gJjyHZREuKFxwGUvnGxA0a2WDQOeLfKtBlPma8+GQ8h+ZDHQMf9wDOu0QhnZO 2nV2urAD0jv6h9wxDOtyvkPti5qMLQnb1LnDQIRmAQzOqmzYXj8L8TxfVc7hH6VDw4XM qPV3vMa/zwnAMBggrMH1onzAh7gaLFItLz99USlUQzZZ9xPvK2nYechOwSNm7thYKbZQ uq5g== X-Gm-Message-State: AOAM531r+tJaHZuw/m8nWZ0F/fUiQPzLB93YFnyIIlMnLIEchqWtshgD 6i4wJcLqtWXNzx+AeSKDghM57g== X-Google-Smtp-Source: ABdhPJyVfNFYYeNQ4AG+yp0IlLCFS0VkZrtKFW3E+38v4QOFOQ28Vij61Om2GuDVOc7ydR2EYbR9cA== X-Received: by 2002:adf:d1c6:: with SMTP id b6mr42542657wrd.110.1620830379358; Wed, 12 May 2021 07:39:39 -0700 (PDT) Received: from apalos.home ([94.69.77.156]) by smtp.gmail.com with ESMTPSA id v17sm29739475wrd.89.2021.05.12.07.39.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 07:39:38 -0700 (PDT) Date: Wed, 12 May 2021 17:39:33 +0300 From: Ilias Apalodimas To: Eric Dumazet Cc: Eric Dumazet , 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 , Jonathan Lemon , Alexander Lobakin , Cong Wang , wenxu , Kevin Hao , Jakub Sitnicki , Marco Elver , Willem de Bruijn , Miaohe Lin , Yunsheng Lin , Guillaume Nault , LKML , linux-rdma , bpf , Matthew Wilcox , David Ahern , Lorenzo Bianconi , Saeed Mahameed , Andrew Lunn , Paolo Abeni , Sven Auhagen Subject: Re: [PATCH net-next v4 2/4] page_pool: Allow drivers to hint on SKB recycling Message-ID: References: <20210511133118.15012-1-mcroce@linux.microsoft.com> <20210511133118.15012-3-mcroce@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Hi Eric, [...] > > > > + if (skb->pp_recycle && page_pool_return_skb_page(head)) > > > > > > This probably should be attempted only in the (skb->head_frag) case ? > > > > I think the extra check makes sense. > > What do you mean here ? > I thought you wanted an extra check in the if statement above. So move the block under the existing if. Something like if (skb->head_frag) { #ifdef (CONFIG_PAGE_POOL) if (skb->pp_recycle && page_pool_return_skb_page(head)) return; #endif skb_free_frag(head); } else { ..... > > > > > > > > Also this patch misses pskb_expand_head() > > > > I am not sure I am following. Misses what? pskb_expand_head() will either > > call skb_release_data() or skb_free_head(), which would either recycle or > > unmap the buffer for us (depending on the page refcnt) > > pskb_expand_head() allocates a new skb->head, from slab. > > We should clear skb->pp_recycle for consistency of the skb->head_frag > clearing we perform there. Ah right, good catch. I was mostly worried we are not freeing/unmapping buffers and I completely missed that. I think nothing bad will happen even if we don't, since the signature will eventually protect us, but it's definitely the right thing to do. > > But then, I now realize you use skb->pp_recycle bit for both skb->head > and fragments, > and rely on this PP_SIGNATURE thing (I note that patch 1 changelog > does not describe why a random page will _not_ have this signature by > bad luck) Correct. I've tried to explain in the previous posting as well, but that's the big difference compared to the initial RFC we sent a few years ago (the ability to recycle frags as well). > > Please document/describe which struct page fields are aliased with > page->signature ? > Sure, any preference on this? Right above page_pool_return_skb_page() ? Keep in mind the current [1/4] patch is wrong, since it will overlap pp_signature with mapping. So we'll have interesting results if a page gets mapped to userspace :). What Matthew proposed makes sense, we can add something along the lines of: + unsigned long pp_magic; + struct page_pool *pp; + unsigned long _pp_mapping_pad; + unsigned long dma_addr[2]; in struct page. In this case page->mapping aliases to pa->_pp_mapping_pad The first word (that we'll now be using) is used for a pointer or a compound_head. So as long as pp_magic doesn't resemble a pointer and has bits 0/1 set to 0 we should be safe. Thanks! /Ilias