Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1110572rwd; Thu, 18 May 2023 08:06:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5R9fvR6J+ga+ljO6mN9WrsZRErSGn2RIohkf/+rnqGIu+mrT+Sovysw+8Ttw19BiFn9sM0 X-Received: by 2002:a17:902:e541:b0:1ac:7e95:74bf with SMTP id n1-20020a170902e54100b001ac7e9574bfmr2580773plf.6.1684422368956; Thu, 18 May 2023 08:06:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684422368; cv=none; d=google.com; s=arc-20160816; b=dHGkRAAnsq82JehK0dHIsZe0SE6Z42ZyB7VeE20joUOac0dBOhUUOOt2Z/aBfrWVlG kLcRYvRM0HuOEfIyWyEygrGXVp0OARWYHDiGDux0waLpnuVoECVwB4QqL8HRwv9GqunN O0QEvAgcLZjVs4agLqwNemX9W1BnNZUvP1UZySYlkRDTGg7XHXb7lvoPB3DR7Q8Bgh0K PknOSqp0N/fx8o9RQKVsSYlSB1xib31KUxzPS/GZDCCTytaeR35ecBmKRAkh25iXsIyC 9tovPAVsjcLliSCppDxPfBdMKCC4nW05xjQcLpwMgTwgsmqKKNS4mg9YJpnJeCyd5wDR I8Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=rCamQJq35FwT+pvHgaFw0d7nnveOoC7b2Eg+Acwxj1k=; b=cuwcNRtdEFfcKkAm5m9xStCmix+vMB9gpcm/3QZYnwimaTPZMYsSLeUFmwVFRFgmV+ pQlZmg8mIq9nx3LdPq1zAaKWkdhB5sbr58VrGOBmM61nwtIIZ+TMlYea9ubE7JtqtU+g 8JNzKazS85GDeQtnirOgQyWBBcusTQs0C83fNo/xmsyjWRbezRq0x9yz6spyTttu6myH ogB+8WbBaaJZzX2uNUquTjQJLeTDmDCckOO07YAozKyp+M34srRNF93zKKYdu2cuThRQ YJYm4YWeLcXgA6J9XiQDo/bGMbPdRwyyZ9/JeTxX1EgH4YMyLmfXOlKlIjjvygygoZ06 x1DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dDDWYbaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a170902e84900b001aadb1147e4si1561497plg.456.2023.05.18.08.05.49; Thu, 18 May 2023 08:06:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dDDWYbaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231405AbjERO6u (ORCPT + 99 others); Thu, 18 May 2023 10:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231361AbjERO6X (ORCPT ); Thu, 18 May 2023 10:58:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77BFA1BD0 for ; Thu, 18 May 2023 07:57:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D180264FF2 for ; Thu, 18 May 2023 14:56:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7CCC433EF; Thu, 18 May 2023 14:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684421805; bh=falOcbL4ZZzvoQbqldjfq18URK37IBRaR29UBqVOjsk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dDDWYbaKviNkf6e5ZNGk+G/Cbzx/2OiZ2ynEHeldkHvdLZMetuHksyWOJmATx2ysB uvQfUuFerlLwgNbz+KAD2e/oPzHYgHx/iL58dhb/Hue8WKHacs/NwB6gq7wWqbdT4K BOyBNHIwj7aYjsMnuoljesAIG4CVio4ZyJZe3LnOYNaegS8PtbAfnljjSGKhVXT41l BPk87oVE5+9u4zM5U2od2Rkn6oG5S8l+zQzPCDjv75/nB5ZE+wf7vWYlo1Cc47Kz2Q fUcNN7RSTXcwXNUCajZgIOkEs0RZ34+oLCdsWRz4Y1PDw3emRweMsSqkLL0MJeyDRa WVHqU0xDpaZeQ== Date: Thu, 18 May 2023 07:56:43 -0700 From: Jakub Kicinski To: Alexander Lobakin Cc: Jesper Dangaard Brouer , Larysa Zaremba , , Ilias Apalodimas , , "Christoph Hellwig" , Eric Dumazet , Michal Kubiak , , Paolo Abeni , "David S. Miller" , Magnus Karlsson Subject: Re: [Intel-wired-lan] [PATCH net-next 07/11] net: page_pool: add DMA-sync-for-CPU inline helpers Message-ID: <20230518075643.3a242837@kernel.org> In-Reply-To: <9feef136-7ff3-91a4-4198-237b07a91c0c@intel.com> References: <20230516161841.37138-1-aleksander.lobakin@intel.com> <20230516161841.37138-8-aleksander.lobakin@intel.com> <20230517211211.1d1bbd0b@kernel.org> <9feef136-7ff3-91a4-4198-237b07a91c0c@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 May 2023 15:45:33 +0200 Alexander Lobakin wrote: > >> diff --git a/include/net/page_pool.h b/include/net/page_pool.h > >> index 8435013de06e..f740c50b661f 100644 > >> --- a/include/net/page_pool.h > >> +++ b/include/net/page_pool.h > >> @@ -32,7 +32,7 @@ > >> > >> #include /* Needed by ptr_ring */ > >> #include > >> -#include > >> +#include > > > > highly nit picky - but isn't dma-mapping.h pretty heavy? > > And we include page_pool.h in skbuff.h. Not that it matters > > today, but maybe one day we'll succeed putting skbuff.h > > on a diet -- so perhaps it's better to put "inline helpers > > with non-trivial dependencies" into a new header? > > Maybe we could rather stop including page_pool.h into skbuff.h? It's > used there only for 1 external, which could be declared directly in > skbuff.h. When Matteo was developing PP recycling, he was storing > mem_info in skb as well, but then it was optimized and we don't do that > anymore. > It annoys sometimes to see the whole kernel rebuilt each time I edit > pag_pool.h :D In fact, only PP-enabled drivers and core code need it. Or maybe we can do both? I think that separating types, defines and simple wrappers from helpers should be considered good code hygiene. > >> #define PP_FLAG_DMA_MAP BIT(0) /* Should page_pool do the DMA > >> * map/unmap > > > >> +/** > >> + * page_pool_dma_sync_for_cpu - sync Rx page for CPU after it's written by HW > >> + * @pool: page_pool which this page belongs to > >> + * @page: page to sync > >> + * @dma_sync_size: size of the data written to the page > >> + * > >> + * Can be used as a shorthand to sync Rx pages before accessing them in the > >> + * driver. Caller must ensure the pool was created with %PP_FLAG_DMA_MAP. > >> + */ > >> +static inline void page_pool_dma_sync_for_cpu(const struct page_pool *pool, > >> + const struct page *page, > >> + u32 dma_sync_size) > >> +{ > >> + dma_sync_single_range_for_cpu(pool->p.dev, > >> + page_pool_get_dma_addr(page), > >> + pool->p.offset, dma_sync_size, > >> + page_pool_get_dma_dir(pool)); > > > > Likely a dumb question but why does this exist? > > Is there a case where the "maybe" version is not safe? > > If the driver doesn't set DMA_SYNC_DEV flag, then the "maybe" version > will never do anything. But we may want to use these helpers in such > drivers too? Oh, I see, the polarity of the flag is awkward. Hm. Maybe just rename things, drop the "maybe_" and prefix the non-checking version with __ ? We expect drivers to call the version which check the flag mostly (AFAIU), so it should have the most obvious name. Plus perhaps a sentence in the kdoc explaining why __ exists would be good, if it wasn't obvious to me it may not be obvious to others..