diff mbox series

[v2,3/4] x86/PCI: Tidy E820 removal messages

Message ID 20221208190341.1560157-4-helgaas@kernel.org
State New
Headers show
Series PCI: Continue E820 vs host bridge window saga | expand

Commit Message

Bjorn Helgaas Dec. 8, 2022, 7:03 p.m. UTC
From: Bjorn Helgaas <bhelgaas@google.com>

These messages:

  clipped [mem size 0x00000000 64bit] to [mem size 0xfffffffffffa0000 64bit] for e820 entry [mem 0x0009f000-0x000fffff]

aren't as useful as they could be because (a) the resource is often
IORESOURCE_UNSET, so we print the size instead of the start/end and (b) we
print the available resource even if it is empty after removing the E820
entry.

Print the available space by hand to avoid the IORESOURCE_UNSET problem and
only if it's non-empty.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Hans de Goede <hdegoede@redhat.com>
---
 arch/x86/kernel/resource.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko Dec. 9, 2022, 6:42 p.m. UTC | #1
On Thu, Dec 08, 2022 at 01:03:40PM -0600, Bjorn Helgaas wrote:
> From: Bjorn Helgaas <bhelgaas@google.com>
> 
> These messages:
> 
>   clipped [mem size 0x00000000 64bit] to [mem size 0xfffffffffffa0000 64bit] for e820 entry [mem 0x0009f000-0x000fffff]
> 
> aren't as useful as they could be because (a) the resource is often
> IORESOURCE_UNSET, so we print the size instead of the start/end and (b) we
> print the available resource even if it is empty after removing the E820
> entry.
> 
> Print the available space by hand to avoid the IORESOURCE_UNSET problem and
> only if it's non-empty.  No functional change intended.

...

> +			if (avail->end > avail->start)
> +				pr_info("resource: remaining [mem %#010llx-%#010llx] available\n",
> +					(unsigned long long) avail->start,
> +					(unsigned long long) avail->end);

Is there any point why we do not use %pa for resource_size_t parameters?
Bjorn Helgaas Dec. 9, 2022, 8:34 p.m. UTC | #2
On Fri, Dec 09, 2022 at 08:42:06PM +0200, Andy Shevchenko wrote:
> On Thu, Dec 08, 2022 at 01:03:40PM -0600, Bjorn Helgaas wrote:
> > From: Bjorn Helgaas <bhelgaas@google.com>
> > 
> > These messages:
> > 
> >   clipped [mem size 0x00000000 64bit] to [mem size 0xfffffffffffa0000 64bit] for e820 entry [mem 0x0009f000-0x000fffff]
> > 
> > aren't as useful as they could be because (a) the resource is often
> > IORESOURCE_UNSET, so we print the size instead of the start/end and (b) we
> > print the available resource even if it is empty after removing the E820
> > entry.
> > 
> > Print the available space by hand to avoid the IORESOURCE_UNSET problem and
> > only if it's non-empty.  No functional change intended.
> 
> ...
> 
> > +			if (avail->end > avail->start)
> > +				pr_info("resource: remaining [mem %#010llx-%#010llx] available\n",
> > +					(unsigned long long) avail->start,
> > +					(unsigned long long) avail->end);
> 
> Is there any point why we do not use %pa for resource_size_t parameters?

Only my ignorance :)  Thanks for pointing that out; I changed it to
this and added a comment about why:


--- a/arch/x86/kernel/resource.c
+++ b/arch/x86/kernel/resource.c
@@ -42,8 +42,16 @@ static void remove_e820_regions(struct resource *avail)
 
 		resource_clip(avail, e820_start, e820_end);
 		if (orig.start != avail->start || orig.end != avail->end) {
-			pr_info("clipped %pR to %pR for e820 entry [mem %#010Lx-%#010Lx]\n",
-				 &orig, avail, e820_start, e820_end);
+			pr_info("resource: avoiding allocation from e820 entry [mem %#010Lx-%#010Lx]\n",
+				e820_start, e820_end);
+			if (avail->end > avail->start)
+				/*
+				 * Use %pa instead of %pR because "avail"
+				 * is typically IORESOURCE_UNSET, so %pR
+				 * shows the size instead of addresses.
+				 */
+				pr_info("resource: remaining [mem %pa-%pa] available\n",
+					&avail->start, &avail->end);
 			orig = *avail;
 		}
 	}
Andy Shevchenko Dec. 9, 2022, 9:33 p.m. UTC | #3
On Fri, Dec 09, 2022 at 02:34:28PM -0600, Bjorn Helgaas wrote:
> On Fri, Dec 09, 2022 at 08:42:06PM +0200, Andy Shevchenko wrote:
> > On Thu, Dec 08, 2022 at 01:03:40PM -0600, Bjorn Helgaas wrote:

...

> > > +			if (avail->end > avail->start)
> > > +				pr_info("resource: remaining [mem %#010llx-%#010llx] available\n",
> > > +					(unsigned long long) avail->start,
> > > +					(unsigned long long) avail->end);
> > 
> > Is there any point why we do not use %pa for resource_size_t parameters?
> 
> Only my ignorance :)  Thanks for pointing that out; I changed it to
> this and added a comment about why:

> +			pr_info("resource: avoiding allocation from e820 entry [mem %#010Lx-%#010Lx]\n",
> +				e820_start, e820_end);
> +			if (avail->end > avail->start)
> +				/*
> +				 * Use %pa instead of %pR because "avail"
> +				 * is typically IORESOURCE_UNSET, so %pR
> +				 * shows the size instead of addresses.
> +				 */
> +				pr_info("resource: remaining [mem %pa-%pa] available\n",
> +					&avail->start, &avail->end);

LGTM, thanks!
diff mbox series

Patch

diff --git a/arch/x86/kernel/resource.c b/arch/x86/kernel/resource.c
index bba1abd05bfe..7543a13c8520 100644
--- a/arch/x86/kernel/resource.c
+++ b/arch/x86/kernel/resource.c
@@ -42,8 +42,12 @@  static void remove_e820_regions(struct resource *avail)
 
 		resource_clip(avail, e820_start, e820_end);
 		if (orig.start != avail->start || orig.end != avail->end) {
-			pr_info("clipped %pR to %pR for e820 entry [mem %#010Lx-%#010Lx]\n",
-				 &orig, avail, e820_start, e820_end);
+			pr_info("resource: avoiding allocation from e820 entry [mem %#010Lx-%#010Lx]\n",
+				e820_start, e820_end);
+			if (avail->end > avail->start)
+				pr_info("resource: remaining [mem %#010llx-%#010llx] available\n",
+					(unsigned long long) avail->start,
+					(unsigned long long) avail->end);
 			orig = *avail;
 		}
 	}