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 2D381C433B4 for ; Wed, 12 May 2021 14:39:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B16061370 for ; Wed, 12 May 2021 14:39:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B16061370 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5A346B0036; Wed, 12 May 2021 10:39:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D30A76B006E; Wed, 12 May 2021 10:39:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B838A6B0070; Wed, 12 May 2021 10:39:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0105.hostedemail.com [216.40.44.105]) by kanga.kvack.org (Postfix) with ESMTP id 9BCE76B0036 for ; Wed, 12 May 2021 10:39:41 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D4ECA98BA for ; Wed, 12 May 2021 14:39:40 +0000 (UTC) X-FDA: 78132837720.29.4CDE328 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf09.hostedemail.com (Postfix) with ESMTP id F27C66000104 for ; Wed, 12 May 2021 14:39:28 +0000 (UTC) Received: by mail-wr1-f47.google.com with SMTP id x5so23877091wrv.13 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=q+ah1EYN1vD1bvbt1A19pNvb2TgNhjzYIQrkLi/nAR4ymBh4oCF8uwyeR92szphIil FvY3XvIgL3YJxK1VdK7FOsdPfWWhe97y9oABRCO7Wk4+3Z+pxJNxIwlue1ckWrSg31o1 qBa5Hp6Llm+SMmjZiCZarX/kdUECxTiMJychHVVUim3ueR5IRncT+7CB6CNccteBF8/3 RV+9nl4Nr8s3/7kcgobs6+HEwwyq0dd6vvRHty0k5e2RTWcg6OFkNJmUBwwnAJj3JKo4 D9YOKdKTvW3w2wG1vzcdg3Sylu2vuFETWkytDn9USfMXrGfcmIVXJEv+VfV09O2z9N8O 2b2Q== X-Gm-Message-State: AOAM530xOPuPNcUvWnT8jlOKdGtSwZxL2SpxQO0JHbykhgg1qgncHtnz RACV2Nc8Jw5NmKzt9N8MUqbq1w== 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: X-Rspamd-Queue-Id: F27C66000104 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=zkeeqiVH; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf09.hostedemail.com: domain of ilias.apalodimas@linaro.org designates 209.85.221.47 as permitted sender) smtp.mailfrom=ilias.apalodimas@linaro.org X-Rspamd-Server: rspam03 X-Stat-Signature: odn1j5empf3kpjqj6aogxh6ga98en5zq Received-SPF: none (linaro.org>: No applicable sender policy available) receiver=imf09; identity=mailfrom; envelope-from=""; helo=mail-wr1-f47.google.com; client-ip=209.85.221.47 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1620830368-430667 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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