Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4534815pxj; Wed, 12 May 2021 07:41:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzPtqxL/74+xWd5fuTFMSwYKFXKQkIQDbr/YZ9f7UhEoGt6v0b33+AQUJjh6vsuK9/WKNXg X-Received: by 2002:a05:6402:26d6:: with SMTP id x22mr18269431edd.88.1620830516167; Wed, 12 May 2021 07:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620830516; cv=none; d=google.com; s=arc-20160816; b=s7Gpx4B80eEX6ZemF0Aa974vs46L0UiW4ZCPDmmfoEXAijyTQs9QXsIouy0MNskwbg 8TkefDhm4ulqTPGirZwIxvhJ+Qyjg6cDlXP0WXsYP31Ye2aZ8nJpdVMOvb0NoP7Y/GDs Inm3FcvumRbNLHjFFutAaKpmoIC8ywghpJFnTx+SlZiGmdmky3XuXnqryEsn2TG7hPzB OZis1ub6PdDbKeKMt7mDyo0Sc4Sv1spZPOWcaY775ffs5cnac+UrtC3FNk6yja7lMSqF ZJvdTRyvZwpZvHtPXb1xwMRQYwvHZiO23CS0w/2Oh765PMGBd8sLaWqHJgz3rjY+gYLu EYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Rfei5MEg9bMEdOxZz3i9gp/4Xf63nRd6sW81/rNWaPA=; b=QgEKMZIrwZ0xOhr877pFe5/p8w1vRogTGybACWwAJxYpNGY6OoAgUaIwxp9wVpCST/ +zWBK6CT0HORH31yXaHk7J4EwX2dbKfg1hFx1ZWz8dRqkYimTYtvkR0C57DVWSeztuj4 VtWSF+m07enBLgkQoJP6IKeYVZZNi3xYO4rLRalwlXETQIwvAk98cQ14TaYpt6ZXBbXq 85T9I1sueOM7O3bh87wcNx4rno6V3jtzXBPEhyohADZYtnKQbTvpl9zytsRYJ98/iIG+ 7xJbVbqzi2JcfDAt0CpQKqMYMocxLSR5WB6U1gE+AkEDMH/OJ0EBCnyqzN24zjtVXKA2 8hZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zkeeqiVH; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de20si19540697edb.211.2021.05.12.07.41.31; Wed, 12 May 2021 07:41:56 -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=@linaro.org header.s=google header.b=zkeeqiVH; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbhELOkv (ORCPT + 99 others); Wed, 12 May 2021 10:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbhELOku (ORCPT ); Wed, 12 May 2021 10:40:50 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952BBC06175F for ; Wed, 12 May 2021 07:39:40 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id s8so23889517wrw.10 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=scSPEAFnz60E6ZSUg0W45JTBu16EfcM0ZUD8CKRIMRPPjH7W2C2btJOfjRn27iInbt F8aU2MoG3EyhGQ+JR/tNY/3glpbm75w8ce5WXZiqTGP7SBcWgpk+bKlFDPEzZ90GX6re Uf7xTkUnyyiOFafhx9LpYQvQ4NSap9JN42Y8k3lQK4/C8hR5ZRi/YLDpYmSiJ/QvMI1T vh91oBi/4O5A4F+9UdjcbDJXVvTpHblTsAY831X1sVQon8HarHoQNGtdv7ophEgh96UA cKlILubObfemLA7Wkr+OU1xUijfanV9z80IxM3A1/D1gFZK8kfsNUx3h3J4m0IZu88jK rE7Q== X-Gm-Message-State: AOAM530mONKXcYGSJLwjznWuGU2NyDgBIy+1emWyQr5qxUDRuoHVVet+ XJ7O87vXNVln7cP0/ovD0Puyhg== 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-kernel@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