diff mbox series

[v4,04/17] arm64: hibernate: use get_safe_page directly

Message ID 20190909181221.309510-5-pasha.tatashin@soleen.com (mailing list archive)
State New, archived
Headers show
Series arm64: MMU enabled kexec relocation | expand

Commit Message

Pasha Tatashin Sept. 9, 2019, 6:12 p.m. UTC
create_safe_exec_page() uses hibernate's allocator to create a set of page
table to map a single page that will contain the relocation code.

Remove the allocator related arguments, and use get_safe_page directly, as
it is done in other local functions in this file to simplify function
prototype.

Removing this function pointer makes it easier to refactor the code later.

Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
---
 arch/arm64/kernel/hibernate.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

Comments

Matthias Brugger Sept. 10, 2019, 8:03 a.m. UTC | #1
On 09/09/2019 20:12, Pavel Tatashin wrote:
> create_safe_exec_page() uses hibernate's allocator to create a set of page
> table to map a single page that will contain the relocation code.
> 
> Remove the allocator related arguments, and use get_safe_page directly, as
> it is done in other local functions in this file to simplify function
> prototype.
> 
> Removing this function pointer makes it easier to refactor the code later.
> 
> Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>

Reviewed-by: Matthias Brugger <mbrugger@suse.com>

> ---
>  arch/arm64/kernel/hibernate.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
> index 227cc26720f7..47a861e0cb0c 100644
> --- a/arch/arm64/kernel/hibernate.c
> +++ b/arch/arm64/kernel/hibernate.c
> @@ -196,9 +196,7 @@ EXPORT_SYMBOL(arch_hibernation_header_restore);
>   */
>  static int create_safe_exec_page(void *src_start, size_t length,
>  				 unsigned long dst_addr,
> -				 phys_addr_t *phys_dst_addr,
> -				 void *(*allocator)(gfp_t mask),
> -				 gfp_t mask)
> +				 phys_addr_t *phys_dst_addr)
>  {
>  	int rc = 0;
>  	pgd_t *trans_pgd;
> @@ -206,7 +204,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
>  	pud_t *pudp;
>  	pmd_t *pmdp;
>  	pte_t *ptep;
> -	unsigned long dst = (unsigned long)allocator(mask);
> +	unsigned long dst = get_safe_page(GFP_ATOMIC);
>  
>  	if (!dst) {
>  		rc = -ENOMEM;
> @@ -216,7 +214,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
>  	memcpy((void *)dst, src_start, length);
>  	__flush_icache_range(dst, dst + length);
>  
> -	trans_pgd = allocator(mask);
> +	trans_pgd = (void *)get_safe_page(GFP_ATOMIC);
>  	if (!trans_pgd) {
>  		rc = -ENOMEM;
>  		goto out;
> @@ -224,7 +222,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
>  
>  	pgdp = pgd_offset_raw(trans_pgd, dst_addr);
>  	if (pgd_none(READ_ONCE(*pgdp))) {
> -		pudp = allocator(mask);
> +		pudp = (void *)get_safe_page(GFP_ATOMIC);
>  		if (!pudp) {
>  			rc = -ENOMEM;
>  			goto out;
> @@ -234,7 +232,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
>  
>  	pudp = pud_offset(pgdp, dst_addr);
>  	if (pud_none(READ_ONCE(*pudp))) {
> -		pmdp = allocator(mask);
> +		pmdp = (void *)get_safe_page(GFP_ATOMIC);
>  		if (!pmdp) {
>  			rc = -ENOMEM;
>  			goto out;
> @@ -244,7 +242,7 @@ static int create_safe_exec_page(void *src_start, size_t length,
>  
>  	pmdp = pmd_offset(pudp, dst_addr);
>  	if (pmd_none(READ_ONCE(*pmdp))) {
> -		ptep = allocator(mask);
> +		ptep = (void *)get_safe_page(GFP_ATOMIC);
>  		if (!ptep) {
>  			rc = -ENOMEM;
>  			goto out;
> @@ -530,8 +528,7 @@ int swsusp_arch_resume(void)
>  	 */
>  	rc = create_safe_exec_page(__hibernate_exit_text_start, exit_size,
>  				   (unsigned long)hibernate_exit,
> -				   &phys_hibernate_exit,
> -				   (void *)get_safe_page, GFP_ATOMIC);
> +				   &phys_hibernate_exit);
>  	if (rc) {
>  		pr_err("Failed to create safe executable page for hibernate_exit code.\n");
>  		goto out;
>
Pasha Tatashin Sept. 10, 2019, 9:10 a.m. UTC | #2
> On 09/09/2019 20:12, Pavel Tatashin wrote:
> > create_safe_exec_page() uses hibernate's allocator to create a set of page
> > table to map a single page that will contain the relocation code.
> >
> > Remove the allocator related arguments, and use get_safe_page directly, as
> > it is done in other local functions in this file to simplify function
> > prototype.
> >
> > Removing this function pointer makes it easier to refactor the code later.
> >
> > Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
>
> Reviewed-by: Matthias Brugger <mbrugger@suse.com>
>

Thank you
diff mbox series

Patch

diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index 227cc26720f7..47a861e0cb0c 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c
@@ -196,9 +196,7 @@  EXPORT_SYMBOL(arch_hibernation_header_restore);
  */
 static int create_safe_exec_page(void *src_start, size_t length,
 				 unsigned long dst_addr,
-				 phys_addr_t *phys_dst_addr,
-				 void *(*allocator)(gfp_t mask),
-				 gfp_t mask)
+				 phys_addr_t *phys_dst_addr)
 {
 	int rc = 0;
 	pgd_t *trans_pgd;
@@ -206,7 +204,7 @@  static int create_safe_exec_page(void *src_start, size_t length,
 	pud_t *pudp;
 	pmd_t *pmdp;
 	pte_t *ptep;
-	unsigned long dst = (unsigned long)allocator(mask);
+	unsigned long dst = get_safe_page(GFP_ATOMIC);
 
 	if (!dst) {
 		rc = -ENOMEM;
@@ -216,7 +214,7 @@  static int create_safe_exec_page(void *src_start, size_t length,
 	memcpy((void *)dst, src_start, length);
 	__flush_icache_range(dst, dst + length);
 
-	trans_pgd = allocator(mask);
+	trans_pgd = (void *)get_safe_page(GFP_ATOMIC);
 	if (!trans_pgd) {
 		rc = -ENOMEM;
 		goto out;
@@ -224,7 +222,7 @@  static int create_safe_exec_page(void *src_start, size_t length,
 
 	pgdp = pgd_offset_raw(trans_pgd, dst_addr);
 	if (pgd_none(READ_ONCE(*pgdp))) {
-		pudp = allocator(mask);
+		pudp = (void *)get_safe_page(GFP_ATOMIC);
 		if (!pudp) {
 			rc = -ENOMEM;
 			goto out;
@@ -234,7 +232,7 @@  static int create_safe_exec_page(void *src_start, size_t length,
 
 	pudp = pud_offset(pgdp, dst_addr);
 	if (pud_none(READ_ONCE(*pudp))) {
-		pmdp = allocator(mask);
+		pmdp = (void *)get_safe_page(GFP_ATOMIC);
 		if (!pmdp) {
 			rc = -ENOMEM;
 			goto out;
@@ -244,7 +242,7 @@  static int create_safe_exec_page(void *src_start, size_t length,
 
 	pmdp = pmd_offset(pudp, dst_addr);
 	if (pmd_none(READ_ONCE(*pmdp))) {
-		ptep = allocator(mask);
+		ptep = (void *)get_safe_page(GFP_ATOMIC);
 		if (!ptep) {
 			rc = -ENOMEM;
 			goto out;
@@ -530,8 +528,7 @@  int swsusp_arch_resume(void)
 	 */
 	rc = create_safe_exec_page(__hibernate_exit_text_start, exit_size,
 				   (unsigned long)hibernate_exit,
-				   &phys_hibernate_exit,
-				   (void *)get_safe_page, GFP_ATOMIC);
+				   &phys_hibernate_exit);
 	if (rc) {
 		pr_err("Failed to create safe executable page for hibernate_exit code.\n");
 		goto out;