Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kexec: Use ALIGN macro instead of open-coding it
@ 2023-12-12 14:27 Yuntao Wang
  2023-12-13  2:49 ` Baoquan He
  0 siblings, 1 reply; 2+ messages in thread
From: Yuntao Wang @ 2023-12-12 14:27 UTC (permalink / raw)
  To: linux-kernel, kexec; +Cc: Eric Biederman, Andrew Morton, Yuntao Wang

Use ALIGN macro instead of open-coding it to improve code readability.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 kernel/kexec_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index be5642a4ec49..0113436e4a3a 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -430,7 +430,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 
 	pages = NULL;
 	size = (1 << order) << PAGE_SHIFT;
-	hole_start = (image->control_page + (size - 1)) & ~(size - 1);
+	hole_start = ALIGN(image->control_page, size);
 	hole_end   = hole_start + size - 1;
 	while (hole_end <= crashk_res.end) {
 		unsigned long i;
@@ -447,7 +447,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 			mend   = mstart + image->segment[i].memsz - 1;
 			if ((hole_end >= mstart) && (hole_start <= mend)) {
 				/* Advance the hole to the end of the segment */
-				hole_start = (mend + (size - 1)) & ~(size - 1);
+				hole_start = ALIGN(mend, size);
 				hole_end   = hole_start + size - 1;
 				break;
 			}
-- 
2.43.0


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] kexec: Use ALIGN macro instead of open-coding it
  2023-12-12 14:27 [PATCH] kexec: Use ALIGN macro instead of open-coding it Yuntao Wang
@ 2023-12-13  2:49 ` Baoquan He
  0 siblings, 0 replies; 2+ messages in thread
From: Baoquan He @ 2023-12-13  2:49 UTC (permalink / raw)
  To: Yuntao Wang; +Cc: linux-kernel, kexec, Eric Biederman, Andrew Morton

On 12/12/23 at 10:27pm, Yuntao Wang wrote:
> Use ALIGN macro instead of open-coding it to improve code readability.
> 
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
>  kernel/kexec_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

LGTM,

Acked-by: Baoquan He <bhe@redhat.com>

> 
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index be5642a4ec49..0113436e4a3a 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -430,7 +430,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
>  
>  	pages = NULL;
>  	size = (1 << order) << PAGE_SHIFT;
> -	hole_start = (image->control_page + (size - 1)) & ~(size - 1);
> +	hole_start = ALIGN(image->control_page, size);
>  	hole_end   = hole_start + size - 1;
>  	while (hole_end <= crashk_res.end) {
>  		unsigned long i;
> @@ -447,7 +447,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
>  			mend   = mstart + image->segment[i].memsz - 1;
>  			if ((hole_end >= mstart) && (hole_start <= mend)) {
>  				/* Advance the hole to the end of the segment */
> -				hole_start = (mend + (size - 1)) & ~(size - 1);
> +				hole_start = ALIGN(mend, size);
>  				hole_end   = hole_start + size - 1;
>  				break;
>  			}
> -- 
> 2.43.0
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-12-13  2:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-12 14:27 [PATCH] kexec: Use ALIGN macro instead of open-coding it Yuntao Wang
2023-12-13  2:49 ` Baoquan He

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox