Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1351696lqe; Mon, 8 Apr 2024 06:43:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVUjwXShuwwr/L9tGUkY1AeHr3VBl046OH/E8Ss8DcDvmmflepXP19K7TMHGP+FuCwv17b/oEt7qAaEFyRl+d74desTjHw7QLR79VFmzw== X-Google-Smtp-Source: AGHT+IFqd6F/co9OB23ASNfcpDDCvbf7XB/EVTWW3miarDmRr6TGGi3eDTacHvMdnNiqcNzbtTrh X-Received: by 2002:a17:90a:b00b:b0:2a2:c538:4d5b with SMTP id x11-20020a17090ab00b00b002a2c5384d5bmr7966300pjq.25.1712583806874; Mon, 08 Apr 2024 06:43:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712583806; cv=pass; d=google.com; s=arc-20160816; b=kdvjbY3aO88LtYGGZKMv+v0orrGlUjBgMjw43N5uSQOPda183WvZHw55d4J/76ncOk f6sddsazRTzW5MJxTtojKkdPEwkpZLYVG8h07CPhKBGsUUV4yYjkyIuYDp3TxkMGmS11 sw0lpBDyevOjpsjIWCjtavjcqwPAH9+bfT5zKePAnMELsBP6p4mS9q5GbnW7TXnNuYzB Vz8rcjeTQ1e41Ty19V2ShJM4uBusjMzHExJvkzaggYsn8M4AYTv9oi9yB5VnHyyT3vpC P55cb2JcaOGSiP2ySLAmShfF4b11o3CWunLmlz3xseZ2HifWMHES/jiDDaRlnnfTNfx0 3bfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:user-agent:date :message-id:from:references:cc:to:subject; bh=ORLkhynfBFHHDPhjF0u1q3AJHwDrnAw4ZNbKzeYJlhQ=; fh=UuQvIkf0wRKknHRYPVxytKiHNlW8obqOBHn/ao/qnm8=; b=VbUlSAP2ApuR6sBsdp1OkmxphU6Z9jBph5QLk1T4Sl/W0sxCm02Uqx5ZTXCdDP6mus kZ0QKp8ckQoZI71WnRTkwoHW5EtTR3PORof7S/oAuGP2nYufY0TGs1HJC8lm+EcRkXPv CSMK+BQ61er3Muc6AZX8mCJGdVRxnS9GZnpLscpPXcWebA1gHcJiz1NCfYiLYD9W4kq6 G0jaYaq8A7K+K2Bt0JEvRt+QgrCnyXZStCYiCSC0PaxltxaqCqEhIVCTHjO4akAGc1da RNWecMIvDXkfc61Y7zgqYli4d5bcaOb+F+mvrKg9/HYifQzcWoe0lyfNoXkt/Dzj1nIz oLAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-135457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id i9-20020a17090ad34900b002a310ed2fefsi6340923pjx.155.2024.04.08.06.43.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 06:43:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-135457-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135457-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=QUARANTINE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 8EC7C283927 for ; Mon, 8 Apr 2024 13:43:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0C68112E1EE; Mon, 8 Apr 2024 13:38:05 +0000 (UTC) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4FE6112CDBF; Mon, 8 Apr 2024 13:38:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712583484; cv=none; b=H6KrxNgnTlxIEoFey5uqBKMHifoQ/V2B+Bmj/DVxTHMZF2Tq9SkXqROoPiQp10iy0ovmwlRrt0E9OnK45nBcI1IQycBPjsXtNjNaAgJEd/V2CC1YIWsaHUJGQ8AIg0cHi3EbbH8+6YcmN/2tM0QJFGmTH6N07qtIWXUimXVXnHI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712583484; c=relaxed/simple; bh=E0/UTpUSMOnQ9j5vlnYiF5Npys6nHFf4oi0gwpMqJj4=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=tmsY09AGZ9i6cKkDnh8PWwwDt6JMF9rMU1yY6HLfzwGAp6cNsu5NyrZb3/x0DXBpeE4tL+wYI+50oCAfEJaUddQH1mnZsGVFakV8d65DTmlZJzYhk7VtacNFrXwmjArkuE5jRMhzheUm+ASfG+XpoYWrWPyS1OWAkF0CRKllClo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4VCqq459Xjz1ymVC; Mon, 8 Apr 2024 21:35:44 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 5D06118002D; Mon, 8 Apr 2024 21:37:58 +0800 (CST) Received: from [10.69.30.204] (10.69.30.204) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 8 Apr 2024 21:37:58 +0800 Subject: Re: [PATCH net-next v1 00/12] First try to replace page_frag with page_frag_cache To: Alexander Duyck CC: , , , , , Matthias Brugger , AngeloGioacchino Del Regno , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , , , References: <20240407130850.19625-1-linyunsheng@huawei.com> From: Yunsheng Lin Message-ID: <05c21500-033b-dfee-6aa7-1ee967616213@huawei.com> Date: Mon, 8 Apr 2024 21:37:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500005.china.huawei.com (7.185.36.74) On 2024/4/8 1:02, Alexander Duyck wrote: > On Sun, Apr 7, 2024 at 6:10 AM Yunsheng Lin wrote: >> >> After [1], Only there are two implementations for page frag: >> >> 1. mm/page_alloc.c: net stack seems to be using it in the >> rx part with 'struct page_frag_cache' and the main API >> being page_frag_alloc_align(). >> 2. net/core/sock.c: net stack seems to be using it in the >> tx part with 'struct page_frag' and the main API being >> skb_page_frag_refill(). >> >> This patchset tries to unfiy the page frag implementation >> by replacing page_frag with page_frag_cache for sk_page_frag() >> first. net_high_order_alloc_disable_key for the implementation >> in net/core/sock.c doesn't seems matter that much now have >> have pcp support for high-order pages in commit 44042b449872 >> ("mm/page_alloc: allow high-order pages to be stored on the >> per-cpu lists"). >> >> As the related change is mostly related to networking, so >> targeting the net-next. And will try to replace the rest >> of page_frag in the follow patchset. >> >> After this patchset, we are not only able to unify the page >> frag implementation a little, but seems able to have about >> 0.5+% performance boost testing by using the vhost_net_test >> introduced in [1] and page_frag_test.ko introduced in this >> patch. > > One question that jumps out at me for this is "why?". No offense but > this is a pretty massive set of changes with over 1400 additions and > 500+ deletions and I can't help but ask why, and this cover page > doesn't give me any good reason to think about accepting this set. There are 375 + 256 additions for testing module and the documentation update in the last two patches, and there is 198 additions and 176 deletions for moving the page fragment allocator from page_alloc into its own file in patch 1. Without above number, there are above 600+ additions and 300+ deletions, deos that seems reasonable considering 140+ additions are needed to for the new API, 300+ additions and deletions for updating the users to use the new API as there are many users using the old API? > What is meant to be the benefit to the community for adding this? All > I am seeing is a ton of extra code to have to review as this > unification is adding an additional 1000+ lines without a good > explanation as to why they are needed. Some benefits I see for now: 1. Improve the maintainability of page frag's implementation: (1) future bugfix and performance can be done in one place. For example, we may able to save some space for the 'page_frag_cache' API user, and avoid 'get_page()' for the old 'page_frag' API user. (2) Provide a proper API so that caller does not need to access internal data field. Exposing the internal data field may enable the caller to do some unexpcted implementation of its own like below, after this patchset the API user is not supposed to do access the data field of 'page_frag_cache' directly[Currently it is still acessable from API caller if the caller is not following the rule, I am not sure how to limit the access without any performance impact yet]. https://elixir.bootlin.com/linux/v6.9-rc3/source/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c#L1141 2. page_frag API may provide a central point for netwroking to allocate memory instead of calling page allocator directly in the future, so that we can decouple 'struct page' from networking. > > Also I wouldn't bother mentioning the 0.5+% performance gain as a > "bonus". Changes of that amount usually mean it is within the margin > of error. At best it likely means you haven't introduced a noticeable > regression. For micro-benchmark ko added in this patchset, performance gain seems quit stable from testing in system without any other load. > . >