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 4B2C7C07E95 for ; Wed, 7 Jul 2021 19:03:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FB9B61CC2 for ; Wed, 7 Jul 2021 19:03:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbhGGTFz (ORCPT ); Wed, 7 Jul 2021 15:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229956AbhGGTFy (ORCPT ); Wed, 7 Jul 2021 15:05:54 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B16FC06175F for ; Wed, 7 Jul 2021 12:03:14 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id t15so4257755wry.11 for ; Wed, 07 Jul 2021 12:03:14 -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=gEyVsUHVabbCcurt1vqr+nKmr7tjD0Zle1ugJOsxNk8=; b=uQahgciwZnRHDS26dth70zA8+WBNEzYXuwzc5GVRJBSrJhp07jCDpwzSWiUiptb2xj 7cdrZCMoJaRDHDN5jl+6M3lZynZVuiOBQkMz4ZFxna6AQ2fmmt3NoX2BtkPno285C5Qw 02Rsz/SXQFpkQsz5wvsk6J2s8UlXFa3qb6dsebpiSGYpSXMfyI0NScRUnMx3wA5+3Wlc CP9d3VQn8Zie43uo08Vg+N4sjAXt4UjVIUwqUSt0L6kfkiHBqSF9XtEn/ueEmIsCh9Xi 8XFnLAamPMICjrEtTWKoHF0iJRdn1t7BJmVvRBDpJW01CQqYM8C6/WMnpEUZ+9E3RpOY fBYw== 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=gEyVsUHVabbCcurt1vqr+nKmr7tjD0Zle1ugJOsxNk8=; b=qqfkiixx4FDZNATWX+RtFhfdXfbHK9lC0EE1bUrWVT8lNZzWnsPCkS2z/hbaAE5080 Pi+E8ti/mUyVWGybFr5zEPhNwjC0t0Wd9/zvmyvounXZLS9vpsF7o4OkHCUoCPF0Jeug PU5VxSg+Erwgt7i7Jej3oNQpqKgDW/zBiRbUbt8ZdJ82DIP8v593fGhx90nVqiXAINpj KzWN1dpDStfCMgfHWdFVmdzJSoOEIbHVFCTdutoEDZ/JWzl6JgQy7tIgU95NQCqNPok+ xNGiF0it7o9hQtuW6MPT8ZAoAn9eY/TBamj1OhLw/g3TTrMLVPYahK7XK5UcUxkEb3vS U4xw== X-Gm-Message-State: AOAM5336JXHl2aj+fTQeO+Aw4ezUc5UJZWOBlIeyurezJ+1BrgbpxPdA tbZgmio1f3AvCd0KYw2zxY1cQA== X-Google-Smtp-Source: ABdhPJySfCSiQ5cTbbS6d9OTSSfjP3HkNHiqbjLKAzqbl35lVyffDcd81DxCDMSy6xGV26L8R9f8Pg== X-Received: by 2002:a5d:61d1:: with SMTP id q17mr30439214wrv.162.1625684592806; Wed, 07 Jul 2021 12:03:12 -0700 (PDT) Received: from enceladus (ppp-94-66-242-227.home.otenet.gr. [94.66.242.227]) by smtp.gmail.com with ESMTPSA id c12sm23742825wrr.90.2021.07.07.12.03.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jul 2021 12:03:12 -0700 (PDT) Date: Wed, 7 Jul 2021 22:03:08 +0300 From: Ilias Apalodimas To: Alexander Duyck Cc: Yunsheng Lin , David Miller , Jakub Kicinski , linuxarm@openeuler.org, yisen.zhuang@huawei.com, Salil Mehta , thomas.petazzoni@bootlin.com, Marcin Wojtas , Russell King - ARM Linux , hawk@kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrew Morton , Peter Zijlstra , Will Deacon , Matthew Wilcox , Vlastimil Babka , fenghua.yu@intel.com, guro@fb.com, peterx@redhat.com, Feng Tang , Jason Gunthorpe , mcroce@microsoft.com, Hugh Dickins , Jonathan Lemon , Alexander Lobakin , Willem de Bruijn , wenxu@ucloud.cn, cong.wang@bytedance.com, Kevin Hao , nogikh@google.com, Marco Elver , Netdev , LKML , bpf Subject: Re: [PATCH net-next RFC 1/2] page_pool: add page recycling support based on elevated refcnt Message-ID: References: <1625044676-12441-1-git-send-email-linyunsheng@huawei.com> <1625044676-12441-2-git-send-email-linyunsheng@huawei.com> <29403911-bc26-dd86-83b8-da3c1784d087@huawei.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: bpf@vger.kernel.org > > Hi, Alexander > > > > Thanks for detailed reviewing. > > Likewise! I'll have a look on the entire conversation in a few days... > > > > > > So this isn't going to work with the current recycling logic. The > > > expectation there is that we can safely unmap the entire page as soon > > > as the reference count is greater than 1. > > > > Yes, the expectation is changed to we can always recycle the page > > when the last user has dropped the refcnt that has given to it when > > the page is not pfmemalloced. > > > > The above expectation is based on that the last user will always > > call page_pool_put_full_page() in order to do the recycling or do > > the resource cleanup(dma unmaping..etc). > > > > As the skb_free_head() and skb_release_data() have both checked the > > skb->pp_recycle to call the page_pool_put_full_page() if needed, I > > think we are safe for most case, the one case I am not so sure above > > is the rx zero copy, which seems to also bump up the refcnt before > > mapping the page to user space, we might need to ensure rx zero copy > > is not the last user of the page or if it is the last user, make sure > > it calls page_pool_put_full_page() too. > > Yes, but the skb->pp_recycle value is per skb, not per page. So my > concern is that carrying around that value can be problematic as there > are a number of possible cases where the pages might be > unintentionally recycled. All it would take is for a packet to get > cloned a few times and then somebody starts using pskb_expand_head and > you would have multiple cases, possibly simultaneously, of entities > trying to free the page. I just worry it opens us up to a number of > possible races. Maybe I missde something, but I thought the cloned SKBs would never trigger the recycling path, since they are protected by the atomic dataref check in skb_release_data(). What am I missing? [...] Thanks /Ilias