Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp218307rdb; Fri, 5 Jan 2024 07:42:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IGDWe9zH18IXDdTiTvdeLkRGFvupfZfrWPHfRsXOTVBPvQ4FZOWwUVIqE1WnYL5bOQH5aX4 X-Received: by 2002:a05:620a:8391:b0:783:cf5:47ab with SMTP id pb17-20020a05620a839100b007830cf547abmr562251qkn.64.1704469342298; Fri, 05 Jan 2024 07:42:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704469342; cv=none; d=google.com; s=arc-20160816; b=tV/04QUwN91NUX8lEuSvJcqP14KGjNoTT+rz90CK+fo1sWzK5NpDFLPAkFAe4gvwt5 7jqOi/sH4HOOngb89lc1DtOm/SwjY85tNel3zoNf+DnDvnpNDBdh45IgQ9wTNc5wY/UN 5siobheVoTxY/9CNDdmKcoSlNTMOJ0ckvnC7afCmICq8+ao3cQs44N0cvNtULJBmsRQz YtFsuSFhQcpe6AXtkPS0t12txtNAQHRP6KyvOiFwb3ddnITTk4JNYC3+EDT9ycIV62jY 9vl82kDt/e3qbfVQ6J3g4HQNLGBxtKdFLRS1Uc0XD99ta6MrFiJy3uW1w5o5tu2/LNF9 IOwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=M0tdftrGJbQA0lnpxqT4ZNVpdbS5d9YFAgX2xz2KRWA=; fh=7l5YGyxYaxrJsaEXLNzam6m6Lfe6zkoD6B6wSn4b3So=; b=eddL1OZyX84ZL2mRHacYZfuk+6sgaBbNH1GYGw8Wh6jD+fRkKz6pDR/EhDcrTf7IoE Ogu0J4JfWVWKiRvKraPWL2sxOFazCPb+3n4zwV95wmbTO7jHOzUcGx1NpXo+R4zoTkjC miYql+9SlCx76P5atHVsevw5jFstkUwD+qx6sGGpsLMLUoda1t0Ys7kiW4FbaCgRX9H1 RruQeXfvVWGDaUMTue2/xmqc7Fqn4cdTJvFcLhLC4nTEfhUPMcbbzTB1qDBqGvnhjiFP D2TyjmIQ0nUldVsX06fenz1ta9xw4GgMaup19FCEHjuubjnG729TWAZD/3Ng/ILV/MoI Lxmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fECjWpxQ; spf=pass (google.com: domain of linux-kernel+bounces-18005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18005-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x21-20020a05620a099500b00783051fb425si1872680qkx.166.2024.01.05.07.42.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 07:42:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-18005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fECjWpxQ; spf=pass (google.com: domain of linux-kernel+bounces-18005-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-18005-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 119D91C228E9 for ; Fri, 5 Jan 2024 15:42:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 74A042E65B; Fri, 5 Jan 2024 15:42:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fECjWpxQ" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 74AC92E640; Fri, 5 Jan 2024 15:42:11 +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-pl1-f176.google.com with SMTP id d9443c01a7336-1d40eec5e12so11988325ad.1; Fri, 05 Jan 2024 07:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704469330; x=1705074130; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=M0tdftrGJbQA0lnpxqT4ZNVpdbS5d9YFAgX2xz2KRWA=; b=fECjWpxQv12EI7w4N+VGl1gFJ9NQ9Kgp86nz2HPZdE3Md54aCBtwclpxqpSi9gKxzI oydwlbImie8exWeaDmpZLnlL3wXO8rah90D9hJtiaJnYffybF+dSx5h34UFzp3YXy/MD OqVMXOoD4MkEvT3GWa3wh9r5u4KT/H8/14PkZo0svi4XUPVlDYggFUbqiqt9TlKH8a9l cR6Vw6hj7BtpCCvjJDhDAanWrl5O5P0AfX+umF04/DgOjHu0lID8a++T2K4gdyrl5s0E /Yd3fHC3JlayjUodpBVvYQSFsXNZqVY3jvU1Gqcv7dvVzkWmplKnXk9RUUdlSaRKYz9d LIxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704469330; x=1705074130; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=M0tdftrGJbQA0lnpxqT4ZNVpdbS5d9YFAgX2xz2KRWA=; b=B0VmEE/x4Sf2P0RElFrbjNXxREjD+gCkUv/wtpmlrovWdJms6iiY218NaAvncZrvIW hoqdtEnGFyvarv0o+viDDZzsLZePzN935/c/+ppatIJ2OByZqw18uhrSnjPsljtsyjoK AKyMm4ZqtKvGQcw7uqQDcLrbx3zKV7DolPub/1yBK7UESKd/1/SegX4PgACzOPx+XFTU mRo2rKhZtvFaQ7LytMjF7fjGLtW/huxRo1kvEJNuV+U+HF/iNQRSk6crMMtFjEgspnlN BRr1KQheGpUnjp3ztp2ukYhDnoO4EHRNtYCdLpR3ct7lXVbmuu9yvJ70giaUHMpE3+kV XSpg== X-Gm-Message-State: AOJu0Yy+uJRYFS2kBiiRvFgTAognDpGxvTGCDkghGODMxNzsWSi8R5hf qE1IA1oSOinJlYA7UNMJZ/I= X-Received: by 2002:a17:902:e84a:b0:1d4:5b0d:7002 with SMTP id t10-20020a170902e84a00b001d45b0d7002mr2672794plg.112.1704469330643; Fri, 05 Jan 2024 07:42:10 -0800 (PST) Received: from ?IPv6:2605:59c8:448:b800:82ee:73ff:fe41:9a02? ([2605:59c8:448:b800:82ee:73ff:fe41:9a02]) by smtp.googlemail.com with ESMTPSA id c5-20020a170902d90500b001d3ec25614bsm1552423plz.24.2024.01.05.07.42.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 07:42:10 -0800 (PST) Message-ID: Subject: Re: [PATCH net-next 3/6] mm/page_alloc: use initial zero offset for page_frag_alloc_align() From: Alexander H Duyck To: Yunsheng Lin , davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , linux-mm@kvack.org Date: Fri, 05 Jan 2024 07:42:08 -0800 In-Reply-To: <20240103095650.25769-4-linyunsheng@huawei.com> References: <20240103095650.25769-1-linyunsheng@huawei.com> <20240103095650.25769-4-linyunsheng@huawei.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2024-01-03 at 17:56 +0800, Yunsheng Lin wrote: > The next patch is above to use page_frag_alloc_align() to > replace vhost_net_page_frag_refill(), the main difference > between those two frag page implementations is whether we > use a initial zero offset or not. >=20 > It seems more nature to use a initial zero offset, as it > may enable more correct cache prefetching and skb frag > coalescing in the networking, so change it to use initial > zero offset. >=20 > Signed-off-by: Yunsheng Lin > CC: Alexander Duyck There are several advantages to running the offset as a countdown rather than count-up value. 1. Specifically for the size of the chunks we are allocating doing it from the bottom up doesn't add any value as we are jumping in large enough amounts and are being used for DMA so being sequential doesn't add any value. 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 every page. Again this is another code cleanup at the cost of performance. I realize many of the items you are removing would be considered micro- optimizations but when we are dealing with millions of packets per second those optimizations add up.