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 autolearn=ham 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 0C812C433E0 for ; Thu, 4 Feb 2021 16:20:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C60DE64E4F for ; Thu, 4 Feb 2021 16:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237577AbhBDQUc (ORCPT ); Thu, 4 Feb 2021 11:20:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237866AbhBDQUL (ORCPT ); Thu, 4 Feb 2021 11:20:11 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6C43C0613D6 for ; Thu, 4 Feb 2021 08:19:26 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id e133so3768073iof.8 for ; Thu, 04 Feb 2021 08:19:26 -0800 (PST) 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=W4SEIsw/cse6byIrFcWwK7Gy1uRGvmSLkKIfeJJmkDg=; b=J7/dFqBtGhzidCblWVkOA0xYg+h9662Tb1/bGkOQ99JWlqha+wrRYRYXH+cteNiC62 nmX5zyvQNdjQ0ku9FGrYXhWbHB+xledUQA1g9OtCJ0SCaW5R+VPjSQeR4MKlQf1NYx6l JCjfJwHsqye3DijQyGOLIHh18zbZR6tfDqs6d+20SGgHPsZ0ZTHNmnn/4vSv+Et6kDuQ 6BdoRpv6MuFYngHFYXaEPyrJLVRejdLuD/uuMl3l08yHcdwTFG6o5ZcR9S7Mi8VtZshZ no6erjWwIF2g6MmcB9EPDLVHCtk+5oZ0l5b7X+sbUFWezgGXexYFB35GUW+GAHD+F8MD ifzg== 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=W4SEIsw/cse6byIrFcWwK7Gy1uRGvmSLkKIfeJJmkDg=; b=Gy6jPtBozLbS4psF+/HLfMPjnwPNVZhqDW1yb5JPe/JD+jcdHad1k/ksxArPB3R8qJ qbrTWvLkz5fvPCCxqmYB8t95Evzml1xmz5VuQVa+DdA+j92gqmUnmzUe7bt/jnTtWe5w QBsfbE0QQCxJDxXnMQzDcmiW3L88FCVpwHwVpUD3oKNk1A+FYOThHymU/JcNYAIDartD Pylyl+qHQ2NR1a7oEU09PmI2JXMJxpLHPCxm3ceHTAQlOIlFeBGFaFkHxVNyFhNC+/mB XG3rGDv98JSEpjfFJ1an7cxO0kinilac3pWJZIku4xRQPd3+0gC3B4MoAIrQg0WQTAsG 9EGQ== X-Gm-Message-State: AOAM5317gzJwbkHY5UIuHvnJetbjbsxj11HQZJpKasannYgAveXZzw4D LA5QTcPyWNXewPlBL+sYgf8Zw9ljqzTdHtieEoU= X-Google-Smtp-Source: ABdhPJwvvKlIYoxzYgbeDd543I8dzUkX4GaUX9gsIOicvu/lH5UNx1ggvkBI7a5rSfDhNbX3rwR8rL07O56GJgbUwu8= X-Received: by 2002:a05:6638:388e:: with SMTP id b14mr308289jav.96.1612455566188; Thu, 04 Feb 2021 08:19:26 -0800 (PST) MIME-Version: 1.0 References: <20210204105638.1584-1-haokexin@gmail.com> <20210204105638.1584-3-haokexin@gmail.com> In-Reply-To: <20210204105638.1584-3-haokexin@gmail.com> From: Alexander Duyck Date: Thu, 4 Feb 2021 08:19:15 -0800 Message-ID: Subject: Re: [PATCH net-next v3 2/4] net: Introduce {netdev,napi}_alloc_frag_align() To: Kevin Hao Cc: "David S . Miller" , Jakub Kicinski , Netdev , Eric Dumazet Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Feb 4, 2021 at 3:06 AM Kevin Hao wrote: > > In the current implementation of {netdev,napi}_alloc_frag(), it doesn't > have any align guarantee for the returned buffer address, But for some > hardwares they do require the DMA buffer to be aligned correctly, > so we would have to use some workarounds like below if the buffers > allocated by the {netdev,napi}_alloc_frag() are used by these hardwares > for DMA. > buf = napi_alloc_frag(really_needed_size + align); > buf = PTR_ALIGN(buf, align); > > These codes seems ugly and would waste a lot of memories if the buffers > are used in a network driver for the TX/RX. We have added the align > support for the page_frag functions, so add the corresponding > {netdev,napi}_frag functions. > > Signed-off-by: Kevin Hao > --- > v3: Use align mask and refactor the {netdev,napi}_alloc_frag_align() as > suggested by Alexander. > > include/linux/skbuff.h | 36 ++++++++++++++++++++++++++++++++++-- > net/core/skbuff.c | 26 ++++++++++---------------- > 2 files changed, 44 insertions(+), 18 deletions(-) Reviewed-by: Alexander Duyck