All of lore.kernel.org
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: panqinglin2020@iscas.ac.cn
Cc: palmer@dabbelt.com, linux-riscv@lists.infradead.org,
	jeff@riscv.org, xuyinan@ict.ac.cn, ajones@ventanamicro.com,
	alex@ghiti.fr, jszhang@kernel.org
Subject: Re: [PATCH v9 3/3] riscv: mm: support Svnapot in huge vmap
Date: Wed, 7 Dec 2022 18:59:18 +0000	[thread overview]
Message-ID: <Y5DihlKTtRFTil+S@spud> (raw)
In-Reply-To: <20221204141137.691790-4-panqinglin2020@iscas.ac.cn>


[-- Attachment #1.1: Type: text/plain, Size: 3051 bytes --]

On Sun, Dec 04, 2022 at 10:11:37PM +0800, panqinglin2020@iscas.ac.cn wrote:
> From: Qinglin Pan <panqinglin2020@iscas.ac.cn>
> 
> As HAVE_ARCH_HUGE_VMAP and HAVE_ARCH_HUGE_VMALLOC is supported, we can
> implement arch_vmap_pte_range_map_size and arch_vmap_pte_supported_shift
> for Svnapot to support huge vmap about napot size.
> 
> It can be tested by huge vmap used in pci driver. Huge vmalloc with svnapot
> can be tested by changing test_vmalloc module like [1], and probe this
> module to run fix_size_alloc_test with use_huge true.
> 
> [1]https://github.com/RV-VM/linux-vm-support/commit/33f4ee399c36d355c412ebe5334ca46fd727f8f5

Please make this one a standard Link: tag.

> 
> Signed-off-by: Qinglin Pan <panqinglin2020@iscas.ac.cn>
> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> 
> diff --git a/arch/riscv/include/asm/vmalloc.h b/arch/riscv/include/asm/vmalloc.h
> index 48da5371f1e9..6f7447d563ab 100644
> --- a/arch/riscv/include/asm/vmalloc.h
> +++ b/arch/riscv/include/asm/vmalloc.h
> @@ -17,6 +17,65 @@ static inline bool arch_vmap_pmd_supported(pgprot_t prot)
>  	return true;
>  }
>  
> -#endif
> +#ifdef CONFIG_RISCV_ISA_SVNAPOT
> +#include <linux/pgtable.h>
>  
> +#define arch_vmap_pte_range_map_size arch_vmap_pte_range_map_size
> +static inline unsigned long arch_vmap_pte_range_map_size(unsigned long addr, unsigned long end,
> +							 u64 pfn, unsigned int max_page_shift)
> +{
> +	unsigned long size, order;
> +	unsigned long map_size = PAGE_SIZE;
> +
> +	if (!has_svnapot())
> +		return map_size;

These ones are obvious about what you're gonna do if !has_svnapot()
though, nice :)
With a proper Link: tag
Acked-by: Conor Dooley <conor.dooley@microchip.com>

> +
> +	for_each_napot_order_rev(order) {
> +		if (napot_cont_shift(order) > max_page_shift)
> +			continue;
> +
> +		size = napot_cont_size(order);
> +		if (end - addr < size)
> +			continue;
> +
> +		if (!IS_ALIGNED(addr, size))
> +			continue;
> +
> +		if (!IS_ALIGNED(PFN_PHYS(pfn), size))
> +			continue;
> +
> +		map_size = size;
> +		break;
> +	}
> +
> +	return map_size;
> +}
> +
> +#define arch_vmap_pte_supported_shift arch_vmap_pte_supported_shift
> +static inline int arch_vmap_pte_supported_shift(unsigned long size)
> +{
> +	int shift = PAGE_SHIFT;
> +	unsigned long order;
> +
> +	if (!has_svnapot())
> +		return shift;
> +
> +	WARN_ON_ONCE(size >= PMD_SIZE);
> +
> +	for_each_napot_order_rev(order) {
> +		if (napot_cont_size(order) > size)
> +			continue;
> +
> +		if (!IS_ALIGNED(size, napot_cont_size(order)))
> +			continue;
> +
> +		shift = napot_cont_shift(order);
> +		break;
> +	}
> +
> +	return shift;
> +}
> +
> +#endif /* CONFIG_RISCV_ISA_SVNAPOT */
> +#endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
>  #endif /* _ASM_RISCV_VMALLOC_H */
> -- 
> 2.37.4
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2022-12-07 18:59 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04 14:11 [PATCH v9 0/3] riscv, mm: detect svnapot cpu support at runtime panqinglin2020
2022-12-04 14:11 ` [PATCH v9 1/3] riscv: mm: modify pte format for Svnapot panqinglin2020
2022-12-06 19:56   ` Conor Dooley
2022-12-07 18:46   ` Conor Dooley
2022-12-08  4:51     ` Qinglin Pan
2022-12-08  4:59       ` Conor.Dooley
2022-12-08 17:34       ` Qinglin Pan
2022-12-09  7:42         ` Andrew Jones
2022-12-09 14:33           ` Conor Dooley
2022-12-09 15:36             ` Qinglin Pan
2022-12-09 17:04               ` Andrew Jones
2022-12-08 14:55   ` Andrew Jones
2022-12-04 14:11 ` [PATCH v9 2/3] riscv: mm: support Svnapot in hugetlb page panqinglin2020
2022-12-07 18:55   ` Conor Dooley
2022-12-08  4:54     ` Qinglin Pan
2022-12-08 15:17   ` Andrew Jones
2022-12-08 17:43     ` Qinglin Pan
2022-12-04 14:11 ` [PATCH v9 3/3] riscv: mm: support Svnapot in huge vmap panqinglin2020
2022-12-07 18:59   ` Conor Dooley [this message]
2022-12-08  4:57     ` Qinglin Pan
2022-12-08 15:22   ` Andrew Jones
2022-12-08 17:39     ` Qinglin Pan

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=Y5DihlKTtRFTil+S@spud \
    --to=conor@kernel.org \
    --cc=ajones@ventanamicro.com \
    --cc=alex@ghiti.fr \
    --cc=jeff@riscv.org \
    --cc=jszhang@kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=panqinglin2020@iscas.ac.cn \
    --cc=xuyinan@ict.ac.cn \
    /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.