Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142179400
D38312.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D38312.diff
View Options
diff --git a/stand/kboot/arch/aarch64/load_addr.c b/stand/kboot/arch/aarch64/load_addr.c
--- a/stand/kboot/arch/aarch64/load_addr.c
+++ b/stand/kboot/arch/aarch64/load_addr.c
@@ -143,45 +143,12 @@
return false;
}
-uint64_t commit_limit;
-uint64_t committed_as;
-uint64_t mem_avail;
-
bool
enumerate_memory_arch(void)
{
int fd = -1;
- char buf[128];
bool rv;
- /*
- * To properly size the slabs, we need to find how much memory we can
- * commit to using. commit_limit is the max, while commited_as is the
- * current total. We can use these later to allocate the largetst amount
- * of memory possible so we can support larger ram disks than we could
- * by using fixed segment sizes. We also grab the memory available so
- * we don't use more than 49% of that.
- */
- fd = open("host:/proc/meminfo", O_RDONLY);
- if (fd != -1) {
- while (fgetstr(buf, sizeof(buf), fd) > 0) {
- if (strncmp(buf, "MemAvailable:", 13) == 0) {
- mem_avail = strtoll(buf + 13, NULL, 0);
- mem_avail <<= 10; /* Units are kB */
- } else if (strncmp(buf, "CommitLimit:", 12) == 0) {
- commit_limit = strtoll(buf + 13, NULL, 0);
- commit_limit <<= 10; /* Units are kB */
- } else if (strncmp(buf, "Committed_AS:", 13) == 0) {
- committed_as = strtoll(buf + 14, NULL, 0);
- committed_as <<= 10; /* Units are kB */
- }
- }
- }
- printf("Commit limit: %lld Committed bytes %lld Available %lld\n",
- (long long)commit_limit, (long long)committed_as,
- (long long)mem_avail);
- close(fd);
-
fd = open("host:/sys/firmware/fdt", O_RDONLY);
if (fd != -1) {
rv = do_memory_from_fdt(fd);
diff --git a/stand/kboot/main.c b/stand/kboot/main.c
--- a/stand/kboot/main.c
+++ b/stand/kboot/main.c
@@ -54,6 +54,45 @@
static vm_offset_t padding;
static vm_offset_t offset;
+uint64_t commit_limit;
+uint64_t committed_as;
+uint64_t mem_avail;
+
+static void
+memory_limits(void)
+{
+ int fd;
+ char buf[128];
+
+ /*
+ * To properly size the slabs, we need to find how much memory we can
+ * commit to using. commit_limit is the max, while commited_as is the
+ * current total. We can use these later to allocate the largetst amount
+ * of memory possible so we can support larger ram disks than we could
+ * by using fixed segment sizes. We also grab the memory available so
+ * we don't use more than 49% of that.
+ */
+ fd = open("host:/proc/meminfo", O_RDONLY);
+ if (fd != -1) {
+ while (fgetstr(buf, sizeof(buf), fd) > 0) {
+ if (strncmp(buf, "MemAvailable:", 13) == 0) {
+ mem_avail = strtoll(buf + 13, NULL, 0);
+ mem_avail <<= 10; /* Units are kB */
+ } else if (strncmp(buf, "CommitLimit:", 12) == 0) {
+ commit_limit = strtoll(buf + 13, NULL, 0);
+ commit_limit <<= 10; /* Units are kB */
+ } else if (strncmp(buf, "Committed_AS:", 13) == 0) {
+ committed_as = strtoll(buf + 14, NULL, 0);
+ committed_as <<= 10; /* Units are kB */
+ }
+ }
+ }
+ printf("Commit limit: %lld Committed bytes %lld Available %lld\n",
+ (long long)commit_limit, (long long)committed_as,
+ (long long)mem_avail);
+ close(fd);
+}
+
/*
* NB: getdev should likely be identical to this most places, except maybe
* we should move to storing the length of the platform devdesc.
@@ -218,6 +257,7 @@
setenv("LINES", "24", 1);
+ memory_limits();
enumerate_memory_arch();
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Jan 17, 9:22 PM (13 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27699412
Default Alt Text
D38312.diff (3 KB)
Attached To
Mode
D38312: kboot: Move discovery of memory limits to main.c
Attached
Detach File
Event Timeline
Log In to Comment