All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Hugh Dickins <hughd@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <muchun.song@linux.dev>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH next] hugetlb: pte_alloc_huge() to replace huge pte_alloc_map()
Date: Thu, 20 Apr 2023 10:08:13 -0700	[thread overview]
Message-ID: <20230420170813.GA8230@monkey> (raw)
In-Reply-To: <ae9e7d98-8a3a-cfd9-4762-bcddffdf96cf@google.com>

On 04/18/23 22:22, Hugh Dickins wrote:
> Some architectures can have their hugetlb pages down at the lowest PTE
> level: their huge_pte_alloc() using pte_alloc_map(), but without any
> following pte_unmap().  Since none of these arches uses CONFIG_HIGHPTE,
> this is not seen as a problem at present; but would become a problem if
> forthcoming changes were to add an rcu_read_lock() into pte_offset_map(),
> with the rcu_read_unlock() expected in pte_unmap().
> 
> Similarly in their huge_pte_offset(): pte_offset_kernel() is good enough
> for that, but it's probably less confusing if we define pte_offset_huge()
> along with pte_alloc_huge().  Only define them without CONFIG_HIGHPTE:
> so there would be a build error to signal if ever more work is needed.
> 
> For ease of development, define these now for 6.4-rc1, ahead of any use:
> then architectures can integrate patches using them, independent from mm.
> 
> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> 
>  include/linux/hugetlb.h | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

Hate to say that I am ignorant of the 'forthcoming changes' that might
add an rcu_read_lock() into pte_offset_map().  But, the reasoning is
sound and code is fine.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

-- 
Mike Kravetz

> 
> --- a/include/linux/hugetlb.h
> +++ b/include/linux/hugetlb.h
> @@ -183,6 +183,23 @@ extern struct list_head huge_boot_pages;
>  
>  /* arch callbacks */
>  
> +#ifndef CONFIG_HIGHPTE
> +/*
> + * pte_offset_huge() and pte_alloc_huge() are helpers for those architectures
> + * which may go down to the lowest PTE level in their huge_pte_offset() and
> + * huge_pte_alloc(): to avoid reliance on pte_offset_map() without pte_unmap().
> + */
> +static inline pte_t *pte_offset_huge(pmd_t *pmd, unsigned long address)
> +{
> +	return pte_offset_kernel(pmd, address);
> +}
> +static inline pte_t *pte_alloc_huge(struct mm_struct *mm, pmd_t *pmd,
> +				    unsigned long address)
> +{
> +	return pte_alloc(mm, pmd) ? NULL : pte_offset_huge(pmd, address);
> +}
> +#endif
> +
>  pte_t *huge_pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
>  			unsigned long addr, unsigned long sz);
>  /*

      reply	other threads:[~2023-04-20 17:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-19  5:22 [PATCH next] hugetlb: pte_alloc_huge() to replace huge pte_alloc_map() Hugh Dickins
2023-04-20 17:08 ` Mike Kravetz [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=20230420170813.GA8230@monkey \
    --to=mike.kravetz@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.