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=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 D1C1EC07E95 for ; Tue, 20 Jul 2021 16:02:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2D536113B for ; Tue, 20 Jul 2021 16:02:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240223AbhGTPTU (ORCPT ); Tue, 20 Jul 2021 11:19:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242543AbhGTPDT (ORCPT ); Tue, 20 Jul 2021 11:03:19 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41221C061767; Tue, 20 Jul 2021 08:43:55 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id ca14so29058323edb.2; Tue, 20 Jul 2021 08:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OpRUncyjpgvq/LeyU+gm5+COgtBzyAUFvnPp6THzYDU=; b=GZXBdSkSAuw74ysSOR4WwhnqZWgCvGZGEoABRjgLw59dhpifC9Ujg5sNWR5AaVtype q5fh9jrjT3cVxaPC+lBeg9+dXQivDfRNNFq12FNQX50baRGyttk/mf0+IuGzoP8Ui23I MFvQTf5Bv8AwglLAU5MZ2aeiEs2NfHD8ntnL1FxiVl6UjtadjjwtH+TSQO2yHC81MtK5 xGuc2zbEfFKCNyh/tkciDg6mZFa/mRrLD56UPWnTh9LMTG0xeWxoxwCK+YQprcimFfez Qhj4r0V2dWQP/9n+d0u6MbXZG9fvT9WRrGaibnvsHV4KmjrGutw6JN3lJTRLYA7bsqWw 4NBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OpRUncyjpgvq/LeyU+gm5+COgtBzyAUFvnPp6THzYDU=; b=J2w8it4ZWaHUSuaENkw1LDsJku6d/0sNHHBzTRSLB/dDVRrrLqepl6BQS9AavRYCVJ q4yU6xBlZzR7kXuQ05LkIJH87YQXtn7ywhSWcgbWUCppk1vCxZy+GfHOUi5dwsZU/Eob kYsF7qMeBk2PGQ/Im/EORhXckVu6BMN8ddgamkdlWzgyWTBP2QIxKdW3vX1drIPGc077 iDi7+0Jyr/M3uj6qOSiihsjwZIQSnYkFvZxS5FM4zxZjZkNxXpeWARcXdcYy2JeoyBTm Q4c7soaNXwuK2N7N3q47nf65/Y3mSCRmWRvg5Zj0IzouQqL9igneZ8wa63MRZpKjaTpk 46kg== X-Gm-Message-State: AOAM533FvEI0S6HXwW07ook8zvvJbSPfU8iAsFSWUec279MjJEb4tiEq prW8/FfFwk+4Wir37KdRxRGlFTEWeXnpwgtliKY= X-Google-Smtp-Source: ABdhPJwU/R0wKgQPuf11WJke70PVawWp/JYYDtCuOk/LsKv1c+viAQUTbOiqJDB2A55BzuV+Dm6ZU5zhv1XFmceanUg= X-Received: by 2002:a50:b412:: with SMTP id b18mr3782169edh.103.1626795833676; Tue, 20 Jul 2021 08:43:53 -0700 (PDT) MIME-Version: 1.0 References: <1626752145-27266-1-git-send-email-linyunsheng@huawei.com> <1626752145-27266-3-git-send-email-linyunsheng@huawei.com> In-Reply-To: <1626752145-27266-3-git-send-email-linyunsheng@huawei.com> From: Alexander Duyck Date: Tue, 20 Jul 2021 08:43:42 -0700 Message-ID: Subject: Re: [PATCH rfc v6 2/4] page_pool: add interface to manipulate frag count in page pool To: Yunsheng Lin Cc: David Miller , Jakub Kicinski , Russell King - ARM Linux , Marcin Wojtas , linuxarm@openeuler.org, yisen.zhuang@huawei.com, Salil Mehta , thomas.petazzoni@bootlin.com, hawk@kernel.org, Ilias Apalodimas , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrew Morton , Peter Zijlstra , Will Deacon , Matthew Wilcox , Vlastimil Babka , fenghua.yu@intel.com, guro@fb.com, Peter Xu , Feng Tang , Jason Gunthorpe , Matteo Croce , Hugh Dickins , Jonathan Lemon , Alexander Lobakin , Willem de Bruijn , wenxu@ucloud.cn, Cong Wang , Kevin Hao , nogikh@google.com, Marco Elver , Yonghong Song , kpsingh@kernel.org, andrii@kernel.org, Martin KaFai Lau , songliubraving@fb.com, Netdev , LKML , bpf Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Mon, Jul 19, 2021 at 8:36 PM Yunsheng Lin wrote: > > For 32 bit systems with 64 bit dma, dma_addr[1] is used to > store the upper 32 bit dma addr, those system should be rare > those days. > > For normal system, the dma_addr[1] in 'struct page' is not > used, so we can reuse dma_addr[1] for storing frag count, > which means how many frags this page might be splited to. > > In order to simplify the page frag support in the page pool, > the PAGE_POOL_DMA_USE_PP_FRAG_COUNT macro is added to indicate > the 32 bit systems with 64 bit dma, and the page frag support > in page pool is disabled for such system. > > The newly added page_pool_set_frag_count() is called to reserve > the maximum frag count before any page frag is passed to the > user. The page_pool_atomic_sub_frag_count_return() is called > when user is done with the page frag. > > Signed-off-by: Yunsheng Lin > --- > include/linux/mm_types.h | 18 +++++++++++++----- > include/net/page_pool.h | 41 ++++++++++++++++++++++++++++++++++------- > net/core/page_pool.c | 4 ++++ > 3 files changed, 51 insertions(+), 12 deletions(-) > > +static inline long page_pool_atomic_sub_frag_count_return(struct page *page, > + long nr) > +{ > + long frag_count = atomic_long_read(&page->pp_frag_count); > + long ret; > + > + if (frag_count == nr) > + return 0; > + > + ret = atomic_long_sub_return(nr, &page->pp_frag_count); > + WARN_ON(ret < 0); > + return ret; > } > So this should just be an atomic_long_sub_return call. You should get rid of the atomic_long_read portion of this as it can cover up reference count errors.