[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 1/6] xen/arm: Skip initializing the BSS section when it is empty


  • To: Frediano Ziglio <frediano.ziglio@xxxxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
  • From: Ayan Kumar Halder <ayankuma@xxxxxxx>
  • Date: Thu, 10 Oct 2024 18:29:16 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TTw36t781ixUbjMP6yGLs7cl7133CZnMldR3pg86t7o=; b=pMD3w6WViS1h7oW2EFkEjBQeulNekMsTsU6/fmrdpeWjkUs280h/m0DH2BOiHN7CPsrgi9Aoq6ETu/QfGr/ezbBB6QUMIP04suS7QxRu9AsQAe/Tc1+dWZ26QUGN+5+RFkiUnat//PF33MiPgUv4gDrgOzAkKWjhOokCQJ93b1GDTl12Nd6TGV6+qQBmb/1rE76z1jgH2vTuVd9lS1G2KW4r7xB0MfrfB4Tg29OAl9m00PpyPFulMmdTg6zGld2gktUZycE6+sphpL2CfJ8aAvJuDNe3bm4fOny6VA4KU4Q/02GMX2+wpeLZierXEJTw7YuXlLa45vdaxkHl/mD35Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ouEuaaKEDSVvphgpcIVvO2FLLXFQufCQuha/GGBpViVEO1C7etC8PA+j1yOGh4Cx1Mx061t05E8ZGdZwOtUnfDVDfLXJ/k4xwtL2ODOa5tEMhT7f+xHIBYZesXpn2UUab+bkZx9uI2qlh3+Tpj2IKzQhkvih4+4zSb5AiAm5Lf2+BGDS781IfhsyxGZQKO9cRUhdc8BI1zgz4MAAvjlpxxmjj9gE6IOP7JbDVibke7picKnAkCYwqh1YWSexM14aAUiwPL4Czk6WnzBYcOMopglBw7AJCwpeRfTPGYxcxiXnvpDsWlHQM8Z8cAPcxR6WI2WjuLjX9j3PVbTlIZ8m6Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 10 Oct 2024 17:29:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Frediano,

Appreciate your feedback.

On 10/10/2024 15:43, Frediano Ziglio wrote:
On Thu, Oct 10, 2024 at 3:05 PM Ayan Kumar Halder
<ayan.kumar.halder@xxxxxxx> wrote:
If the BSS section is empty, then the function can just return.

Signed-off-by: Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>
---
Changes from :-

v1..v2 - New patch introduced in v3.

  xen/arch/arm/arm64/head.S | 2 ++
  1 file changed, 2 insertions(+)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 14c3720d80..72c7b24498 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -346,6 +346,8 @@ FUNC_LOCAL(zero_bss)
          PRINT("- Zero BSS -\r\n")
          ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
          ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
+        cmp   x1, x0
+        beq   skip_bss

  1:      str   xzr, [x0], #8
          cmp   x0, x1
Why not just transforming the "do while" loop into a "while" one and
just jump to cmp?

Something like (not tested)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 14c3720d80..987f243578 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -346,9 +346,10 @@ FUNC_LOCAL(zero_bss)
         PRINT("- Zero BSS -\r\n")
         ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
         ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end)   */
+        b     2f

1:      str   xzr, [x0], #8
-        cmp   x0, x1
+2:      cmp   x0, x1
         b.lo  1b

I am not really sure if this implementation is better than the previous one. The drawback of my implementation is that we have an extra 'cmp' instruction. The drawback of this implementation is that we need an extra label and there is an un-conditional branch after ldr (readability is difficult). May be I am biased. :)

How does this look ?

FUNC_LOCAL(zero_bss)
        /* Zero BSS only when requested */
        cbnz  x26, skip_bss

        PRINT("- Zero BSS -\r\n")
        ldr   x0, =__bss_start       /* x0 := vaddr(__bss_start) */
        ldr   x1, =__bss_end         /* x1 := vaddr(__bss_end) */
1:     cmp   x1, x0
        beq   skip_bss

        str   xzr, [x0], #8
        b     1b

skip_bss:
        ret
END(zero_bss)

- Ayan





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.