@@ -13,14 +13,18 @@
static int loadavg_proc_show(struct seq_file *m, void *v)
{
+#if defined(CONFIG_64BIT) && (BITS_PER_LONG == 32)
+ unsigned long long avnrun[3];
+#else
unsigned long avnrun[3];
+#endif
get_avenrun(avnrun, FIXED_1/200, 0);
seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %u/%d %d\n",
- LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
- LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
- LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
+ LOAD_INT((ulong)avnrun[0]), LOAD_FRAC((ulong)avnrun[0]),
+ LOAD_INT((ulong)avnrun[1]), LOAD_FRAC((ulong)avnrun[1]),
+ LOAD_INT((ulong)avnrun[2]), LOAD_FRAC((ulong)avnrun[2]),
nr_running(), nr_threads,
idr_get_cursor(&task_active_pid_ns(current)->idr) - 1);
return 0;
@@ -13,7 +13,11 @@
* 11 bit fractions.
*/
extern unsigned long avenrun[]; /* Load averages */
+#if defined(CONFIG_64BIT) && (BITS_PER_LONG == 32)
+extern void get_avenrun(unsigned long long *loads, unsigned long offset, int shift);
+#else
extern void get_avenrun(unsigned long *loads, unsigned long offset, int shift);
+#endif
#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
@@ -5,6 +5,25 @@
#include <linux/types.h>
#define SI_LOAD_SHIFT 16
+
+#if (__riscv_xlen == 64) && (__BITS_PER_LONG == 32)
+struct sysinfo {
+ __s64 uptime; /* Seconds since boot */
+ __u64 loads[3]; /* 1, 5, and 15 minute load averages */
+ __u64 totalram; /* Total usable main memory size */
+ __u64 freeram; /* Available memory size */
+ __u64 sharedram; /* Amount of shared memory */
+ __u64 bufferram; /* Memory used by buffers */
+ __u64 totalswap; /* Total swap space size */
+ __u64 freeswap; /* swap space still available */
+ __u16 procs; /* Number of current processes */
+ __u16 pad; /* Explicit padding for m68k */
+ __u64 totalhigh; /* Total high memory size */
+ __u64 freehigh; /* Available high memory size */
+ __u32 mem_unit; /* Memory unit size in bytes */
+ char _f[20-2*sizeof(__u64)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
+};
+#else
struct sysinfo {
__kernel_long_t uptime; /* Seconds since boot */
__kernel_ulong_t loads[3]; /* 1, 5, and 15 minute load averages */
@@ -21,5 +40,6 @@ struct sysinfo {
__u32 mem_unit; /* Memory unit size in bytes */
char _f[20-2*sizeof(__kernel_ulong_t)-sizeof(__u32)]; /* Padding: libc5 uses this.. */
};
+#endif
#endif /* _LINUX_SYSINFO_H */
@@ -68,7 +68,11 @@ EXPORT_SYMBOL(avenrun); /* should be removed */
*
* These values are estimates at best, so no need for locking.
*/
+#if defined(CONFIG_64BIT) && (BITS_PER_LONG == 32)
+void get_avenrun(unsigned long long *loads, unsigned long offset, int shift)
+#else
void get_avenrun(unsigned long *loads, unsigned long offset, int shift)
+#endif
{
loads[0] = (avenrun[0] + offset) << shift;
loads[1] = (avenrun[1] + offset) << shift;