Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp402310rdd; Tue, 9 Jan 2024 07:38:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IFoglRP+X6uaYRdiE5cvtkp9esxwIqDoN+bpe4ihH+TPqH0WpXZcNaUu15wIBCJ52nuBjhz X-Received: by 2002:a05:6122:21a3:b0:4b7:aae9:dfaf with SMTP id j35-20020a05612221a300b004b7aae9dfafmr2637037vkd.24.1704814715605; Tue, 09 Jan 2024 07:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704814715; cv=none; d=google.com; s=arc-20160816; b=swyFqfLh49JaBPEmIrBIAELsUWd+b2IPuMrmDNyXKXCVeq4vZd8r8vBQlcmRNoHsnh AsNok2rfyiRU1FTv6pnZGamjVOPB+z3VHUOGF1Ldod2z/cpRB47PpHJg+nsXED7Y6IPT u27SicRu9HsMc0fHb0iNaePOXJk0LEyYFLiWJru8VAL5iIWX4Qxc35F+r20pAMaNdUGH eVwlAreWmavTlUTlAp4vi80n2TL2xglr9Jzl+dL/Fsmfry9s/ZbnCiqbvE6s5/S7Od0k q4nGHmjMBI69tKr4QKP9VdA7SDWdTOK/awQMHHGSUQ1abPaKBPui84q0qtdK6XMFpvHY sE7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=WczyQ1l8jHhZlEcIGinjqLaLiGU6nueDfrDaoUhkza8=; fh=Ff3LjifzwbmPsBdNeAp9lyk2vadALK9yA7W1mBkN9nE=; b=NdbHLrkw7MaDFK086S1/9quhQPD2SnLagope2wuHu/v1v2BSOKgT1miXpJYtBEXmeT gf3OrdLhtPa4hU7Co/UgHg5Lue9rs44IpVpr72lQyGtFGmOK4dIMYhtLh2AmihmbibGv CLsG0sRAMINtjuT95tYYib7bBo6sZmuMIfLtjO4bexbKis7CQ4QseP/uATnziXHmnEf7 olSgX5QBU4ZT3UfVBoKACRQeibyScR0M/ZL2j++TCmKPzGyQ43xhkNzLVdVzaVKuSEle g07qoSdRK42FCKvcAh+42PcHv5rPtkhs/1EbeI+Lzt9P1im1LZYbHLIeYLq7xsSaXTuY U9hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TvN3Fyf6; spf=pass (google.com: domain of linux-kernel+bounces-21056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21056-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b189-20020a1fcbc6000000b004b7179785a1si373814vkg.25.2024.01.09.07.38.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 07:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=TvN3Fyf6; spf=pass (google.com: domain of linux-kernel+bounces-21056-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21056-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 572ED1C23C5F for ; Tue, 9 Jan 2024 15:38:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9EB3539FF3; Tue, 9 Jan 2024 15:38:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TvN3Fyf6" Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 917F639FDD; Tue, 9 Jan 2024 15:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-5cedfc32250so1257731a12.0; Tue, 09 Jan 2024 07:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704814703; x=1705419503; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WczyQ1l8jHhZlEcIGinjqLaLiGU6nueDfrDaoUhkza8=; b=TvN3Fyf6k87SR+zPi7lOYo0zUO6Rv3MAgXwjlQyl0CUb6SHjRgit8iSKrqf7qaMZEC dZXEnTGOm9KhOhSco+tRffNUy/Po/SnQjN1+OWOQ1yqKafXD74H0DblVW4LjHkwuCuqF mvcgim21VkCuBNI3zTGSBXiVgDoOEYDGEqzuWiFnM38A38BuCXvKYyZwzu1NAfIp0a8J I6WtoV0q7JhJhr3kNdjQNJ9c3ksbohaNQ0UwT1Y4rrxzsWSnG1SGk9gJe14aXFTMIzWb C4ggJPcB9Ss0HpFNhf3WqX3xbcBfQui/bBLBNSJ55pKvaAK8vv4gOiEtmGzqLvGWPwVx Q1aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704814703; x=1705419503; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WczyQ1l8jHhZlEcIGinjqLaLiGU6nueDfrDaoUhkza8=; b=J7f87pZOOidt0rawALuGNKEV/yI91teMPTuk5BKrn02HZWytyE0al0GS6SJANZ1v7n Qb1eleeVZH/Towrf0z495OvVvMgYBraexDyRoz1hVPZbOt7VDCRB8B5GpYmY8fnHfuya u3V2A2c4NYX0Xuf4I6PVyVbQd8soyyTqD40IEp+UfTW6W4IZjGx0pllLLg34ThyI990p 1qSfgqF1IAUVHANKVpmn+HXXv5FY4nEa6EGuYDQ1dsSd4lSM0dFNEKKXaQQnZfaaXImx pt/sSW+766ABqnPkKl/E02Odu82+ewxR9Kg4uF/r1F3/KoVeB3Oxmep928879eGZAWs6 I5AQ== X-Gm-Message-State: AOJu0YzMzXwwEXJsXKFGLdra60Pooch9smSQqCZxY2xzi41z78ktGY/W 7idQTdT0ZW5TAmb4i+T4G0Mnvwro7hTsZD5LNvPY6kbi X-Received: by 2002:a17:90b:364c:b0:28d:7947:1da0 with SMTP id nh12-20020a17090b364c00b0028d79471da0mr1816952pjb.29.1704814702732; Tue, 09 Jan 2024 07:38:22 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240103095650.25769-1-linyunsheng@huawei.com> <20240103095650.25769-4-linyunsheng@huawei.com> <74c9a3a1-5204-f79a-95ff-5c108ec6cf2a@huawei.com> In-Reply-To: From: Alexander Duyck Date: Tue, 9 Jan 2024 07:37:46 -0800 Message-ID: Subject: Re: [PATCH net-next 3/6] mm/page_alloc: use initial zero offset for page_frag_alloc_align() To: Yunsheng Lin Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 9, 2024 at 3:22=E2=80=AFAM Yunsheng Lin wrote: > > On 2024/1/9 0:25, Alexander Duyck wrote: > > On Mon, Jan 8, 2024 at 12:59=E2=80=AFAM Yunsheng Lin wrote: > > ... > > > > >>> > >>> 2. By starting at the end and working toward zero we can use built in > >>> functionality of the CPU to only have to check and see if our result > >>> would be signed rather than having to load two registers with the > >>> values and then compare them which saves us a few cycles. In addition > >>> it saves us from having to read both the size and the offset for ever= y > >>> page. > >> > >> I suppose the above is ok if we only use the page_frag_alloc*() API to > >> allocate memory for skb->data, not for the frag in skb_shinfo(), as by > >> starting at the end and working toward zero, it means we can not do sk= b > >> coalescing. > >> > >> As page_frag_alloc*() is returning va now, I am assuming most of users > >> is using the API for skb->data, I guess it is ok to drop this patch fo= r > >> now. > >> > >> If we allow page_frag_alloc*() to return struct page, we might need th= is > >> patch to enable coalescing. > > > > I would argue this is not the interface for enabling coalescing. This > > is one of the reasons why this is implemented the way it is. When you > > are aligning fragments you aren't going to be able to coalesce the > > frames anyway as the alignment would push the fragments apart. > > It seems the alignment requirement is the same for the same user of a pag= e_frag > instance, so the aligning does not seem to be a problem for coalescing? I'm a bit confused as to what coalescing you are referring to. If you can provide a link it would be useful. The problem is page_frag is a very generic item and can be generated from a regular page on NICs that can internally reuse the same page instance for multiple buffers. So it is possible to coalesce page frags, however it is very unlikely to be coalescing them in the case of them being used for skb buffers since it would require aligned payloads on the network in order to really make it work without hardware intervention of some sort and on such devices they are likely allocating entire pages instead of page frags for the buffers.