Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3139919pxb; Tue, 20 Apr 2021 01:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN4XnTIF+FCd9SM3bxJdz81HgknnoqHJmaKDgqg7sQqdVSQj0+InaLBXVJfh00MzPHKDHq X-Received: by 2002:a17:90a:f402:: with SMTP id ch2mr3652948pjb.171.1618906315298; Tue, 20 Apr 2021 01:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618906315; cv=none; d=google.com; s=arc-20160816; b=sBX0TZ7Gk527TFhFdvZQoRWyQYOq01xBy3wRmLhG3zxXoDAM2F1J7cMRWxccc2vK5U rt7JPANsdKvPyuS1jH9mgrFhI5adn6QpvlV5fIkJdAZEPDKew7d19qGeHorVUveffyQX DIRwjYhWyjToDJiOa+yOc2q+puZ8GGMsDnpPemvfJ90s/NelA/u3vLJsg//fNzM2gJFM iwdbiXR5lO0PUHuBBp9W/5seCMfbhqHR5ZwQeATrKwG3jNL1mxNEELbezosLh+VQvs5D G20XJQ88a7co7vNJp4G6PZI5hKichT0F1ryiTFH4+7Ly0njI9nj1njdTla0KRqS19IrB QWBg== 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=FG5E8uWGSrCvajWCjQUTriiKHPgt6q+O5wn0TlE95pQ=; b=GRu4HyfRpHSyWxgFD1qJuuMUUIyXhEe10RVZkBRpSWKnFq0WNL4GC3ibYGRrfm0YiQ Ql2vnbsja3isRuwsRgatKQJdyzcHNG3P5/lBElKgAhR/A5uQUJ5yhYovh2CNlGB/DWDr hkaNAMIxQGXIaRHk3IpsSREGETs0JcQQn28Pf90MAov5VKaRFrVVb6vPhHpNAMEBvQRS gNdJfA8svDFGKo42D8yZ/w8xwagXWuBs4L7+5O6cCa47+PgifwGTydlhrQ/15lVnHmGQ LbzYjnrc7RbpdQTNNsp/vumqBJFIpO5/WJr2/w6EpeE1aeGXo+5285JteaAuUE3O4jdJ jwzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zCCqheyR; 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 i19si423237pfq.102.2021.04.20.01.11.42; Tue, 20 Apr 2021 01:11:55 -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=zCCqheyR; 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 S229997AbhDTILI (ORCPT + 99 others); Tue, 20 Apr 2021 04:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbhDTILG (ORCPT ); Tue, 20 Apr 2021 04:11:06 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACFCC061763 for ; Tue, 20 Apr 2021 01:10:33 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id l4so56863287ejc.10 for ; Tue, 20 Apr 2021 01:10:33 -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=FG5E8uWGSrCvajWCjQUTriiKHPgt6q+O5wn0TlE95pQ=; b=zCCqheyR986/BDJiX2v51ephpReLZP0aCw2199pReb60w50j/aQo+xHHfXXUBXXydW 1iPjmITiaWa8banzSpUECuDdbVOiI4NKC9wnSLuBbE/YC5846UJY1XwLTipBgGV/fZlh aeu7T47FtiIPMNezvjA8OW4GOsvVFAnqOuyar1inVAZrF4tNsRDporJAlldNike4y7TC ly3OBtz7A1LspIgPb3Egr4a3gGJ9ZTu+aBMUhkcr20HtAmV66EIp8V9kIURR3gtLEGMV /7R5yQCiCUDpNn62ZghQyGjtFrsbOBqiirdidAeJx9UGX/bJtpyuOWB6GZnHLQfoMoL+ y10Q== 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=FG5E8uWGSrCvajWCjQUTriiKHPgt6q+O5wn0TlE95pQ=; b=V5tANq78jxSQyrUmPbD8jBEtG6xTlVSDqQjtyspWp+u9SbqOEFkDAoy2/WnpleACdH qeTf0hz+y1UV/KhkQa0f0fa7Md55s4vgtFRK5teVxKRgwpSjHQ4ZXE3PQsBRDFZdCjt/ 43AWEE9OrGtlW3HUmPJmDRrknv6OEpNl4+i89CsSr9dDRLvELK9drfl4Tn3Lj1rB5XWI za5GImSnGEIy2KbPP05/MEti1DJRshbFvDtrrZulmWqIFaLH9/78ltl8pM5E6du4MX4o aUOwLqJo79sfG81K7ywKIXvfL/ffcTqE+v4MFB5c2H0sxk+Y3Dsl/tAqI9kRSHA8GBym 9jcg== X-Gm-Message-State: AOAM530acokoyqy+TawhuCXDUnAdgkg/r1YmgniSjEY6A0XhWOLLDPob voQ+yoCAijpSCHYvAEXfrCFZBg== X-Received: by 2002:a17:906:c34d:: with SMTP id ci13mr25303488ejb.430.1618906231985; Tue, 20 Apr 2021 01:10:31 -0700 (PDT) Received: from apalos.home (ppp-94-65-92-88.home.otenet.gr. [94.65.92.88]) by smtp.gmail.com with ESMTPSA id yr16sm11854378ejb.63.2021.04.20.01.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Apr 2021 01:10:31 -0700 (PDT) Date: Tue, 20 Apr 2021 11:10:26 +0300 From: Ilias Apalodimas To: Matthew Wilcox Cc: Jesper Dangaard Brouer , Shakeel Butt , 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 Subject: Re: [PATCH net-next v3 2/5] mm: add a signature in struct page Message-ID: References: <20210409223801.104657-1-mcroce@linux.microsoft.com> <20210409223801.104657-3-mcroce@linux.microsoft.com> <20210410154824.GZ2531743@casper.infradead.org> <20210414214132.74f721dd@carbon> <20210419132204.1e07d5b9@carbon> <20210419130148.GA2531743@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210419130148.GA2531743@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Matthew, [...] > > And the contents of this page already came from that device ... if it > wanted to write bad data, it could already have done so. > > > > > (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. > > > > That is a good point. So, there is a race window where it is possible > > to gain recycling. > > > > It seems my page_pool co-maintainer Ilias is interested in taking up the > > challenge to get this working with TCP RX zerocopy. So, lets see how > > this is doable. > > You could also check page_ref_count() - page_mapcount() instead of > just checking page_ref_count(). Assuming mapping/unmapping can't > race with recycling? > That's not a bad idea. As I explained on my last reply to Shakeel, I don't think the current patch will blow up anywhere. If the page is unmapped prior to kfree_skb() it will be recycled. If it's done in a reverse order, we'll just free the page entirely and will have to re-allocate it. The only thing I need to test is potential races (assuming those can even happen?). Trying to recycle the page outside of kfree_skb() means we'd have to 'steal' the page, during put_page() (or some function that's outside the networking scope). I think this is going to have a measurable performance penalty though not in networking, but in general. In any case, that should be orthogonal to the current patchset. So unless someone feels strongly about it, I'd prefer keeping the current code and trying to enable recycling in the skb zc case, when we have enough users of the API. Thanks /Ilias