2021-04-13 07:43:07

by brookxu.cn

[permalink] [raw]
Subject: [RESEND PATCH 1/2] delayacct: refactor the code to simplify the implementation

From: Chunguang Xu <[email protected]>

The existing data structure is not very convenient for
expansion, and part of the code can be saved. Here, try
to optimize, which can make the code more concise and
easy to expand.

Signed-off-by: Chunguang Xu <[email protected]>
---
include/linux/delayacct.h | 139 ++++++++++++++++++++--------------------------
kernel/delayacct.c | 93 ++++++++-----------------------
2 files changed, 81 insertions(+), 151 deletions(-)

diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 2d3bdcc..33f6c84 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -2,12 +2,15 @@
/* delayacct.h - per-task delay accounting
*
* Copyright (C) Shailabh Nagar, IBM Corp. 2006
+ * Copyright (C) Chunguang Xu, Tencent Corp. 2021
*/

#ifndef _LINUX_DELAYACCT_H
#define _LINUX_DELAYACCT_H

#include <uapi/linux/taskstats.h>
+#include <linux/sched.h>
+#include <linux/slab.h>

/*
* Per-task flags relevant to delay accounting
@@ -15,71 +18,44 @@
* Used to set current->delays->flags
*/
#define DELAYACCT_PF_SWAPIN 0x00000001 /* I am doing a swapin */
-#define DELAYACCT_PF_BLKIO 0x00000002 /* I am waiting on IO */

#ifdef CONFIG_TASK_DELAY_ACCT
+
+enum delayacct_item {
+ DELAYACCT_BLKIO, /* block IO latency */
+ DELAYACCT_SWAPIN, /* swapin IO latency*/
+ DELAYACCT_THRASHING, /* pagecache thrashing IO latency*/
+ DELAYACCT_FREEPAGES, /* memory reclaim latency*/
+ DELAYACCT_NR_ITEMS
+};
+
+struct delayacct_count {
+ u64 start; /* start timestamp of XXX operation */
+ u32 count; /* incremented on every XXX operation */
+ u64 delay; /* accumulated delay time in nanoseconds */
+ u64 max; /* maximum latency of XXX operation */
+};
+
struct task_delay_info {
raw_spinlock_t lock;
unsigned int flags; /* Private per-task flags */
-
- /* For each stat XXX, add following, aligned appropriately
- *
- * struct timespec XXX_start, XXX_end;
- * u64 XXX_delay;
- * u32 XXX_count;
- *
- * Atomicity of updates to XXX_delay, XXX_count protected by
- * single lock above (split into XXX_lock if contention is an issue).
- */
-
- /*
- * XXX_count is incremented on every XXX operation, the delay
- * associated with the operation is added to XXX_delay.
- * XXX_delay contains the accumulated delay time in nanoseconds.
- */
- u64 blkio_start; /* Shared by blkio, swapin */
- u64 blkio_delay; /* wait for sync block io completion */
- u64 swapin_delay; /* wait for swapin block io completion */
- u32 blkio_count; /* total count of the number of sync block */
- /* io operations performed */
- u32 swapin_count; /* total count of the number of swapin block */
- /* io operations performed */
-
- u64 freepages_start;
- u64 freepages_delay; /* wait for memory reclaim */
-
- u64 thrashing_start;
- u64 thrashing_delay; /* wait for thrashing page */
-
- u32 freepages_count; /* total count of memory reclaim */
- u32 thrashing_count; /* total count of thrash waits */
+ struct delayacct_count delays[DELAYACCT_NR_ITEMS];
};
-#endif
-
-#include <linux/sched.h>
-#include <linux/slab.h>

-#ifdef CONFIG_TASK_DELAY_ACCT
extern int delayacct_on; /* Delay accounting turned on/off */
extern struct kmem_cache *delayacct_cache;
extern void delayacct_init(void);
extern void __delayacct_tsk_init(struct task_struct *);
-extern void __delayacct_tsk_exit(struct task_struct *);
-extern void __delayacct_blkio_start(void);
-extern void __delayacct_blkio_end(struct task_struct *);
-extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
-extern __u64 __delayacct_blkio_ticks(struct task_struct *);
-extern void __delayacct_freepages_start(void);
-extern void __delayacct_freepages_end(void);
-extern void __delayacct_thrashing_start(void);
-extern void __delayacct_thrashing_end(void);
-
-static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
+extern int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk);
+extern u64 __delayacct_blkio_ticks(struct task_struct *tsk);
+extern void __delayacct_end(struct task_delay_info *delays, int item);
+
+extern int proc_delayacct_show(struct seq_file *m, struct pid_namespace *ns,
+ struct pid *pid, struct task_struct *task);
+
+static inline void __delayacct_start(struct task_delay_info *delays, int item)
{
- if (p->delays)
- return (p->delays->flags & DELAYACCT_PF_BLKIO);
- else
- return 0;
+ delays->delays[item].start = ktime_get_ns();
}

static inline void delayacct_set_flag(int flag)
@@ -112,22 +88,7 @@ static inline void delayacct_tsk_free(struct task_struct *tsk)
tsk->delays = NULL;
}

-static inline void delayacct_blkio_start(void)
-{
- delayacct_set_flag(DELAYACCT_PF_BLKIO);
- if (current->delays)
- __delayacct_blkio_start();
-}
-
-static inline void delayacct_blkio_end(struct task_struct *p)
-{
- if (p->delays)
- __delayacct_blkio_end(p);
- delayacct_clear_flag(DELAYACCT_PF_BLKIO);
-}
-
-static inline int delayacct_add_tsk(struct taskstats *d,
- struct task_struct *tsk)
+static inline int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
{
if (!delayacct_on || !tsk->delays)
return 0;
@@ -141,31 +102,52 @@ static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
return 0;
}

+static inline void delayacct_blkio_start(void)
+{
+ if (current->delays) {
+ if (current->delays->flags & DELAYACCT_PF_SWAPIN)
+ __delayacct_start(current->delays, DELAYACCT_SWAPIN);
+ else
+ __delayacct_start(current->delays, DELAYACCT_BLKIO);
+ }
+}
+
+static inline void delayacct_blkio_end(struct task_struct *p)
+{
+ if (p->delays) {
+ if (p->delays->flags & DELAYACCT_PF_SWAPIN)
+ __delayacct_end(p->delays, DELAYACCT_SWAPIN);
+ else
+ __delayacct_end(p->delays, DELAYACCT_BLKIO);
+ }
+}
+
static inline void delayacct_freepages_start(void)
{
if (current->delays)
- __delayacct_freepages_start();
+ __delayacct_start(current->delays, DELAYACCT_FREEPAGES);
}

static inline void delayacct_freepages_end(void)
{
if (current->delays)
- __delayacct_freepages_end();
+ __delayacct_end(current->delays, DELAYACCT_FREEPAGES);
}

static inline void delayacct_thrashing_start(void)
{
if (current->delays)
- __delayacct_thrashing_start();
+ __delayacct_start(current->delays, DELAYACCT_THRASHING);
}

static inline void delayacct_thrashing_end(void)
{
if (current->delays)
- __delayacct_thrashing_end();
+ __delayacct_end(current->delays, DELAYACCT_THRASHING);
}

#else
+
static inline void delayacct_set_flag(int flag)
{}
static inline void delayacct_clear_flag(int flag)
@@ -176,17 +158,14 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
{}
static inline void delayacct_tsk_free(struct task_struct *tsk)
{}
+static inline int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
+{ return 0; }
+static inline u64 delayacct_blkio_ticks(struct task_struct *tsk)
+{ return 0; }
static inline void delayacct_blkio_start(void)
{}
static inline void delayacct_blkio_end(struct task_struct *p)
{}
-static inline int delayacct_add_tsk(struct taskstats *d,
- struct task_struct *tsk)
-{ return 0; }
-static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
-{ return 0; }
-static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
-{ return 0; }
static inline void delayacct_freepages_start(void)
{}
static inline void delayacct_freepages_end(void)
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 27725754..ec580cb 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -2,6 +2,7 @@
/* delayacct.c - per-task delay accounting
*
* Copyright (C) Shailabh Nagar, IBM Corp. 2006
+ * Copyright (C) Chunguang Xu, Tencent Corp. 2021
*/

#include <linux/sched.h>
@@ -42,48 +43,24 @@ void __delayacct_tsk_init(struct task_struct *tsk)
* Finish delay accounting for a statistic using its timestamps (@start),
* accumalator (@total) and @count
*/
-static void delayacct_end(raw_spinlock_t *lock, u64 *start, u64 *total,
- u32 *count)
+void __delayacct_end(struct task_delay_info *delays, int item)
{
- s64 ns = ktime_get_ns() - *start;
+ struct delayacct_count *delay = &delays->delays[item];
+ u64 ns = ktime_get_ns() - delay->start;
unsigned long flags;

if (ns > 0) {
- raw_spin_lock_irqsave(lock, flags);
- *total += ns;
- (*count)++;
- raw_spin_unlock_irqrestore(lock, flags);
+ raw_spin_lock_irqsave(&delays->lock, flags);
+ delay->max = max(delay->max, ns);
+ delay->delay += ns;
+ delay->count++;
+ raw_spin_unlock_irqrestore(&delays->lock, flags);
}
}

-void __delayacct_blkio_start(void)
-{
- current->delays->blkio_start = ktime_get_ns();
-}
-
-/*
- * We cannot rely on the `current` macro, as we haven't yet switched back to
- * the process being woken.
- */
-void __delayacct_blkio_end(struct task_struct *p)
-{
- struct task_delay_info *delays = p->delays;
- u64 *total;
- u32 *count;
-
- if (p->delays->flags & DELAYACCT_PF_SWAPIN) {
- total = &delays->swapin_delay;
- count = &delays->swapin_count;
- } else {
- total = &delays->blkio_delay;
- count = &delays->blkio_count;
- }
-
- delayacct_end(&delays->lock, &delays->blkio_start, total, count);
-}
-
int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
{
+ struct delayacct_count *delays = tsk->delays->delays;
u64 utime, stime, stimescaled, utimescaled;
unsigned long long t2, t3;
unsigned long flags, t1;
@@ -120,58 +97,32 @@ int __delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
/* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */

raw_spin_lock_irqsave(&tsk->delays->lock, flags);
- tmp = d->blkio_delay_total + tsk->delays->blkio_delay;
+ tmp = d->blkio_delay_total + delays[DELAYACCT_BLKIO].delay;
d->blkio_delay_total = (tmp < d->blkio_delay_total) ? 0 : tmp;
- tmp = d->swapin_delay_total + tsk->delays->swapin_delay;
+ tmp = d->swapin_delay_total + delays[DELAYACCT_SWAPIN].delay;
d->swapin_delay_total = (tmp < d->swapin_delay_total) ? 0 : tmp;
- tmp = d->freepages_delay_total + tsk->delays->freepages_delay;
+ tmp = d->freepages_delay_total + delays[DELAYACCT_FREEPAGES].delay;
d->freepages_delay_total = (tmp < d->freepages_delay_total) ? 0 : tmp;
- tmp = d->thrashing_delay_total + tsk->delays->thrashing_delay;
+ tmp = d->thrashing_delay_total + delays[DELAYACCT_THRASHING].delay;
d->thrashing_delay_total = (tmp < d->thrashing_delay_total) ? 0 : tmp;
- d->blkio_count += tsk->delays->blkio_count;
- d->swapin_count += tsk->delays->swapin_count;
- d->freepages_count += tsk->delays->freepages_count;
- d->thrashing_count += tsk->delays->thrashing_count;
+ d->blkio_count += delays[DELAYACCT_BLKIO].count;
+ d->swapin_count += delays[DELAYACCT_SWAPIN].count;
+ d->freepages_count += delays[DELAYACCT_FREEPAGES].count;
+ d->thrashing_count += delays[DELAYACCT_THRASHING].count;
raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);

return 0;
}

-__u64 __delayacct_blkio_ticks(struct task_struct *tsk)
+u64 __delayacct_blkio_ticks(struct task_struct *tsk)
{
- __u64 ret;
+ u64 ret;
unsigned long flags;

raw_spin_lock_irqsave(&tsk->delays->lock, flags);
- ret = nsec_to_clock_t(tsk->delays->blkio_delay +
- tsk->delays->swapin_delay);
+ ret = nsec_to_clock_t(tsk->delays->delays[DELAYACCT_BLKIO].delay +
+ tsk->delays->delays[DELAYACCT_SWAPIN].delay);
raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
return ret;
}

-void __delayacct_freepages_start(void)
-{
- current->delays->freepages_start = ktime_get_ns();
-}
-
-void __delayacct_freepages_end(void)
-{
- delayacct_end(
- &current->delays->lock,
- &current->delays->freepages_start,
- &current->delays->freepages_delay,
- &current->delays->freepages_count);
-}
-
-void __delayacct_thrashing_start(void)
-{
- current->delays->thrashing_start = ktime_get_ns();
-}
-
-void __delayacct_thrashing_end(void)
-{
- delayacct_end(&current->delays->lock,
- &current->delays->thrashing_start,
- &current->delays->thrashing_delay,
- &current->delays->thrashing_count);
-}
--
1.8.3.1


2021-04-13 07:43:27

by brookxu.cn

[permalink] [raw]
Subject: [RESEND PATCH 2/2] delayacct: Add a proc file to dump the delay info

From: Chunguang Xu <[email protected]>

Many distributions do not install the getdelay tool by
default, similar to task_io_accounting, adding a proc
file to make access easier.

Signed-off-by: Chunguang Xu <[email protected]>
---
fs/proc/base.c | 7 +++++++
kernel/delayacct.c | 41 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index b3422cd..4de261a 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -96,6 +96,7 @@
#include <linux/posix-timers.h>
#include <linux/time_namespace.h>
#include <linux/resctrl.h>
+#include <linux/delayacct.h>
#include <trace/events/oom.h>
#include "internal.h"
#include "fd.h"
@@ -3244,6 +3245,9 @@ static int proc_stack_depth(struct seq_file *m, struct pid_namespace *ns,
#ifdef CONFIG_TASK_IO_ACCOUNTING
ONE("io", S_IRUSR, proc_tgid_io_accounting),
#endif
+#ifdef CONFIG_TASK_DELAY_ACCT
+ ONE("delays", S_IRUSR, proc_delayacct_show),
+#endif
#ifdef CONFIG_USER_NS
REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
@@ -3583,6 +3587,9 @@ static int proc_tid_comm_permission(struct inode *inode, int mask)
#ifdef CONFIG_TASK_IO_ACCOUNTING
ONE("io", S_IRUSR, proc_tid_io_accounting),
#endif
+#ifdef CONFIG_TASK_DELAY_ACCT
+ ONE("delays", S_IRUSR, proc_delayacct_show),
+#endif
#ifdef CONFIG_USER_NS
REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index ec580cb..990af3b 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -14,6 +14,7 @@
#include <linux/sysctl.h>
#include <linux/delayacct.h>
#include <linux/module.h>
+#include <linux/seq_file.h>

int delayacct_on __read_mostly = 1; /* Delay accounting turned on/off */
EXPORT_SYMBOL_GPL(delayacct_on);
@@ -26,6 +27,18 @@ static int __init delayacct_setup_disable(char *str)
}
__setup("nodelayacct", delayacct_setup_disable);

+struct delayacct_stat {
+ const char *name;
+ unsigned int idx;
+};
+
+struct delayacct_stat delayacct_stats[] = {
+ {"blkio", DELAYACCT_BLKIO},
+ {"swapin", DELAYACCT_SWAPIN},
+ {"pagecache_thrashing", DELAYACCT_THRASHING},
+ {"mem_reclaim", DELAYACCT_FREEPAGES}
+};
+
void delayacct_init(void)
{
delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC|SLAB_ACCOUNT);
@@ -126,3 +139,31 @@ u64 __delayacct_blkio_ticks(struct task_struct *tsk)
return ret;
}

+#define K(x) ((x) / 1000)
+
+int proc_delayacct_show(struct seq_file *m, struct pid_namespace *ns,
+ struct pid *pid, struct task_struct *task)
+{
+ struct delayacct_count *delays;
+ int idx;
+
+ if (!task->delays)
+ return 0;
+
+ delays = task->delays->delays;
+ for (idx = 0; idx < ARRAY_SIZE(delayacct_stats); idx++) {
+ u32 item = delayacct_stats[idx].idx;
+ u64 mean = 0;
+
+ if (delays[item].count)
+ mean = div_u64(delays[item].delay, delays[item].count);
+
+ seq_printf(m, "%s %llu %llu %u %llu\n",
+ delayacct_stats[idx].name,
+ K(mean),
+ K(delays[item].max),
+ delays[item].count,
+ K(delays[item].delay));
+ }
+ return 0;
+}
--
1.8.3.1

2021-04-13 13:42:24

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 2/2] delayacct: Add a proc file to dump the delay info

Hi brookxu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.12-rc7 next-20210412]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 89698becf06d341a700913c3d89ce2a914af69a2
config: x86_64-randconfig-s021-20210413 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.3-280-g2cd6d34e-dirty
# https://github.com/0day-ci/linux/commit/7023a409dec95195a0e3360a36e8cb66363a9457
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
git checkout 7023a409dec95195a0e3360a36e8cb66363a9457
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)
>> kernel/delayacct.c:35:23: sparse: sparse: symbol 'delayacct_stats' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (1.70 kB)
.config.gz (36.07 kB)
Download all attachments

2021-04-13 13:42:44

by kernel test robot

[permalink] [raw]
Subject: [RFC PATCH] delayacct: delayacct_stats[] can be static


Reported-by: kernel test robot <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
---
delayacct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index b8d719fbfc404..2505aa9f87f61 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -32,7 +32,7 @@ struct delayacct_stat {
unsigned int idx;
};

-struct delayacct_stat delayacct_stats[] = {
+static struct delayacct_stat delayacct_stats[] = {
{"blkio", DELAYACCT_BLKIO},
{"swapin", DELAYACCT_SWAPIN},
{"pagecache_thrashing", DELAYACCT_THRASHING},

2021-04-14 08:35:52

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 2/2] delayacct: Add a proc file to dump the delay info

Hi brookxu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.12-rc7 next-20210413]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 89698becf06d341a700913c3d89ce2a914af69a2
config: arm-randconfig-r005-20210413 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9829f5e6b1bca9b61efc629770d28bb9014dec45)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/7023a409dec95195a0e3360a36e8cb66363a9457
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
git checkout 7023a409dec95195a0e3360a36e8cb66363a9457
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

ld.lld: warning: lld uses blx instruction, no object with architecture supporting feature detected
ld.lld: warning: lld uses blx instruction, no object with architecture supporting feature detected
>> ld.lld: error: undefined symbol: __aeabi_uldivmod
>>> referenced by delayacct.c
>>> delayacct.o:(proc_delayacct_show) in archive kernel/built-in.a
>>> referenced by delayacct.c
>>> delayacct.o:(proc_delayacct_show) in archive kernel/built-in.a
>>> referenced by delayacct.c
>>> delayacct.o:(proc_delayacct_show) in archive kernel/built-in.a
>>> did you mean: __aeabi_uidivmod
>>> defined in: arch/arm/lib/lib.a(lib1funcs.o)

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.47 kB)
.config.gz (34.88 kB)
Download all attachments

2021-04-14 09:54:15

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 1/2] delayacct: refactor the code to simplify the implementation

Hi brookxu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.12-rc7 next-20210413]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 89698becf06d341a700913c3d89ce2a914af69a2
config: x86_64-randconfig-a014-20210413 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 9829f5e6b1bca9b61efc629770d28bb9014dec45)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://github.com/0day-ci/linux/commit/37860ad48e2e1c1b332172849833ebb49802d0a8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
git checkout 37860ad48e2e1c1b332172849833ebb49802d0a8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

>> kernel/cgroup/cgroup-v1.c:730:8: error: implicit declaration of function 'delayacct_is_task_waiting_on_io' [-Werror,-Wimplicit-function-declaration]
if (delayacct_is_task_waiting_on_io(tsk))
^
1 error generated.


vim +/delayacct_is_task_waiting_on_io +730 kernel/cgroup/cgroup-v1.c

0a268dbd7932c7 Tejun Heo 2016-12-27 676
0a268dbd7932c7 Tejun Heo 2016-12-27 677 /**
0a268dbd7932c7 Tejun Heo 2016-12-27 678 * cgroupstats_build - build and fill cgroupstats
0a268dbd7932c7 Tejun Heo 2016-12-27 679 * @stats: cgroupstats to fill information into
0a268dbd7932c7 Tejun Heo 2016-12-27 680 * @dentry: A dentry entry belonging to the cgroup for which stats have
0a268dbd7932c7 Tejun Heo 2016-12-27 681 * been requested.
0a268dbd7932c7 Tejun Heo 2016-12-27 682 *
0a268dbd7932c7 Tejun Heo 2016-12-27 683 * Build and fill cgroupstats so that taskstats can export it to user
0a268dbd7932c7 Tejun Heo 2016-12-27 684 * space.
0a268dbd7932c7 Tejun Heo 2016-12-27 685 */
0a268dbd7932c7 Tejun Heo 2016-12-27 686 int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
0a268dbd7932c7 Tejun Heo 2016-12-27 687 {
0a268dbd7932c7 Tejun Heo 2016-12-27 688 struct kernfs_node *kn = kernfs_node_from_dentry(dentry);
0a268dbd7932c7 Tejun Heo 2016-12-27 689 struct cgroup *cgrp;
0a268dbd7932c7 Tejun Heo 2016-12-27 690 struct css_task_iter it;
0a268dbd7932c7 Tejun Heo 2016-12-27 691 struct task_struct *tsk;
0a268dbd7932c7 Tejun Heo 2016-12-27 692
0a268dbd7932c7 Tejun Heo 2016-12-27 693 /* it should be kernfs_node belonging to cgroupfs and is a directory */
0a268dbd7932c7 Tejun Heo 2016-12-27 694 if (dentry->d_sb->s_type != &cgroup_fs_type || !kn ||
0a268dbd7932c7 Tejun Heo 2016-12-27 695 kernfs_type(kn) != KERNFS_DIR)
0a268dbd7932c7 Tejun Heo 2016-12-27 696 return -EINVAL;
0a268dbd7932c7 Tejun Heo 2016-12-27 697
0a268dbd7932c7 Tejun Heo 2016-12-27 698 mutex_lock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 699
0a268dbd7932c7 Tejun Heo 2016-12-27 700 /*
0a268dbd7932c7 Tejun Heo 2016-12-27 701 * We aren't being called from kernfs and there's no guarantee on
0a268dbd7932c7 Tejun Heo 2016-12-27 702 * @kn->priv's validity. For this and css_tryget_online_from_dir(),
0a268dbd7932c7 Tejun Heo 2016-12-27 703 * @kn->priv is RCU safe. Let's do the RCU dancing.
0a268dbd7932c7 Tejun Heo 2016-12-27 704 */
0a268dbd7932c7 Tejun Heo 2016-12-27 705 rcu_read_lock();
e0aed7c74f0bf6 Tejun Heo 2016-12-27 706 cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
0a268dbd7932c7 Tejun Heo 2016-12-27 707 if (!cgrp || cgroup_is_dead(cgrp)) {
0a268dbd7932c7 Tejun Heo 2016-12-27 708 rcu_read_unlock();
0a268dbd7932c7 Tejun Heo 2016-12-27 709 mutex_unlock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 710 return -ENOENT;
0a268dbd7932c7 Tejun Heo 2016-12-27 711 }
0a268dbd7932c7 Tejun Heo 2016-12-27 712 rcu_read_unlock();
0a268dbd7932c7 Tejun Heo 2016-12-27 713
bc2fb7ed089ffd Tejun Heo 2017-05-15 714 css_task_iter_start(&cgrp->self, 0, &it);
0a268dbd7932c7 Tejun Heo 2016-12-27 715 while ((tsk = css_task_iter_next(&it))) {
0a268dbd7932c7 Tejun Heo 2016-12-27 716 switch (tsk->state) {
0a268dbd7932c7 Tejun Heo 2016-12-27 717 case TASK_RUNNING:
0a268dbd7932c7 Tejun Heo 2016-12-27 718 stats->nr_running++;
0a268dbd7932c7 Tejun Heo 2016-12-27 719 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 720 case TASK_INTERRUPTIBLE:
0a268dbd7932c7 Tejun Heo 2016-12-27 721 stats->nr_sleeping++;
0a268dbd7932c7 Tejun Heo 2016-12-27 722 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 723 case TASK_UNINTERRUPTIBLE:
0a268dbd7932c7 Tejun Heo 2016-12-27 724 stats->nr_uninterruptible++;
0a268dbd7932c7 Tejun Heo 2016-12-27 725 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 726 case TASK_STOPPED:
0a268dbd7932c7 Tejun Heo 2016-12-27 727 stats->nr_stopped++;
0a268dbd7932c7 Tejun Heo 2016-12-27 728 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 729 default:
0a268dbd7932c7 Tejun Heo 2016-12-27 @730 if (delayacct_is_task_waiting_on_io(tsk))
0a268dbd7932c7 Tejun Heo 2016-12-27 731 stats->nr_io_wait++;
0a268dbd7932c7 Tejun Heo 2016-12-27 732 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 733 }
0a268dbd7932c7 Tejun Heo 2016-12-27 734 }
0a268dbd7932c7 Tejun Heo 2016-12-27 735 css_task_iter_end(&it);
0a268dbd7932c7 Tejun Heo 2016-12-27 736
0a268dbd7932c7 Tejun Heo 2016-12-27 737 mutex_unlock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 738 return 0;
0a268dbd7932c7 Tejun Heo 2016-12-27 739 }
0a268dbd7932c7 Tejun Heo 2016-12-27 740

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (6.46 kB)
.config.gz (35.58 kB)
Download all attachments

2021-04-14 10:49:50

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 1/2] delayacct: refactor the code to simplify the implementation

Hi brookxu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.12-rc7 next-20210413]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 89698becf06d341a700913c3d89ce2a914af69a2
config: microblaze-randconfig-r026-20210413 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/37860ad48e2e1c1b332172849833ebb49802d0a8
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review brookxu/delayacct-refactor-the-code-to-simplify-the-implementation/20210413-093934
git checkout 37860ad48e2e1c1b332172849833ebb49802d0a8
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

kernel/cgroup/cgroup-v1.c: In function 'cgroupstats_build':
>> kernel/cgroup/cgroup-v1.c:730:8: error: implicit declaration of function 'delayacct_is_task_waiting_on_io' [-Werror=implicit-function-declaration]
730 | if (delayacct_is_task_waiting_on_io(tsk))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/delayacct_is_task_waiting_on_io +730 kernel/cgroup/cgroup-v1.c

0a268dbd7932c7 Tejun Heo 2016-12-27 676
0a268dbd7932c7 Tejun Heo 2016-12-27 677 /**
0a268dbd7932c7 Tejun Heo 2016-12-27 678 * cgroupstats_build - build and fill cgroupstats
0a268dbd7932c7 Tejun Heo 2016-12-27 679 * @stats: cgroupstats to fill information into
0a268dbd7932c7 Tejun Heo 2016-12-27 680 * @dentry: A dentry entry belonging to the cgroup for which stats have
0a268dbd7932c7 Tejun Heo 2016-12-27 681 * been requested.
0a268dbd7932c7 Tejun Heo 2016-12-27 682 *
0a268dbd7932c7 Tejun Heo 2016-12-27 683 * Build and fill cgroupstats so that taskstats can export it to user
0a268dbd7932c7 Tejun Heo 2016-12-27 684 * space.
0a268dbd7932c7 Tejun Heo 2016-12-27 685 */
0a268dbd7932c7 Tejun Heo 2016-12-27 686 int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
0a268dbd7932c7 Tejun Heo 2016-12-27 687 {
0a268dbd7932c7 Tejun Heo 2016-12-27 688 struct kernfs_node *kn = kernfs_node_from_dentry(dentry);
0a268dbd7932c7 Tejun Heo 2016-12-27 689 struct cgroup *cgrp;
0a268dbd7932c7 Tejun Heo 2016-12-27 690 struct css_task_iter it;
0a268dbd7932c7 Tejun Heo 2016-12-27 691 struct task_struct *tsk;
0a268dbd7932c7 Tejun Heo 2016-12-27 692
0a268dbd7932c7 Tejun Heo 2016-12-27 693 /* it should be kernfs_node belonging to cgroupfs and is a directory */
0a268dbd7932c7 Tejun Heo 2016-12-27 694 if (dentry->d_sb->s_type != &cgroup_fs_type || !kn ||
0a268dbd7932c7 Tejun Heo 2016-12-27 695 kernfs_type(kn) != KERNFS_DIR)
0a268dbd7932c7 Tejun Heo 2016-12-27 696 return -EINVAL;
0a268dbd7932c7 Tejun Heo 2016-12-27 697
0a268dbd7932c7 Tejun Heo 2016-12-27 698 mutex_lock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 699
0a268dbd7932c7 Tejun Heo 2016-12-27 700 /*
0a268dbd7932c7 Tejun Heo 2016-12-27 701 * We aren't being called from kernfs and there's no guarantee on
0a268dbd7932c7 Tejun Heo 2016-12-27 702 * @kn->priv's validity. For this and css_tryget_online_from_dir(),
0a268dbd7932c7 Tejun Heo 2016-12-27 703 * @kn->priv is RCU safe. Let's do the RCU dancing.
0a268dbd7932c7 Tejun Heo 2016-12-27 704 */
0a268dbd7932c7 Tejun Heo 2016-12-27 705 rcu_read_lock();
e0aed7c74f0bf6 Tejun Heo 2016-12-27 706 cgrp = rcu_dereference(*(void __rcu __force **)&kn->priv);
0a268dbd7932c7 Tejun Heo 2016-12-27 707 if (!cgrp || cgroup_is_dead(cgrp)) {
0a268dbd7932c7 Tejun Heo 2016-12-27 708 rcu_read_unlock();
0a268dbd7932c7 Tejun Heo 2016-12-27 709 mutex_unlock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 710 return -ENOENT;
0a268dbd7932c7 Tejun Heo 2016-12-27 711 }
0a268dbd7932c7 Tejun Heo 2016-12-27 712 rcu_read_unlock();
0a268dbd7932c7 Tejun Heo 2016-12-27 713
bc2fb7ed089ffd Tejun Heo 2017-05-15 714 css_task_iter_start(&cgrp->self, 0, &it);
0a268dbd7932c7 Tejun Heo 2016-12-27 715 while ((tsk = css_task_iter_next(&it))) {
0a268dbd7932c7 Tejun Heo 2016-12-27 716 switch (tsk->state) {
0a268dbd7932c7 Tejun Heo 2016-12-27 717 case TASK_RUNNING:
0a268dbd7932c7 Tejun Heo 2016-12-27 718 stats->nr_running++;
0a268dbd7932c7 Tejun Heo 2016-12-27 719 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 720 case TASK_INTERRUPTIBLE:
0a268dbd7932c7 Tejun Heo 2016-12-27 721 stats->nr_sleeping++;
0a268dbd7932c7 Tejun Heo 2016-12-27 722 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 723 case TASK_UNINTERRUPTIBLE:
0a268dbd7932c7 Tejun Heo 2016-12-27 724 stats->nr_uninterruptible++;
0a268dbd7932c7 Tejun Heo 2016-12-27 725 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 726 case TASK_STOPPED:
0a268dbd7932c7 Tejun Heo 2016-12-27 727 stats->nr_stopped++;
0a268dbd7932c7 Tejun Heo 2016-12-27 728 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 729 default:
0a268dbd7932c7 Tejun Heo 2016-12-27 @730 if (delayacct_is_task_waiting_on_io(tsk))
0a268dbd7932c7 Tejun Heo 2016-12-27 731 stats->nr_io_wait++;
0a268dbd7932c7 Tejun Heo 2016-12-27 732 break;
0a268dbd7932c7 Tejun Heo 2016-12-27 733 }
0a268dbd7932c7 Tejun Heo 2016-12-27 734 }
0a268dbd7932c7 Tejun Heo 2016-12-27 735 css_task_iter_end(&it);
0a268dbd7932c7 Tejun Heo 2016-12-27 736
0a268dbd7932c7 Tejun Heo 2016-12-27 737 mutex_unlock(&cgroup_mutex);
0a268dbd7932c7 Tejun Heo 2016-12-27 738 return 0;
0a268dbd7932c7 Tejun Heo 2016-12-27 739 }
0a268dbd7932c7 Tejun Heo 2016-12-27 740

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (6.38 kB)
.config.gz (27.43 kB)
Download all attachments

2021-04-19 07:04:54

by Balbir Singh

[permalink] [raw]
Subject: Re: [RESEND PATCH 1/2] delayacct: refactor the code to simplify the implementation

On Tue, Apr 13, 2021 at 09:37:26AM +0800, brookxu wrote:
> From: Chunguang Xu <[email protected]>
>
> The existing data structure is not very convenient for
> expansion, and part of the code can be saved. Here, try
> to optimize, which can make the code more concise and
> easy to expand.
>
> Signed-off-by: Chunguang Xu <[email protected]>

The approach seems to make sense, but the test robot has found
a few issues, can you correct those as applicable please?

Balbir Singh.

2021-04-19 09:41:06

by brookxu.cn

[permalink] [raw]
Subject: Re: [RESEND PATCH 1/2] delayacct: refactor the code to simplify the implementation



Balbir Singh wrote on 2021/4/19 15:01:
> On Tue, Apr 13, 2021 at 09:37:26AM +0800, brookxu wrote:
>> From: Chunguang Xu <[email protected]>
>>
>> The existing data structure is not very convenient for
>> expansion, and part of the code can be saved. Here, try
>> to optimize, which can make the code more concise and
>> easy to expand.
>>
>> Signed-off-by: Chunguang Xu <[email protected]>
>
> The approach seems to make sense, but the test robot has found
> a few issues, can you correct those as applicable please?

OK, i will fix it later, thanks for your reply.

> Balbir Singh.
>