Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp4501349pxb; Tue, 25 Jan 2022 11:44:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJl/tz+W/FhJegfP9G/iUqxztpE7iB/6oaqa0AwD8SOT3yM2I0cbL4c6akbslPmv144/io X-Received: by 2002:a17:907:6e94:: with SMTP id sh20mr13472501ejc.378.1643139881648; Tue, 25 Jan 2022 11:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643139881; cv=none; d=google.com; s=arc-20160816; b=WbK03mkc61+P0mQKL1rpstPDJhWecnpG7kCFHqIREwzflTAjwdzrQU4eu8IutAAgxG ZeIe2q0ecpK6cBTop7EFCmY5dEHWlEg1D8se0aibDExnEfRTx/+LmYCVcaw/zG0PeIOV QWRw5ONAcjYa4tb4Mf56csbWwSVh6/dVH3yDdSrR/aOBjFvuJEoeEOmjD1+6vd7eimLw wn3zdvk13VArQqsxxjhBP4Bd6+j8s6y1+IaysELQd37PIMezYhPOl2GNxsDD2iU3399R P6m15grlpfCZaj6ifv1HEdVqVyI88nQM0z7zMvRtvwxJpszpyaICJyhkqUReBN4xdwJf 1v3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=dmTRZQPuRO8f++oWDROLMKejn3nl3Z1SGKdLjvl7gws=; b=qOsil1BZaIVSEJIopVtW8fwMndTxEKU+nsBiCE0Qz71Nrpkueh9YwY7RReR+7wmUEA EiQ6A4ZREGgTmUqKJus+/fO7aVnu6N7QS5RyiAkkbOBBp9VwBf4ScJ5GIBE4n1CSWbSe PO15BHAGHS5P6kBIRURSiJQ3yTPIdaT6ebbYLL+jJoCwNoQTf1oWmE6ZeIZrqRG0SCEp MzHIHv5xYfmTxe2yYeWMLVagGqK33vMfDy2WWYiR7GoZEJYbjBAsOjzp8MLaJpFMWO4d gy+Ih7/HuOlRzrT2iojgTuxdtEzUF+VDN64UsR1r1bKAPdOFqrmDRadw+9vpV7O2bXsy 9Xlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BEWDGMMo; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si12563415edc.214.2022.01.25.11.44.16; Tue, 25 Jan 2022 11:44:41 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=BEWDGMMo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1577505AbiAYNsZ (ORCPT + 99 others); Tue, 25 Jan 2022 08:48:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1577601AbiAYNpV (ORCPT ); Tue, 25 Jan 2022 08:45:21 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84F4CC06175E; Tue, 25 Jan 2022 05:45:18 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id t7so8851641ljc.10; Tue, 25 Jan 2022 05:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=dmTRZQPuRO8f++oWDROLMKejn3nl3Z1SGKdLjvl7gws=; b=BEWDGMMoMtROBzr8EOGbxyLugIK9SlaF4xB8o2GIIWKYTgUO5ifb3+PzatsOVDsiW4 jts2Q8yi8DTDCnKzLfUtm21nKsYYZdvvN3H4STmJ1T4fnB+dwlbroyvI/9TByhB+nkQ6 yl8p5oggELsaBPWLBh8v6lK8+UOaV4NzfJrtRKNBHQDkPEUc2HdMYfQfShLepvFL/dq+ +5suF/LKHu0OGxHZmviEQrtLScqqL50GrVBK2uNVTZSF7uvxGuFKO6O+2q6eY7MPT63G Eo1b7WmAiqUVJS0moI3cK+yddSe4bzmcNNS35iQ+XLRqKcsbBfFlkFxM8ziurOhHER+e /JxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=dmTRZQPuRO8f++oWDROLMKejn3nl3Z1SGKdLjvl7gws=; b=v3qdwxIz68a2h0CXHYuSzCwKW0ekfIEETxyoPOyzHlfpUpTDYc2wYcCnhGDe651qQ7 s/ZbknnkvQskA5FNuJUsD2TqHUbj/uRRk5jJH8/k1kAvgXXTo2u8OFdN8RQXRy7z6QhG tLy4Wwra02VwsuABVj1/5Jqc99Tcp9gfEaFoVUB+Mwd24Ylmz9uRp9xGbHVp/KsG2jyZ uJK03SvTV+uNA/rRMMNOk/4Aw0jNeslJANVHSRJKqTTLc7UqGeyF7xGRyZ8OdYfVgqqP ORod7Ic5VgjC0V1TaJM3EWl6BnzSvS9Mo2JN98fMLUgPfZR3uBHKizaIwoSh4NSFOMl0 j8YQ== X-Gm-Message-State: AOAM531SRvLm9Ojncvo+DmU9jXMsV0946i466y6xjRpsGElx7Y4KgJns qMrxB9EI3XNT8CbtydjVvYFRwcm21fWt2w== X-Received: by 2002:a2e:9cd4:: with SMTP id g20mr10157727ljj.116.1643118316756; Tue, 25 Jan 2022 05:45:16 -0800 (PST) Received: from [192.168.8.103] (m91-129-103-86.cust.tele2.ee. [91.129.103.86]) by smtp.gmail.com with ESMTPSA id q12sm1224461ljh.16.2022.01.25.05.45.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Jan 2022 05:45:16 -0800 (PST) Message-ID: <564ae11c-24fb-a9ad-f8f4-c9d80b7307b3@gmail.com> Date: Tue, 25 Jan 2022 15:45:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [PATCH] net: ena: Do not waste napi skb cache Content-Language: en-US To: Shay Agroskin Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, netdev@vger.kernel.org, Arthur Kiyanovski , David Arinzon , Noam Dagan , Saeed Bishara , "David S . Miller" , Jakub Kicinski , Daniel Borkmann , Sameeh Jubran , Wei Yongjun , Lorenzo Bianconi , linux-kernel@vger.kernel.org References: <20220123115623.94843-1-42.hyeyoo@gmail.com> <5cca8bdd-bed0-f26a-6c96-d18947d3a50b@gmail.com> From: Julian Wiedmann In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24.01.22 22:50, Shay Agroskin wrote: > > Julian Wiedmann writes: > >> On 24.01.22 10:57, Julian Wiedmann wrote: >>> On 23.01.22 13:56, Hyeonggon Yoo wrote: >>>> By profiling, discovered that ena device driver allocates skb by >>>> build_skb() and frees by napi_skb_cache_put(). Because the driver >>>> does not use napi skb cache in allocation path, napi skb cache is >>>> periodically filled and flushed. This is waste of napi skb cache. >>>> >>>> As ena_alloc_skb() is called only in napi, Use napi_build_skb() >>>> instead of build_skb() to when allocating skb. >>>> >>>> This patch was tested on aws a1.metal instance. >>>> >>>> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com> >>>> --- >>>>  drivers/net/ethernet/amazon/ena/ena_netdev.c | 2 +- >>>>  1 file changed, 1 insertion(+), 1 deletion(-) >>>> >>>> diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c >>>> index c72f0c7ff4aa..2c67fb1703c5 100644 >>>> --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c >>>> +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c >>>> @@ -1407,7 +1407,7 @@ static struct sk_buff *ena_alloc_skb(struct ena_ring *rx_ring, void *first_frag) >>>>          skb = netdev_alloc_skb_ip_align(rx_ring->netdev, >>>>                          rx_ring->rx_copybreak); >>> >>> To keep things consistent, this should then also be napi_alloc_skb(). >>> >> >> And on closer look, this copybreak path also looks buggy. If rx_copybreak >> gets reduced _while_ receiving a frame, the allocated skb can end up too >> small to take all the data. >> >> @ ena maintainers: can you please fix this? >> > > Updating the copybreak value is done through ena_ethtool.c (ena_set_tunable()) which updates `adapter->rx_copybreak`. > The adapter->rx_copybreak value is "propagated back" to the ring local attributes (rx_ring->rx_copybreak) only after an interface toggle which stops the napi routine first. > That's unfortunate. ena_get_tunable() returns the updated adapter->rx_copybreak, how would a user know that their update isn't actually live yet? > Unless I'm missing something here I don't think the bug you're describing exists. > ack, thanks for double-checking! > I agree that the netdev_alloc_skb_ip_align() can become napi_alloc_skb(). Hyeonggon Yoo, can you please apply this change as well to this patch? > > Thanks, > Shay > > >>>>      else >>>> -        skb = build_skb(first_frag, ENA_PAGE_SIZE); >>>> +        skb = napi_build_skb(first_frag, ENA_PAGE_SIZE); >>>>   >>>>      if (unlikely(!skb)) { >>>>          ena_increase_stat(&rx_ring->rx_stats.skb_alloc_fail,  1, >>>