[lxc-devel] [lxcfs/master] tree-wide: use {u}int64_t types
brauner on Github
lxc-bot at linuxcontainers.org
Sat Mar 14 17:05:13 UTC 2020
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 365 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200314/87304ed0/attachment.bin>
-------------- next part --------------
From 1ba088aeb1c229da69076eb15b58b7c7b8217436 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Sat, 14 Mar 2020 18:04:38 +0100
Subject: [PATCH] tree-wide: use {u}int64_t types
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/bindings.c | 8 ++++----
src/proc_cpuview.c | 12 ++++++------
src/proc_fuse.c | 24 ++++++++++++------------
src/proc_loadavg.c | 16 +++++++++-------
4 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/src/bindings.c b/src/bindings.c
index bcee24c..fb3dcb7 100644
--- a/src/bindings.c
+++ b/src/bindings.c
@@ -90,9 +90,9 @@ struct pidns_init_store {
ino_t ino; /* inode number for /proc/$pid/ns/pid */
pid_t initpid; /* the pid of nit in that ns */
int init_pidfd;
- long int ctime; /* the time at which /proc/$initpid was created */
+ int64_t ctime; /* the time at which /proc/$initpid was created */
struct pidns_init_store *next;
- long int lastcheck;
+ int64_t lastcheck;
};
/* lol - look at how they are allocated in the kernel */
@@ -216,8 +216,8 @@ static void remove_initpid(struct pidns_init_store *entry)
/* Must be called under store_lock */
static void prune_initpid_store(void)
{
- static long int last_prune = 0;
- long int now, threshold;
+ static int64_t last_prune = 0;
+ int64_t now, threshold;
if (!last_prune) {
last_prune = time(NULL);
diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c
index 15a7b5c..ed6bd77 100644
--- a/src/proc_cpuview.c
+++ b/src/proc_cpuview.c
@@ -360,7 +360,7 @@ static struct cg_proc_stat *find_or_create_proc_stat_node(struct cpuacct_usage *
static void add_cpu_usage(uint64_t *surplus, struct cpuacct_usage *usage,
uint64_t *counter, uint64_t threshold)
{
- unsigned long free_space, to_add;
+ uint64_t free_space, to_add;
free_space = threshold - usage->user - usage->system;
@@ -374,11 +374,11 @@ static void add_cpu_usage(uint64_t *surplus, struct cpuacct_usage *usage,
*surplus -= to_add;
}
-static unsigned long diff_cpu_usage(struct cpuacct_usage *older,
- struct cpuacct_usage *newer,
- struct cpuacct_usage *diff, int cpu_count)
+static uint64_t diff_cpu_usage(struct cpuacct_usage *older,
+ struct cpuacct_usage *newer,
+ struct cpuacct_usage *diff, int cpu_count)
{
- unsigned long sum = 0;
+ uint64_t sum = 0;
for (int i = 0; i < cpu_count; i++) {
if (!newer[i].online)
@@ -717,7 +717,7 @@ int cpuview_proc_stat(const char *cg, const char *cpuset,
/* revise cpu usage view to support partial cpu case. */
exact_cpus = exact_cpu_count(cg);
if (exact_cpus < (double)max_cpus){
- unsigned long delta = (unsigned long)((double)(diff_user + diff_system + diff_idle) * (1 - exact_cpus / (double)max_cpus));
+ uint64_t delta = (uint64_t)((double)(diff_user + diff_system + diff_idle) * (1 - exact_cpus / (double)max_cpus));
lxcfs_v("revising cpu usage view to match the exact cpu count [%f]\n", exact_cpus);
lxcfs_v("delta: %lu\n", delta);
diff --git a/src/proc_fuse.c b/src/proc_fuse.c
index f120eb1..406b1f4 100644
--- a/src/proc_fuse.c
+++ b/src/proc_fuse.c
@@ -350,7 +350,7 @@ static int proc_swaps_read(char *buf, size_t size, off_t offset,
}
static void get_blkio_io_value(char *str, unsigned major, unsigned minor,
- char *iotype, unsigned long *v)
+ char *iotype, uint64_t *v)
{
char *eol;
char key[32];
@@ -384,12 +384,12 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset,
__do_fclose FILE *f = NULL;
struct fuse_context *fc = fuse_get_context();
struct file_info *d = INTTYPE_TO_PTR(fi->fh);
- unsigned long read = 0, write = 0;
- unsigned long read_merged = 0, write_merged = 0;
- unsigned long read_sectors = 0, write_sectors = 0;
- unsigned long read_ticks = 0, write_ticks = 0;
- unsigned long ios_pgr = 0, tot_ticks = 0, rq_ticks = 0;
- unsigned long rd_svctm = 0, wr_svctm = 0, rd_wait = 0, wr_wait = 0;
+ uint64_t read = 0, write = 0;
+ uint64_t read_merged = 0, write_merged = 0;
+ uint64_t read_sectors = 0, write_sectors = 0;
+ uint64_t read_ticks = 0, write_ticks = 0;
+ uint64_t ios_pgr = 0, tot_ticks = 0, rq_ticks = 0;
+ uint64_t rd_svctm = 0, wr_svctm = 0, rd_wait = 0, wr_wait = 0;
char *cache = d->buf;
size_t cache_size = d->buflen;
size_t linelen = 0, total_len = 0;
@@ -747,11 +747,11 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
size_t linelen = 0, total_len = 0;
int curcpu = -1; /* cpu numbering starts at 0 */
int physcpu = 0;
- unsigned long user = 0, nice = 0, system = 0, idle = 0, iowait = 0,
- irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
- unsigned long user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0,
- iowait_sum = 0, irq_sum = 0, softirq_sum = 0,
- steal_sum = 0, guest_sum = 0, guest_nice_sum = 0;
+ uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0,
+ softirq = 0, steal = 0, guest = 0, guest_nice = 0;
+ uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0,
+ iowait_sum = 0, irq_sum = 0, softirq_sum = 0, steal_sum = 0,
+ guest_sum = 0, guest_nice_sum = 0;
char cpuall[CPUALL_MAX_SIZE];
/* reserve for cpu all */
char *cache = d->buf + CPUALL_MAX_SIZE;
diff --git a/src/proc_loadavg.c b/src/proc_loadavg.c
index e5fa6be..0a4f6d6 100644
--- a/src/proc_loadavg.c
+++ b/src/proc_loadavg.c
@@ -68,12 +68,15 @@ static int loadavg = 0;
static volatile sig_atomic_t loadavg_stop = 0;
struct load_node {
- char *cg; /*cg */
- unsigned long avenrun[3]; /* Load averages */
+ /* cgroup */
+ char *cg;
+ /* Load averages */
+ uint64_t avenrun[3];
unsigned int run_pid;
unsigned int total_pid;
unsigned int last_pid;
- int cfd; /* The file descriptor of the mounted cgroup */
+ /* The file descriptor of the mounted cgroup */
+ int cfd;
struct load_node *next;
struct load_node **pre;
};
@@ -173,7 +176,7 @@ int proc_loadavg_read(char *buf, size_t size, off_t offset,
struct load_node *n;
int hash;
int cfd;
- unsigned long a, b, c;
+ uint64_t a, b, c;
if (offset) {
int left;
@@ -362,10 +365,9 @@ static int calc_pid(char ***pid_buf, char *dpath, int depth, int sum, int cfd)
* @active: the total number of running pid at this moment.
* @exp: the fixed-point defined in the beginning.
*/
-static unsigned long calc_load(unsigned long load, unsigned long exp,
- unsigned long active)
+static uint64_t calc_load(uint64_t load, uint64_t exp, uint64_t active)
{
- unsigned long newload;
+ uint64_t newload;
active = active > 0 ? active * FIXED_1 : 0;
newload = load * exp + active * (FIXED_1 - exp);
More information about the lxc-devel
mailing list