From: Zi Yan <ziy@nvidia.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux-MM <linux-mm@kvack.org>,
Steven Rostedt <rostedt@goodmis.org>,
David Hildenbrand <david@redhat.com>,
Vlastimil Babka <vbabka@suse.cz>,
Mel Gorman <mgorman@techsingularity.net>,
Mike Rapoport <rppt@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] mm: wrap __find_buddy_pfn() with a necessary buddy page validation.
Date: Fri, 01 Apr 2022 15:25:44 -0400 [thread overview]
Message-ID: <C8ADDC89-FE41-4DA1-A820-E3F7CE818955@nvidia.com> (raw)
In-Reply-To: <CAHk-=wgNxEq9BaxBSjC+RvKPsc5zuRwc1PGEvXqqX9vb1UALyA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1701 bytes --]
On 1 Apr 2022, at 15:01, Linus Torvalds wrote:
> On Fri, Apr 1, 2022 at 11:56 AM Zi Yan <ziy@nvidia.com> wrote:
>>
>> How about the patch below? If it looks good, I will send v3.
>
> I can't see anything worrisome, but by now I've looked at several
> versions and who knows what I'm missing.
>
> Making it inline and allowing a NULL 'buddy_pfn' pointer for the cases
> that don't care might be an option, but I don't think it matters
> hugely.
What do you mean by inlining it? Moving the function and __find_buddy_pfn()
to mm/internal.h and mark both inline?
Something like below to allow a NULL 'buddy_pfn'? buddy_pfn is needed
to store the result of __find_buddy_pfn(). The code does not look
as nice as before.
struct page *find_buddy_page_pfn(struct page *page, unsigned long pfn,
unsigned int order, unsigned long *buddy_pfn)
{
struct page *buddy;
if (buddy_pfn) {
*buddy_pfn = __find_buddy_pfn(pfn, order);
buddy = page + (*buddy_pfn - pfn);
} else
buddy = page + (__find_buddy_pfn(pfn, order) - pfn);
if (page_is_buddy(page, buddy, order))
return buddy;
return NULL;
}
or
struct page *find_buddy_page_pfn(struct page *page, unsigned long pfn,
unsigned int order, unsigned long *buddy_pfn)
{
struct page *buddy;
unsigned long local_buddy_pfn = __find_buddy_pfn(pfn, order);
buddy = page + (local_buddy_pfn - pfn);
if (buddy_pfn)
*buddy_pfn = local_buddy_pfn;
if (page_is_buddy(page, buddy, order))
return buddy;
return NULL;
}
--
Best Regards,
Yan, Zi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]
next prev parent reply other threads:[~2022-04-01 19:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 18:11 [PATCH v2 1/2] mm: page_alloc: simplify pageblock migratetype check in __free_one_page() Zi Yan
2022-04-01 18:11 ` [PATCH v2 2/2] mm: wrap __find_buddy_pfn() with a necessary buddy page validation Zi Yan
2022-04-01 18:29 ` Linus Torvalds
2022-04-01 18:56 ` Zi Yan
2022-04-01 19:01 ` Linus Torvalds
2022-04-01 19:25 ` Zi Yan [this message]
2022-04-01 22:33 ` Vlastimil Babka
2022-04-01 22:14 ` [PATCH v2 1/2] mm: page_alloc: simplify pageblock migratetype check in __free_one_page() Vlastimil Babka
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=C8ADDC89-FE41-4DA1-A820-E3F7CE818955@nvidia.com \
--to=ziy@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=osalvador@suse.de \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/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