linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line
@ 2021-06-02  8:47 Max Gurtovoy
  2021-06-02  8:47 ` [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span Max Gurtovoy
  2021-06-02  8:59 ` [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line David Hildenbrand
  0 siblings, 2 replies; 4+ messages in thread
From: Max Gurtovoy @ 2021-06-02  8:47 UTC (permalink / raw)
  To: akpm, linux-mm; +Cc: pasha.tatashin, linux-kernel, logang, Max Gurtovoy

The "if" clause can fit to one line. Also while we're here, fix the end
pfn print (use %#lx instead of #%lx).

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 mm/memory_hotplug.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 70620d0dd923..8c3b423c1141 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -288,10 +288,9 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
 		min_align = PAGES_PER_SUBSECTION;
 	else
 		min_align = PAGES_PER_SECTION;
-	if (!IS_ALIGNED(pfn, min_align)
-			|| !IS_ALIGNED(nr_pages, min_align)) {
-		WARN(1, "Misaligned __%s_pages start: %#lx end: #%lx\n",
-				reason, pfn, pfn + nr_pages - 1);
+	if (!IS_ALIGNED(pfn, min_align) || !IS_ALIGNED(nr_pages, min_align)) {
+		WARN(1, "Misaligned __%s_pages start: %#lx end: %#lx\n",
+		     reason, pfn, pfn + nr_pages - 1);
 		return -EINVAL;
 	}
 	return 0;
-- 
2.18.1


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

* [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span
  2021-06-02  8:47 [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line Max Gurtovoy
@ 2021-06-02  8:47 ` Max Gurtovoy
  2021-06-02  9:01   ` David Hildenbrand
  2021-06-02  8:59 ` [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line David Hildenbrand
  1 sibling, 1 reply; 4+ messages in thread
From: Max Gurtovoy @ 2021-06-02  8:47 UTC (permalink / raw)
  To: akpm, linux-mm; +Cc: pasha.tatashin, linux-kernel, logang, Max Gurtovoy

The warning only prints the start and end pfns. Add min_align to the
warning print to add more info regarding the failure.

Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 mm/memory_hotplug.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 8c3b423c1141..9e86e9ee0a10 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -289,8 +289,8 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
 	else
 		min_align = PAGES_PER_SECTION;
 	if (!IS_ALIGNED(pfn, min_align) || !IS_ALIGNED(nr_pages, min_align)) {
-		WARN(1, "Misaligned __%s_pages start: %#lx end: %#lx\n",
-		     reason, pfn, pfn + nr_pages - 1);
+		WARN(1, "Misaligned __%s_pages min_align: %#lx start: %#lx end: %#lx\n",
+		     reason, min_align, pfn, pfn + nr_pages - 1);
 		return -EINVAL;
 	}
 	return 0;
-- 
2.18.1


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

* Re: [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line
  2021-06-02  8:47 [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line Max Gurtovoy
  2021-06-02  8:47 ` [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span Max Gurtovoy
@ 2021-06-02  8:59 ` David Hildenbrand
  1 sibling, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2021-06-02  8:59 UTC (permalink / raw)
  To: Max Gurtovoy, akpm, linux-mm; +Cc: pasha.tatashin, linux-kernel, logang

On 02.06.21 10:47, Max Gurtovoy wrote:
> The "if" clause can fit to one line. Also while we're here, fix the end
> pfn print (use %#lx instead of #%lx).
> 

I think the subject could be more expressive. I'd suggest

"mm,memory_hotplug: cleanup alignment checks in check_pfn_span"


Reviewed-by: David Hildenbrand <david@redhat.com>

> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
> ---
>   mm/memory_hotplug.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 70620d0dd923..8c3b423c1141 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -288,10 +288,9 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
>   		min_align = PAGES_PER_SUBSECTION;
>   	else
>   		min_align = PAGES_PER_SECTION;
> -	if (!IS_ALIGNED(pfn, min_align)
> -			|| !IS_ALIGNED(nr_pages, min_align)) {
> -		WARN(1, "Misaligned __%s_pages start: %#lx end: #%lx\n",
> -				reason, pfn, pfn + nr_pages - 1);
> +	if (!IS_ALIGNED(pfn, min_align) || !IS_ALIGNED(nr_pages, min_align)) {
> +		WARN(1, "Misaligned __%s_pages start: %#lx end: %#lx\n",
> +		     reason, pfn, pfn + nr_pages - 1);
>   		return -EINVAL;
>   	}
>   	return 0;
> 


-- 
Thanks,

David / dhildenb


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

* Re: [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span
  2021-06-02  8:47 ` [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span Max Gurtovoy
@ 2021-06-02  9:01   ` David Hildenbrand
  0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2021-06-02  9:01 UTC (permalink / raw)
  To: Max Gurtovoy, akpm, linux-mm; +Cc: pasha.tatashin, linux-kernel, logang

On 02.06.21 10:47, Max Gurtovoy wrote:
> The warning only prints the start and end pfns. Add min_align to the
> warning print to add more info regarding the failure.
> 
> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
> ---
>   mm/memory_hotplug.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 8c3b423c1141..9e86e9ee0a10 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -289,8 +289,8 @@ static int check_pfn_span(unsigned long pfn, unsigned long nr_pages,
>   	else
>   		min_align = PAGES_PER_SECTION;
>   	if (!IS_ALIGNED(pfn, min_align) || !IS_ALIGNED(nr_pages, min_align)) {
> -		WARN(1, "Misaligned __%s_pages start: %#lx end: %#lx\n",
> -		     reason, pfn, pfn + nr_pages - 1);
> +		WARN(1, "Misaligned __%s_pages min_align: %#lx start: %#lx end: %#lx\n",
> +		     reason, min_align, pfn, pfn + nr_pages - 1);
>   		return -EINVAL;
>   	}
>   	return 0;
> 

Not sure if we really care. I expect only developers will run into that 
hacking on something new, and they will have to dig deeper either way.

While at it, I'd suggest converting this to pr_warn(), as WARN() is 
frowned upon as it can crash the kernel with panic_on_warn as set by 
some distros.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


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

end of thread, other threads:[~2021-06-02  9:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02  8:47 [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line Max Gurtovoy
2021-06-02  8:47 ` [PATCH 2/2] mm,memory_hotplug: print the min alignment in check_pfn_span Max Gurtovoy
2021-06-02  9:01   ` David Hildenbrand
2021-06-02  8:59 ` [PATCH 1/2] mm,memory_hotplug: align code to fit 80 characters per line David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).