Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Eric DeVolder <eric.devolder@oracle.com>
To: kexec@lists.infradead.org
Cc: boris.ostrovsky@oracle.com, eric.devolder@oracle.com
Subject: [PATCH v1 4/7] kexec: create get_nr_cpus()
Date: Thu, 20 Oct 2022 13:03:41 -0400	[thread overview]
Message-ID: <20221020170344.1962-5-eric.devolder@oracle.com> (raw)
In-Reply-To: <20221020170344.1962-1-eric.devolder@oracle.com>

From existing code, create function get_nr_cpus(). This function,
will be referenced from multiple locations.

No functional changes.

Signed-off-by: Eric DeVolder <eric.devolder@oracle.com>
---
 kexec/crashdump-elf.c |  6 +-----
 kexec/crashdump.h     |  1 -
 kexec/kexec-xen.h     |  1 +
 kexec/kexec.c         | 11 +++++++++++
 kexec/kexec.h         |  2 ++
 5 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index b8bb686..5e29f7a 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -43,11 +43,7 @@ int FUNC(struct kexec_info *info,
 	int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
 	long int count_cpu;
 
-	if (xen_present())
-		nr_cpus = xen_get_nr_phys_cpus();
-	else
-		nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
-
+	nr_cpus = get_nr_cpus();
 	if (nr_cpus < 0) {
 		return -1;
 	}
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 18bd691..28d3278 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -57,7 +57,6 @@ unsigned long phys_to_virt(struct crash_elf_info *elf_info,
 			   unsigned long long paddr);
 
 unsigned long xen_architecture(struct crash_elf_info *elf_info);
-int xen_get_nr_phys_cpus(void);
 int xen_get_note(int cpu, uint64_t *addr, uint64_t *len);
 int xen_get_crashkernel_region(uint64_t *start, uint64_t *end);
 
diff --git a/kexec/kexec-xen.h b/kexec/kexec-xen.h
index 70fb576..f54a2dd 100644
--- a/kexec/kexec-xen.h
+++ b/kexec/kexec-xen.h
@@ -83,5 +83,6 @@ extern int __xc_interface_close(xc_interface *xch);
 #endif
 
 int xen_get_kexec_range(int range, uint64_t *start, uint64_t *end);
+int xen_get_nr_phys_cpus(void);
 
 #endif /* KEXEC_XEN_H */
diff --git a/kexec/kexec.c b/kexec/kexec.c
index 90f2e71..d2379cb 100644
--- a/kexec/kexec.c
+++ b/kexec/kexec.c
@@ -490,6 +490,17 @@ static int add_backup_segments(struct kexec_info *info,
 	return 0;
 }
 
+long int get_nr_cpus(void)
+{
+	long int nr_cpus;
+
+	if (xen_present())
+		nr_cpus = xen_get_nr_phys_cpus();
+	else
+		nr_cpus = sysconf(_SC_NPROCESSORS_CONF);
+	return nr_cpus;
+}
+
 static char *slurp_fd(int fd, const char *filename, off_t size, off_t *nread)
 {
 	char *buf;
diff --git a/kexec/kexec.h b/kexec/kexec.h
index 9a26065..9675e79 100644
--- a/kexec/kexec.h
+++ b/kexec/kexec.h
@@ -294,6 +294,8 @@ extern unsigned long add_buffer_phys_virt(struct kexec_info *info,
 	int buf_end, int phys);
 extern void arch_reuse_initrd(void);
 
+extern long int get_nr_cpus(void);
+
 extern int ifdown(void);
 
 extern int do_hotplug;
-- 
2.31.1


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

  parent reply	other threads:[~2022-10-20 17:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 17:03 [PATCH v1 0/7] crashdump: Kernel handling of CPU and memory hot un/plug Eric DeVolder
2022-10-20 17:03 ` [PATCH v1 1/7] crashdump: introduce the --hotplug option Eric DeVolder
2022-10-20 17:03 ` [PATCH v1 2/7] crashdump: exclude elfcorehdr segment from digest for hotplug Eric DeVolder
2022-10-20 17:03 ` [PATCH v1 3/7] crashdump/x86: identify elfcorehdr segment " Eric DeVolder
2022-10-20 17:03 ` Eric DeVolder [this message]
2022-10-20 17:03 ` [PATCH v1 5/7] crashdump: introduce --elfcorehdrsz option Eric DeVolder
2022-10-20 17:03 ` [PATCH v1 6/7] crashdump: create get_elfcorehdrsz() Eric DeVolder
2022-10-20 17:03 ` [PATCH v1 7/7] crashdump/x86: utilize get_elfcorehdrsz() Eric DeVolder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221020170344.1962-5-eric.devolder@oracle.com \
    --to=eric.devolder@oracle.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=kexec@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox