From: Vlastimil Babka <vbabka@suse.cz>
To: Alexander Duyck <alexander.duyck@gmail.com>,
netdev@vger.kernel.org, davem@davemloft.net
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, jannh@google.com
Subject: Re: [net PATCH 1/2] mm: Use fixed constant in page_frag_alloc instead of size + 1
Date: Mon, 20 Mar 2023 16:14:50 +0100 [thread overview]
Message-ID: <7b2a7b7b-0ebc-1f03-5f1b-ac598fc950dc@suse.cz> (raw)
In-Reply-To: <d68edefb-4930-a9cf-1150-9bd2a2a9a02f@suse.cz>
On 2/17/23 10:30, Vlastimil Babka wrote:
> On 2/15/19 23:44, Alexander Duyck wrote:
>> From: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>>
>> This patch replaces the size + 1 value introduced with the recent fix for 1
>> byte allocs with a constant value.
>>
>> The idea here is to reduce code overhead as the previous logic would have
>> to read size into a register, then increment it, and write it back to
>> whatever field was being used. By using a constant we can avoid those
>> memory reads and arithmetic operations in favor of just encoding the
>> maximum value into the operation itself.
>>
>> Fixes: 2c2ade81741c ("mm: page_alloc: fix ref bias in page_frag_alloc() for 1-byte allocs")
>> Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
>> ---
>> mm/page_alloc.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>> index ebb35e4d0d90..37ed14ad0b59 100644
>> --- a/mm/page_alloc.c
>> +++ b/mm/page_alloc.c
>> @@ -4857,11 +4857,11 @@ void *page_frag_alloc(struct page_frag_cache *nc,
>> /* Even if we own the page, we do not use atomic_set().
>> * This would break get_page_unless_zero() users.
>> */
>> - page_ref_add(page, size);
>> + page_ref_add(page, PAGE_FRAG_CACHE_MAX_SIZE);
>
> But this value can be theoretically too low when PAGE_SIZE >
> PAGE_FRAG_CACHE_MAX_SIZE? Such as on architectures with 64kB page size,
> while PAGE_FRAG_CACHE_MAX_SIZE is 32kB?
Nevermind, PAGE_FRAG_CACHE_MAX_SIZE would be 64kB because
#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
So all is fine, sorry for the noise.
next prev parent reply other threads:[~2023-03-20 15:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-15 22:44 [net PATCH 0/2] Address recent issues found in netdev page_frag_alloc usage Alexander Duyck
2019-02-15 22:44 ` [net PATCH 1/2] mm: Use fixed constant in page_frag_alloc instead of size + 1 Alexander Duyck
2023-02-17 9:30 ` Vlastimil Babka
2023-03-20 15:14 ` Vlastimil Babka [this message]
2019-02-15 22:44 ` [net PATCH 2/2] net: Do not allocate page fragments that are not skb aligned Alexander Duyck
2019-02-17 23:50 ` [net PATCH 0/2] Address recent issues found in netdev page_frag_alloc usage David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b2a7b7b-0ebc-1f03-5f1b-ac598fc950dc@suse.cz \
--to=vbabka@suse.cz \
--cc=alexander.duyck@gmail.com \
--cc=davem@davemloft.net \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).