linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Joao Martins <joao.m.martins@oracle.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Muchun Song <songmuchun@bytedance.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Tarun Sahu <tsahu@linux.ibm.com>,
	linux-mm@kvack.org, akpm@linux-foundation.org
Subject: Re: [PATCH v2 1/2] mm/vmemmap/devdax: Fix kernel crash when probing devdax devices
Date: Tue, 11 Apr 2023 16:50:58 +0100	[thread overview]
Message-ID: <4c3797a7-45d0-f876-2d44-3238e66d5b77@oracle.com> (raw)
In-Reply-To: <87y1mybg2s.fsf@linux.ibm.com>

On 11/04/2023 16:20, Aneesh Kumar K.V wrote:
> Joao Martins <joao.m.martins@oracle.com> writes:
>> On 11/04/2023 15:18, Aneesh Kumar K.V wrote:
>>> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
>>> index 3bb3484563ed..292411d8816f 100644
>>> --- a/mm/page_alloc.c
>>> +++ b/mm/page_alloc.c
>>> @@ -6844,10 +6844,13 @@ static void __ref __init_zone_device_page(struct page *page, unsigned long pfn,
>>>   * of an altmap. See vmemmap_populate_compound_pages().
>>>   */
>>>  static inline unsigned long compound_nr_pages(struct vmem_altmap *altmap,
>>> +					      struct dev_pagemap *pgmap,
>>>  					      unsigned long nr_pages)
>>>  {
>>> -	return is_power_of_2(sizeof(struct page)) &&
>>> -		!altmap ? 2 * (PAGE_SIZE / sizeof(struct page)) : nr_pages;
>>> +	if (vmemmap_can_optimize(altmap, pgmap))
>>> +		return 2 * (PAGE_SIZE / sizeof(struct page));
>>> +	else
>>> +		return nr_pages;
>>>  }
>>>  
>>
>> Keep the ternary operator as already is the case for compound_nr_pages to avoid
>> doing too much in one patch:
>>
>> 	return vmemmap_can_optimize(altmap, pgmap) ?
>> 		2 * (PAGE_SIZE / sizeof(struct page)) : nr_pages;
>>
>> Or you really want to remove the ternary operator perhaps take the unnecessary
>> else and make the long line be less indented:
>>
>> 	if (!vmemmap_can_optimize(altmap, pgmap))
>> 		return nr_pages;
>>
>> 	return  2 * (PAGE_SIZE / sizeof(struct page));
>>
>> I don't think the latter is a significant improvement over the ternary one. But
>> I guess that's a matter of preferred style.
> 
> How about
> 
> static inline unsigned long compound_nr_pages(struct vmem_altmap *altmap,
> 					      struct dev_pagemap *pgmap)
> {
> 
> 	if (!vmemmap_can_optimize(altmap, pgmap))
> 		return pgmap_vmemmap_nr(pgmap);
> 
> 	return 2 * (PAGE_SIZE / sizeof(struct page));
> }
> 

I am a bit more fond of the ternary option. But this snip above is fine as well,
including with the s/nr_pages/pgmap_vmemmap_nr(pgmap)/ change you added.



      reply	other threads:[~2023-04-11 15:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11 14:18 Aneesh Kumar K.V
2023-04-11 14:18 ` [PATCH v2 2/2] m/hugetlb: Rename ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP Aneesh Kumar K.V
2023-04-11 15:52   ` Joao Martins
2023-04-11 16:14     ` Aneesh Kumar K V
2023-04-11 17:34       ` Joao Martins
2023-04-12  3:43   ` [External] " Muchun Song
2023-04-11 14:35 ` [PATCH v2 1/2] mm/vmemmap/devdax: Fix kernel crash when probing devdax devices Joao Martins
2023-04-11 15:20   ` Aneesh Kumar K.V
2023-04-11 15:50     ` Joao Martins [this message]

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=4c3797a7-45d0-f876-2d44-3238e66d5b77@oracle.com \
    --to=joao.m.martins@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-mm@kvack.org \
    --cc=songmuchun@bytedance.com \
    --cc=tsahu@linux.ibm.com \
    /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