2023-10-08 10:50:00

by 许春光

[permalink] [raw]
Subject: [PATCH 0/3] delayacct: optimization & code simplify

From: Chunguang Xu <[email protected]>

Since in some scenarios we still want to get the task delayacct
through taskstats, so commit <0cd7c741f01de> introduces a sysctl to
enable it dynamically. However, since task->delays is allocated
during fork(), task->delays will not be reallocated when delayacct
is enabled later. This will make we cannot get the delayacct of old
tasks, but the new tasks cans. This can easily lead to confusion.
Therefore, try to workaround this issue by convert task->delays to
an object, just like sched_statistics. Besides, try to simplify the
code of delayacct.

Chunguang Xu (3):
delayacct: introduce delayacct_enabled() to simplify implement
delayacct: convert task->delays to a object
delayacct: remove delayacct_on to simplify the code

include/linux/delayacct.h | 83 +++++-------------------
include/linux/sched.h | 3 +-
kernel/delayacct.c | 129 ++++++++++++++++++--------------------
kernel/fork.c | 7 +--
4 files changed, 81 insertions(+), 141 deletions(-)

--
2.25.1


2023-10-08 10:50:11

by 许春光

[permalink] [raw]
Subject: [PATCH 1/3] delayacct: introduce delayacct_enabled() to simplify implement

From: Chunguang Xu <[email protected]>

Introduce delayacct_enabled() to simplify the code and make it
more concise.

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

diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 6639f48dac36..660e534ce7c4 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -94,137 +94,103 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
__delayacct_tsk_init(tsk);
}

+static inline bool delayacct_enabled(void)
+{
+ return static_branch_unlikely(&delayacct_key);
+}
+
/* Free tsk->delays. Called from bad fork and __put_task_struct
* where there's no risk of tsk->delays being accessed elsewhere
*/
static inline void delayacct_tsk_free(struct task_struct *tsk)
{
- if (tsk->delays)
+ if (delayacct_enabled())
kmem_cache_free(delayacct_cache, tsk->delays);
tsk->delays = NULL;
}

static inline void delayacct_blkio_start(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_blkio_start();
}

static inline void delayacct_blkio_end(struct task_struct *p)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (p->delays)
+ if (delayacct_enabled())
__delayacct_blkio_end(p);
}

static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
{
- if (tsk->delays)
+ if (delayacct_enabled())
return __delayacct_blkio_ticks(tsk);
return 0;
}

static inline void delayacct_freepages_start(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_freepages_start();
}

static inline void delayacct_freepages_end(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_freepages_end();
}

static inline void delayacct_thrashing_start(bool *in_thrashing)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_thrashing_start(in_thrashing);
}

static inline void delayacct_thrashing_end(bool *in_thrashing)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_thrashing_end(in_thrashing);
}

static inline void delayacct_swapin_start(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_swapin_start();
}

static inline void delayacct_swapin_end(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_swapin_end();
}

static inline void delayacct_compact_start(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_compact_start();
}

static inline void delayacct_compact_end(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_compact_end();
}

static inline void delayacct_wpcopy_start(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_wpcopy_start();
}

static inline void delayacct_wpcopy_end(void)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (current->delays)
+ if (delayacct_enabled())
__delayacct_wpcopy_end();
}

static inline void delayacct_irq(struct task_struct *task, u32 delta)
{
- if (!static_branch_unlikely(&delayacct_key))
- return;
-
- if (task->delays)
+ if (delayacct_enabled())
__delayacct_irq(task, delta);
}

diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 6f0c358e73d8..ce10b7c1ee43 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -161,7 +161,7 @@ int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
d->cpu_run_virtual_total =
(tmp < (s64)d->cpu_run_virtual_total) ? 0 : tmp;

- if (!tsk->delays)
+ if (!delayacct_enabled())
return 0;

/* zero XXX_total, non-zero XXX_count implies XXX stat overflowed */
--
2.25.1

2023-10-08 10:50:25

by 许春光

[permalink] [raw]
Subject: [PATCH 3/3] delayacct: remove delayacct_on to simplify the code

From: Chunguang Xu <[email protected]>

Seems delayacct_on can be removed, so try to do it
to simplify the code.

Signed-off-by: Chunguang Xu <[email protected]>
---
include/linux/delayacct.h | 1 -
kernel/delayacct.c | 14 ++++----------
2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 2f1dc6688a2f..caa7564a1a52 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -64,7 +64,6 @@ struct task_delay_info {

#ifdef CONFIG_TASK_DELAY_ACCT
DECLARE_STATIC_KEY_FALSE(delayacct_key);
-extern int delayacct_on; /* Delay accounting turned on/off */
extern void delayacct_init(void);

extern void __delayacct_tsk_init(struct task_struct *);
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index 1a6b1d3e80af..397b36adb634 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -15,22 +15,18 @@
#include <linux/module.h>

DEFINE_STATIC_KEY_FALSE(delayacct_key);
-int delayacct_on __read_mostly; /* Delay accounting turned on/off */

static void set_delayacct(bool enabled)
{
- if (enabled) {
+ if (enabled)
static_branch_enable(&delayacct_key);
- delayacct_on = 1;
- } else {
- delayacct_on = 0;
+ else
static_branch_disable(&delayacct_key);
- }
}

static int __init delayacct_setup_enable(char *str)
{
- delayacct_on = 1;
+ set_delayacct(true);
return 1;
}
__setup("delayacct", delayacct_setup_enable);
@@ -38,16 +34,14 @@ __setup("delayacct", delayacct_setup_enable);
void delayacct_init(void)
{
delayacct_tsk_init(&init_task);
- set_delayacct(delayacct_on);
}

#ifdef CONFIG_PROC_SYSCTL
static int sysctl_delayacct(struct ctl_table *table, int write, void *buffer,
size_t *lenp, loff_t *ppos)
{
- int state = delayacct_on;
struct ctl_table t;
- int err;
+ int err, state;

if (write && !capable(CAP_SYS_ADMIN))
return -EPERM;
--
2.25.1

2023-10-08 10:50:27

by 许春光

[permalink] [raw]
Subject: [PATCH 2/3] delayacct: convert task->delays to a object

From: Chunguang Xu <[email protected]>

Since in some scenarios we still want to get the task delayacct
through taskstats, so commit <0cd7c741f01de> introduces a sysctl to
enable it dynamically. However, since task->delays is allocated
during fork(), task->delays will not be reallocated when delayacct
is enabled later. This will make we cannot get the delayacct of old
tasks, but the new tasks cans. This can easily lead to confusion.
Therefore, try to workaround this issue by convert task->delays to
an object.

Signed-off-by: Chunguang Xu <[email protected]>
---
include/linux/delayacct.h | 16 +-----
include/linux/sched.h | 3 +-
kernel/delayacct.c | 113 +++++++++++++++++++-------------------
kernel/fork.c | 7 +--
4 files changed, 60 insertions(+), 79 deletions(-)

diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
index 660e534ce7c4..2f1dc6688a2f 100644
--- a/include/linux/delayacct.h
+++ b/include/linux/delayacct.h
@@ -65,7 +65,6 @@ struct task_delay_info {
#ifdef CONFIG_TASK_DELAY_ACCT
DECLARE_STATIC_KEY_FALSE(delayacct_key);
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 *);
@@ -88,10 +87,7 @@ extern void __delayacct_irq(struct task_struct *task, u32 delta);

static inline void delayacct_tsk_init(struct task_struct *tsk)
{
- /* reinitialize in case parent's non-null pointer was dup'ed*/
- tsk->delays = NULL;
- if (delayacct_on)
- __delayacct_tsk_init(tsk);
+ __delayacct_tsk_init(tsk);
}

static inline bool delayacct_enabled(void)
@@ -99,16 +95,6 @@ static inline bool delayacct_enabled(void)
return static_branch_unlikely(&delayacct_key);
}

-/* Free tsk->delays. Called from bad fork and __put_task_struct
- * where there's no risk of tsk->delays being accessed elsewhere
- */
-static inline void delayacct_tsk_free(struct task_struct *tsk)
-{
- if (delayacct_enabled())
- kmem_cache_free(delayacct_cache, tsk->delays);
- tsk->delays = NULL;
-}
-
static inline void delayacct_blkio_start(void)
{
if (delayacct_enabled())
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 77f01ac385f7..5cc78184a31f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -37,6 +37,7 @@
#include <linux/kcsan.h>
#include <linux/rv.h>
#include <linux/livepatch_sched.h>
+#include <linux/delayacct.h>
#include <asm/kmap_size.h>

/* task_struct member predeclarations (sorted alphabetically): */
@@ -1331,7 +1332,7 @@ struct task_struct {
struct page_frag task_frag;

#ifdef CONFIG_TASK_DELAY_ACCT
- struct task_delay_info *delays;
+ struct task_delay_info delays;
#endif

#ifdef CONFIG_FAULT_INJECTION
diff --git a/kernel/delayacct.c b/kernel/delayacct.c
index ce10b7c1ee43..1a6b1d3e80af 100644
--- a/kernel/delayacct.c
+++ b/kernel/delayacct.c
@@ -16,7 +16,6 @@

DEFINE_STATIC_KEY_FALSE(delayacct_key);
int delayacct_on __read_mostly; /* Delay accounting turned on/off */
-struct kmem_cache *delayacct_cache;

static void set_delayacct(bool enabled)
{
@@ -38,7 +37,6 @@ __setup("delayacct", delayacct_setup_enable);

void delayacct_init(void)
{
- delayacct_cache = KMEM_CACHE(task_delay_info, SLAB_PANIC|SLAB_ACCOUNT);
delayacct_tsk_init(&init_task);
set_delayacct(delayacct_on);
}
@@ -87,9 +85,8 @@ late_initcall(kernel_delayacct_sysctls_init);

void __delayacct_tsk_init(struct task_struct *tsk)
{
- tsk->delays = kmem_cache_zalloc(delayacct_cache, GFP_KERNEL);
- if (tsk->delays)
- raw_spin_lock_init(&tsk->delays->lock);
+ memset(&tsk->delays, 0, sizeof(struct task_delay_info));
+ raw_spin_lock_init(&tsk->delays.lock);
}

/*
@@ -111,7 +108,7 @@ static void delayacct_end(raw_spinlock_t *lock, u64 *start, u64 *total, u32 *cou

void __delayacct_blkio_start(void)
{
- current->delays->blkio_start = local_clock();
+ current->delays.blkio_start = local_clock();
}

/*
@@ -120,10 +117,10 @@ void __delayacct_blkio_start(void)
*/
void __delayacct_blkio_end(struct task_struct *p)
{
- delayacct_end(&p->delays->lock,
- &p->delays->blkio_start,
- &p->delays->blkio_delay,
- &p->delays->blkio_count);
+ delayacct_end(&p->delays.lock,
+ &p->delays.blkio_start,
+ &p->delays.blkio_delay,
+ &p->delays.blkio_count);
}

int delayacct_add_tsk(struct taskstats *d, struct task_struct *tsk)
@@ -166,29 +163,29 @@ 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;
+ raw_spin_lock_irqsave(&tsk->delays.lock, flags);
+ tmp = d->blkio_delay_total + tsk->delays.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 + tsk->delays.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 + tsk->delays.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 + tsk->delays.thrashing_delay;
d->thrashing_delay_total = (tmp < d->thrashing_delay_total) ? 0 : tmp;
- tmp = d->compact_delay_total + tsk->delays->compact_delay;
+ tmp = d->compact_delay_total + tsk->delays.compact_delay;
d->compact_delay_total = (tmp < d->compact_delay_total) ? 0 : tmp;
- tmp = d->wpcopy_delay_total + tsk->delays->wpcopy_delay;
+ tmp = d->wpcopy_delay_total + tsk->delays.wpcopy_delay;
d->wpcopy_delay_total = (tmp < d->wpcopy_delay_total) ? 0 : tmp;
- tmp = d->irq_delay_total + tsk->delays->irq_delay;
+ tmp = d->irq_delay_total + tsk->delays.irq_delay;
d->irq_delay_total = (tmp < d->irq_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->compact_count += tsk->delays->compact_count;
- d->wpcopy_count += tsk->delays->wpcopy_count;
- d->irq_count += tsk->delays->irq_count;
- raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
+ 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->compact_count += tsk->delays.compact_count;
+ d->wpcopy_count += tsk->delays.wpcopy_count;
+ d->irq_count += tsk->delays.irq_count;
+ raw_spin_unlock_irqrestore(&tsk->delays.lock, flags);

return 0;
}
@@ -198,23 +195,23 @@ __u64 __delayacct_blkio_ticks(struct task_struct *tsk)
__u64 ret;
unsigned long flags;

- raw_spin_lock_irqsave(&tsk->delays->lock, flags);
- ret = nsec_to_clock_t(tsk->delays->blkio_delay);
- raw_spin_unlock_irqrestore(&tsk->delays->lock, flags);
+ raw_spin_lock_irqsave(&tsk->delays.lock, flags);
+ ret = nsec_to_clock_t(tsk->delays.blkio_delay);
+ raw_spin_unlock_irqrestore(&tsk->delays.lock, flags);
return ret;
}

void __delayacct_freepages_start(void)
{
- current->delays->freepages_start = local_clock();
+ current->delays.freepages_start = local_clock();
}

void __delayacct_freepages_end(void)
{
- delayacct_end(&current->delays->lock,
- &current->delays->freepages_start,
- &current->delays->freepages_delay,
- &current->delays->freepages_count);
+ delayacct_end(&current->delays.lock,
+ &current->delays.freepages_start,
+ &current->delays.freepages_delay,
+ &current->delays.freepages_count);
}

void __delayacct_thrashing_start(bool *in_thrashing)
@@ -224,7 +221,7 @@ void __delayacct_thrashing_start(bool *in_thrashing)
return;

current->in_thrashing = 1;
- current->delays->thrashing_start = local_clock();
+ current->delays.thrashing_start = local_clock();
}

void __delayacct_thrashing_end(bool *in_thrashing)
@@ -233,58 +230,58 @@ void __delayacct_thrashing_end(bool *in_thrashing)
return;

current->in_thrashing = 0;
- delayacct_end(&current->delays->lock,
- &current->delays->thrashing_start,
- &current->delays->thrashing_delay,
- &current->delays->thrashing_count);
+ delayacct_end(&current->delays.lock,
+ &current->delays.thrashing_start,
+ &current->delays.thrashing_delay,
+ &current->delays.thrashing_count);
}

void __delayacct_swapin_start(void)
{
- current->delays->swapin_start = local_clock();
+ current->delays.swapin_start = local_clock();
}

void __delayacct_swapin_end(void)
{
- delayacct_end(&current->delays->lock,
- &current->delays->swapin_start,
- &current->delays->swapin_delay,
- &current->delays->swapin_count);
+ delayacct_end(&current->delays.lock,
+ &current->delays.swapin_start,
+ &current->delays.swapin_delay,
+ &current->delays.swapin_count);
}

void __delayacct_compact_start(void)
{
- current->delays->compact_start = local_clock();
+ current->delays.compact_start = local_clock();
}

void __delayacct_compact_end(void)
{
- delayacct_end(&current->delays->lock,
- &current->delays->compact_start,
- &current->delays->compact_delay,
- &current->delays->compact_count);
+ delayacct_end(&current->delays.lock,
+ &current->delays.compact_start,
+ &current->delays.compact_delay,
+ &current->delays.compact_count);
}

void __delayacct_wpcopy_start(void)
{
- current->delays->wpcopy_start = local_clock();
+ current->delays.wpcopy_start = local_clock();
}

void __delayacct_wpcopy_end(void)
{
- delayacct_end(&current->delays->lock,
- &current->delays->wpcopy_start,
- &current->delays->wpcopy_delay,
- &current->delays->wpcopy_count);
+ delayacct_end(&current->delays.lock,
+ &current->delays.wpcopy_start,
+ &current->delays.wpcopy_delay,
+ &current->delays.wpcopy_count);
}

void __delayacct_irq(struct task_struct *task, u32 delta)
{
unsigned long flags;

- raw_spin_lock_irqsave(&task->delays->lock, flags);
- task->delays->irq_delay += delta;
- task->delays->irq_count++;
- raw_spin_unlock_irqrestore(&task->delays->lock, flags);
+ raw_spin_lock_irqsave(&task->delays.lock, flags);
+ task->delays.irq_delay += delta;
+ task->delays.irq_count++;
+ raw_spin_unlock_irqrestore(&task->delays.lock, flags);
}

diff --git a/kernel/fork.c b/kernel/fork.c
index 3b6d20dfb9a8..6f47989e3885 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -975,7 +975,6 @@ void __put_task_struct(struct task_struct *tsk)
task_numa_free(tsk, true);
security_task_free(tsk);
exit_creds(tsk);
- delayacct_tsk_free(tsk);
put_signal_struct(tsk->signal);
sched_core_free(tsk);
free_task(tsk);
@@ -2426,14 +2425,14 @@ __latent_entropy struct task_struct *copy_process(
cgroup_fork(p);
if (args->kthread) {
if (!set_kthread_struct(p))
- goto bad_fork_cleanup_delayacct;
+ goto bad_fork_cleanup_count;
}
#ifdef CONFIG_NUMA
p->mempolicy = mpol_dup(p->mempolicy);
if (IS_ERR(p->mempolicy)) {
retval = PTR_ERR(p->mempolicy);
p->mempolicy = NULL;
- goto bad_fork_cleanup_delayacct;
+ goto bad_fork_cleanup_count;
}
#endif
#ifdef CONFIG_CPUSETS
@@ -2781,8 +2780,6 @@ __latent_entropy struct task_struct *copy_process(
#ifdef CONFIG_NUMA
mpol_put(p->mempolicy);
#endif
-bad_fork_cleanup_delayacct:
- delayacct_tsk_free(p);
bad_fork_cleanup_count:
dec_rlimit_ucounts(task_ucounts(p), UCOUNT_RLIMIT_NPROC, 1);
exit_creds(p);
--
2.25.1

2023-10-08 10:56:49

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 1/3] delayacct: introduce delayacct_enabled() to simplify implement

On Sun, Oct 08, 2023 at 06:49:36PM +0800, brookxu.cn wrote:
> From: Chunguang Xu <[email protected]>
>
> Introduce delayacct_enabled() to simplify the code and make it
> more concise.
>
> Signed-off-by: Chunguang Xu <[email protected]>
> ---
> include/linux/delayacct.h | 74 +++++++++++----------------------------
> kernel/delayacct.c | 2 +-
> 2 files changed, 21 insertions(+), 55 deletions(-)
>
> diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
> index 6639f48dac36..660e534ce7c4 100644
> --- a/include/linux/delayacct.h
> +++ b/include/linux/delayacct.h
> @@ -94,137 +94,103 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
> __delayacct_tsk_init(tsk);
> }
>
> +static inline bool delayacct_enabled(void)
> +{
> + return static_branch_unlikely(&delayacct_key);
> +}
> +
> /* Free tsk->delays. Called from bad fork and __put_task_struct
> * where there's no risk of tsk->delays being accessed elsewhere
> */
> static inline void delayacct_tsk_free(struct task_struct *tsk)
> {
> - if (tsk->delays)
> + if (delayacct_enabled())

This isn't an equivalent change and your Changelog does not clarify.

2023-10-08 10:58:19

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

On Sun, Oct 08, 2023 at 06:49:37PM +0800, brookxu.cn wrote:
> From: Chunguang Xu <[email protected]>
>
> Since in some scenarios we still want to get the task delayacct
> through taskstats, so commit <0cd7c741f01de> introduces a sysctl to

This is not the canonical way to reference a commit.

> enable it dynamically. However, since task->delays is allocated
> during fork(), task->delays will not be reallocated when delayacct
> is enabled later. This will make we cannot get the delayacct of old
> tasks, but the new tasks cans. This can easily lead to confusion.
> Therefore, try to workaround this issue by convert task->delays to
> an object.

And grow task_struct for no reason? I think not.

> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 77f01ac385f7..5cc78184a31f 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -37,6 +37,7 @@
> #include <linux/kcsan.h>
> #include <linux/rv.h>
> #include <linux/livepatch_sched.h>
> +#include <linux/delayacct.h>
> #include <asm/kmap_size.h>
>
> /* task_struct member predeclarations (sorted alphabetically): */
> @@ -1331,7 +1332,7 @@ struct task_struct {
> struct page_frag task_frag;
>
> #ifdef CONFIG_TASK_DELAY_ACCT
> - struct task_delay_info *delays;
> + struct task_delay_info delays;
> #endif

Yeah, no.

2023-10-08 11:03:26

by 许春光

[permalink] [raw]
Subject: Re: [PATCH 1/3] delayacct: introduce delayacct_enabled() to simplify implement


在 2023/10/8 18:56, Peter Zijlstra 写道:
> On Sun, Oct 08, 2023 at 06:49:36PM +0800, brookxu.cn wrote:
>> From: Chunguang Xu <[email protected]>
>>
>> Introduce delayacct_enabled() to simplify the code and make it
>> more concise.
>>
>> Signed-off-by: Chunguang Xu <[email protected]>
>> ---
>> include/linux/delayacct.h | 74 +++++++++++----------------------------
>> kernel/delayacct.c | 2 +-
>> 2 files changed, 21 insertions(+), 55 deletions(-)
>>
>> diff --git a/include/linux/delayacct.h b/include/linux/delayacct.h
>> index 6639f48dac36..660e534ce7c4 100644
>> --- a/include/linux/delayacct.h
>> +++ b/include/linux/delayacct.h
>> @@ -94,137 +94,103 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
>> __delayacct_tsk_init(tsk);
>> }
>>
>> +static inline bool delayacct_enabled(void)
>> +{
>> + return static_branch_unlikely(&delayacct_key);
>> +}
>> +
>> /* Free tsk->delays. Called from bad fork and __put_task_struct
>> * where there's no risk of tsk->delays being accessed elsewhere
>> */
>> static inline void delayacct_tsk_free(struct task_struct *tsk)
>> {
>> - if (tsk->delays)
>> + if (delayacct_enabled())
> This isn't an equivalent change and your Changelog does not clarify.
Sorry, As Patch 2 will convert tsk->delays to object,  we donot need to
check whether tsk->delays is null or not, so relative code can be simplify.

2023-10-08 11:10:18

by 许春光

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object


在 2023/10/8 18:58, Peter Zijlstra 写道:
> On Sun, Oct 08, 2023 at 06:49:37PM +0800, brookxu.cn wrote:
>> From: Chunguang Xu <[email protected]>
>>
>> Since in some scenarios we still want to get the task delayacct
>> through taskstats, so commit <0cd7c741f01de> introduces a sysctl to
> This is not the canonical way to reference a commit.
>
>> enable it dynamically. However, since task->delays is allocated
>> during fork(), task->delays will not be reallocated when delayacct
>> is enabled later. This will make we cannot get the delayacct of old
>> tasks, but the new tasks cans. This can easily lead to confusion.
>> Therefore, try to workaround this issue by convert task->delays to
>> an object.
> And grow task_struct for no reason? I think not.
>
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index 77f01ac385f7..5cc78184a31f 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -37,6 +37,7 @@
>> #include <linux/kcsan.h>
>> #include <linux/rv.h>
>> #include <linux/livepatch_sched.h>
>> +#include <linux/delayacct.h>
>> #include <asm/kmap_size.h>
>>
>> /* task_struct member predeclarations (sorted alphabetically): */
>> @@ -1331,7 +1332,7 @@ struct task_struct {
>> struct page_frag task_frag;
>>
>> #ifdef CONFIG_TASK_DELAY_ACCT
>> - struct task_delay_info *delays;
>> + struct task_delay_info delays;
>> #endif
> Yeah, no.
Yes, this way will increase about 80 bytes for task_struct, about 0.85%
of size of task_struct, I think this just like sched_statistics, so that
can better support dynamically enable through sysctl.

2023-10-08 13:43:23

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

Hi brookxu.cn,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master v6.6-rc4 next-20231006]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/brookxu-cn/delayacct-introduce-delayacct_enabled-to-simplify-implement/20231008-185144
base: tip/sched/core
patch link: https://lore.kernel.org/r/531ddc82793a39f4c09316d701a4b1170bcad4ab.1696761522.git.chunguang.xu%40shopee.com
patch subject: [PATCH 2/3] delayacct: convert task->delays to a object
config: riscv-randconfig-002-20231008 (https://download.01.org/0day-ci/archive/20231008/[email protected]/config)
compiler: riscv64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231008/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from arch/riscv/include/asm/compat.h:12,
from arch/riscv/include/asm/pgtable.h:119,
from include/linux/pgtable.h:6,
from include/linux/kasan.h:33,
from include/linux/slab.h:180,
from include/linux/delayacct.h:62,
from include/linux/sched.h:40,
from include/linux/mm.h:28,
from arch/riscv/kernel/asm-offsets.c:10:
include/linux/sched/task_stack.h: In function 'task_stack_page':
>> include/linux/sched/task_stack.h:21:20: error: invalid use of undefined type 'const struct task_struct'
21 | return task->stack;
| ^~
include/linux/sched/task_stack.h: In function 'end_of_stack':
include/linux/sched/task_stack.h:31:20: error: invalid use of undefined type 'const struct task_struct'
31 | return task->stack;
| ^~
include/linux/sched/task_stack.h: In function 'try_get_task_stack':
>> include/linux/sched/task_stack.h:68:42: error: invalid use of undefined type 'struct task_struct'
68 | return refcount_inc_not_zero(&tsk->stack_refcount) ?
| ^~
make[3]: *** [scripts/Makefile.build:116: arch/riscv/kernel/asm-offsets.s] Error 1 shuffle=2275994632
make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1202: prepare0] Error 2 shuffle=2275994632
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:234: __sub-make] Error 2 shuffle=2275994632
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:234: __sub-make] Error 2 shuffle=2275994632
make: Target 'prepare' not remade because of errors.


vim +21 include/linux/sched/task_stack.h

f3ac60671954c8 Ingo Molnar 2017-02-03 13
f3ac60671954c8 Ingo Molnar 2017-02-03 14 /*
f3ac60671954c8 Ingo Molnar 2017-02-03 15 * When accessing the stack of a non-current task that might exit, use
f3ac60671954c8 Ingo Molnar 2017-02-03 16 * try_get_task_stack() instead. task_stack_page will return a pointer
f3ac60671954c8 Ingo Molnar 2017-02-03 17 * that could get freed out from under you.
f3ac60671954c8 Ingo Molnar 2017-02-03 18 */
e87f4152e54261 Borislav Petkov 2022-03-23 19 static __always_inline void *task_stack_page(const struct task_struct *task)
f3ac60671954c8 Ingo Molnar 2017-02-03 20 {
f3ac60671954c8 Ingo Molnar 2017-02-03 @21 return task->stack;
f3ac60671954c8 Ingo Molnar 2017-02-03 22 }
f3ac60671954c8 Ingo Molnar 2017-02-03 23
f3ac60671954c8 Ingo Molnar 2017-02-03 24 #define setup_thread_stack(new,old) do { } while(0)
f3ac60671954c8 Ingo Molnar 2017-02-03 25
e0b081d17a9f4e Josh Poimboeuf 2023-04-12 26 static __always_inline unsigned long *end_of_stack(const struct task_struct *task)
f3ac60671954c8 Ingo Molnar 2017-02-03 27 {
9cc2fa4f4a92cc Helge Deller 2021-10-05 28 #ifdef CONFIG_STACK_GROWSUP
9cc2fa4f4a92cc Helge Deller 2021-10-05 29 return (unsigned long *)((unsigned long)task->stack + THREAD_SIZE) - 1;
9cc2fa4f4a92cc Helge Deller 2021-10-05 30 #else
f3ac60671954c8 Ingo Molnar 2017-02-03 31 return task->stack;
9cc2fa4f4a92cc Helge Deller 2021-10-05 32 #endif
f3ac60671954c8 Ingo Molnar 2017-02-03 33 }
f3ac60671954c8 Ingo Molnar 2017-02-03 34
f3ac60671954c8 Ingo Molnar 2017-02-03 35 #elif !defined(__HAVE_THREAD_FUNCTIONS)
f3ac60671954c8 Ingo Molnar 2017-02-03 36
f3ac60671954c8 Ingo Molnar 2017-02-03 37 #define task_stack_page(task) ((void *)(task)->stack)
f3ac60671954c8 Ingo Molnar 2017-02-03 38
f3ac60671954c8 Ingo Molnar 2017-02-03 39 static inline void setup_thread_stack(struct task_struct *p, struct task_struct *org)
f3ac60671954c8 Ingo Molnar 2017-02-03 40 {
f3ac60671954c8 Ingo Molnar 2017-02-03 41 *task_thread_info(p) = *task_thread_info(org);
f3ac60671954c8 Ingo Molnar 2017-02-03 42 task_thread_info(p)->task = p;
f3ac60671954c8 Ingo Molnar 2017-02-03 43 }
f3ac60671954c8 Ingo Molnar 2017-02-03 44
f3ac60671954c8 Ingo Molnar 2017-02-03 45 /*
f3ac60671954c8 Ingo Molnar 2017-02-03 46 * Return the address of the last usable long on the stack.
f3ac60671954c8 Ingo Molnar 2017-02-03 47 *
f3ac60671954c8 Ingo Molnar 2017-02-03 48 * When the stack grows down, this is just above the thread
f3ac60671954c8 Ingo Molnar 2017-02-03 49 * info struct. Going any lower will corrupt the threadinfo.
f3ac60671954c8 Ingo Molnar 2017-02-03 50 *
f3ac60671954c8 Ingo Molnar 2017-02-03 51 * When the stack grows up, this is the highest address.
f3ac60671954c8 Ingo Molnar 2017-02-03 52 * Beyond that position, we corrupt data on the next page.
f3ac60671954c8 Ingo Molnar 2017-02-03 53 */
f3ac60671954c8 Ingo Molnar 2017-02-03 54 static inline unsigned long *end_of_stack(struct task_struct *p)
f3ac60671954c8 Ingo Molnar 2017-02-03 55 {
f3ac60671954c8 Ingo Molnar 2017-02-03 56 #ifdef CONFIG_STACK_GROWSUP
f3ac60671954c8 Ingo Molnar 2017-02-03 57 return (unsigned long *)((unsigned long)task_thread_info(p) + THREAD_SIZE) - 1;
f3ac60671954c8 Ingo Molnar 2017-02-03 58 #else
f3ac60671954c8 Ingo Molnar 2017-02-03 59 return (unsigned long *)(task_thread_info(p) + 1);
f3ac60671954c8 Ingo Molnar 2017-02-03 60 #endif
f3ac60671954c8 Ingo Molnar 2017-02-03 61 }
f3ac60671954c8 Ingo Molnar 2017-02-03 62
f3ac60671954c8 Ingo Molnar 2017-02-03 63 #endif
f3ac60671954c8 Ingo Molnar 2017-02-03 64
f3ac60671954c8 Ingo Molnar 2017-02-03 65 #ifdef CONFIG_THREAD_INFO_IN_TASK
f3ac60671954c8 Ingo Molnar 2017-02-03 66 static inline void *try_get_task_stack(struct task_struct *tsk)
f3ac60671954c8 Ingo Molnar 2017-02-03 67 {
f0b89d3958d73c Elena Reshetova 2019-01-18 @68 return refcount_inc_not_zero(&tsk->stack_refcount) ?
f3ac60671954c8 Ingo Molnar 2017-02-03 69 task_stack_page(tsk) : NULL;
f3ac60671954c8 Ingo Molnar 2017-02-03 70 }
f3ac60671954c8 Ingo Molnar 2017-02-03 71

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-10-08 15:49:08

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

Hi brookxu.cn,

kernel test robot noticed the following build errors:

[auto build test ERROR on tip/sched/core]
[also build test ERROR on linus/master v6.6-rc4 next-20231006]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/brookxu-cn/delayacct-introduce-delayacct_enabled-to-simplify-implement/20231008-185144
base: tip/sched/core
patch link: https://lore.kernel.org/r/531ddc82793a39f4c09316d701a4b1170bcad4ab.1696761522.git.chunguang.xu%40shopee.com
patch subject: [PATCH 2/3] delayacct: convert task->delays to a object
config: arm64-randconfig-003-20231008 (https://download.01.org/0day-ci/archive/20231008/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231008/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

In file included from include/linux/kasan.h:33,
from include/linux/slab.h:180,
from include/linux/delayacct.h:62,
from include/linux/sched.h:40,
from arch/arm64/include/asm/mte.h:16,
from arch/arm64/include/asm/pgtable.h:12,
from arch/arm64/include/asm/vmalloc.h:5,
from include/linux/vmalloc.h:13,
from mm/vmalloc.c:11:
include/linux/pgtable.h: In function 'pte_offset_kernel':
include/linux/pgtable.h:94:25: error: implicit declaration of function 'pmd_page_vaddr'; did you mean 'pgd_page_vaddr'? [-Werror=implicit-function-declaration]
94 | return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
| ^~~~~~~~~~~~~~
| pgd_page_vaddr
include/linux/pgtable.h:94:16: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
94 | return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
| ^
include/linux/pgtable.h: In function 'pmd_offset':
include/linux/pgtable.h:123:16: error: implicit declaration of function 'pud_pgtable'; did you mean 'p4d_pgtable'? [-Werror=implicit-function-declaration]
123 | return pud_pgtable(*pud) + pmd_index(address);
| ^~~~~~~~~~~
| p4d_pgtable
include/linux/pgtable.h:123:34: warning: returning 'long unsigned int' from a function with return type 'pmd_t *' makes pointer from integer without a cast [-Wint-conversion]
123 | return pud_pgtable(*pud) + pmd_index(address);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h: In function 'virt_to_kpte':
include/linux/pgtable.h:177:16: error: implicit declaration of function 'pmd_none'; did you mean 'p4d_none'? [-Werror=implicit-function-declaration]
177 | return pmd_none(*pmd) ? NULL : pte_offset_kernel(pmd, vaddr);
| ^~~~~~~~
| p4d_none
In file included from arch/arm64/include/asm/kasan.h:10,
from arch/arm64/include/asm/processor.h:40,
from include/asm-generic/qrwlock.h:18,
from ./arch/arm64/include/generated/asm/qrwlock.h:1,
from arch/arm64/include/asm/spinlock.h:9,
from include/linux/spinlock.h:95,
from include/linux/vmalloc.h:5:
include/linux/pgtable.h: In function 'pte_next_pfn':
include/linux/pgtable.h:213:45: error: 'PFN_PTE_SHIFT' undeclared (first use in this function); did you mean 'CONT_PTE_SHIFT'?
213 | return __pte(pte_val(pte) + (1UL << PFN_PTE_SHIFT));
| ^~~~~~~~~~~~~
arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
25 | #define __pte(x) ((pte_t) { (x) } )
| ^
include/linux/pgtable.h:213:45: note: each undeclared identifier is reported only once for each function it appears in
213 | return __pte(pte_val(pte) + (1UL << PFN_PTE_SHIFT));
| ^~~~~~~~~~~~~
arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
25 | #define __pte(x) ((pte_t) { (x) } )
| ^
include/linux/pgtable.h: In function 'set_ptes':
include/linux/pgtable.h:238:17: error: implicit declaration of function 'set_pte'; did you mean 'set_ptes'? [-Werror=implicit-function-declaration]
238 | set_pte(ptep, pte);
| ^~~~~~~
| set_ptes
include/linux/pgtable.h: In function 'ptep_test_and_clear_young':
include/linux/pgtable.h:302:14: error: implicit declaration of function 'pte_young'; did you mean 'pmd_young'? [-Werror=implicit-function-declaration]
302 | if (!pte_young(pte))
| ^~~~~~~~~
| pmd_young
include/linux/pgtable.h:305:55: error: implicit declaration of function 'pte_mkold' [-Werror=implicit-function-declaration]
305 | set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
| ^~~~~~~~~
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
include/linux/pgtable.h:305:55: error: incompatible type for argument 4 of 'set_ptes'
305 | set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
| ^~~~~~~~~~~~~~
| |
| int
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
include/linux/pgtable.h:232:36: note: expected 'pte_t' but argument is of type 'int'
232 | pte_t *ptep, pte_t pte, unsigned int nr)
| ~~~~~~^~~
include/linux/pgtable.h: In function 'pmdp_test_and_clear_young':
>> include/linux/pgtable.h:321:17: error: implicit declaration of function 'set_pmd_at'; did you mean 'set_pte_at'? [-Werror=implicit-function-declaration]
321 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
| ^~~~~~~~~~
| set_pte_at
>> include/linux/pgtable.h:321:55: error: implicit declaration of function 'pmd_mkold' [-Werror=implicit-function-declaration]
321 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
| ^~~~~~~~~
include/linux/pgtable.h: In function 'ptep_get_and_clear':
include/linux/pgtable.h:402:9: error: implicit declaration of function 'pte_clear'; did you mean 'p4d_clear'? [-Werror=implicit-function-declaration]
402 | pte_clear(mm, address, ptep);
| ^~~~~~~~~
| p4d_clear
include/linux/pgtable.h: In function 'pmdp_huge_get_and_clear':
>> include/linux/pgtable.h:505:9: error: implicit declaration of function 'pmd_clear'; did you mean 'p4d_clear'? [-Werror=implicit-function-declaration]
505 | pmd_clear(pmdp);
| ^~~~~~~~~
| p4d_clear
include/linux/pgtable.h: In function 'pudp_huge_get_and_clear':
>> include/linux/pgtable.h:518:9: error: implicit declaration of function 'pud_clear'; did you mean 'p4d_clear'? [-Werror=implicit-function-declaration]
518 | pud_clear(pudp);
| ^~~~~~~~~
| p4d_clear
include/linux/pgtable.h: In function 'pte_mkwrite':
include/linux/pgtable.h:605:16: error: implicit declaration of function 'pte_mkwrite_novma'; did you mean 'pte_mkwrite'? [-Werror=implicit-function-declaration]
605 | return pte_mkwrite_novma(pte);
| ^~~~~~~~~~~~~~~~~
| pte_mkwrite
include/linux/pgtable.h:605:16: error: incompatible types when returning type 'int' but 'pte_t' was expected
605 | return pte_mkwrite_novma(pte);
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h: In function 'pmd_mkwrite':
>> include/linux/pgtable.h:612:16: error: implicit declaration of function 'pmd_mkwrite_novma'; did you mean 'pmd_mkwrite'? [-Werror=implicit-function-declaration]
612 | return pmd_mkwrite_novma(pmd);
| ^~~~~~~~~~~~~~~~~
| pmd_mkwrite
>> include/linux/pgtable.h:612:16: error: incompatible types when returning type 'int' but 'pmd_t' was expected
612 | return pmd_mkwrite_novma(pmd);
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h: In function 'ptep_set_wrprotect':
include/linux/pgtable.h:621:39: error: implicit declaration of function 'pte_wrprotect'; did you mean 'ptep_set_wrprotect'? [-Werror=implicit-function-declaration]
621 | set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
| ^~~~~~~~~~~~~
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
include/linux/pgtable.h:621:39: error: incompatible type for argument 4 of 'set_ptes'
621 | set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| int
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
include/linux/pgtable.h:232:36: note: expected 'pte_t' but argument is of type 'int'
232 | pte_t *ptep, pte_t pte, unsigned int nr)
| ~~~~~~^~~
include/linux/pgtable.h: In function 'pmdp_set_wrprotect':
>> include/linux/pgtable.h:647:39: error: implicit declaration of function 'pmd_wrprotect'; did you mean 'pmdp_set_wrprotect'? [-Werror=implicit-function-declaration]
647 | set_pmd_at(mm, address, pmdp, pmd_wrprotect(old_pmd));
| ^~~~~~~~~~~~~
| pmdp_set_wrprotect
include/linux/pgtable.h: In function 'pud_none_or_clear_bad':
include/linux/pgtable.h:1015:13: error: implicit declaration of function 'pud_none'; did you mean 'p4d_none'? [-Werror=implicit-function-declaration]
1015 | if (pud_none(*pud))
| ^~~~~~~~
| p4d_none
In file included from include/linux/export.h:5,
from include/linux/linkage.h:7,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:56:
include/linux/pgtable.h:1017:22: error: implicit declaration of function 'pud_bad'; did you mean 'p4d_bad'? [-Werror=implicit-function-declaration]
1017 | if (unlikely(pud_bad(*pud))) {
| ^~~~~~~
include/linux/compiler.h:77:45: note: in definition of macro 'unlikely'
77 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/pgtable.h: In function 'pmd_none_or_clear_bad':
include/linux/pgtable.h:1028:22: error: implicit declaration of function 'pmd_bad'; did you mean 'p4d_bad'? [-Werror=implicit-function-declaration]
1028 | if (unlikely(pmd_bad(*pmd))) {
| ^~~~~~~
include/linux/compiler.h:77:45: note: in definition of macro 'unlikely'
77 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
In file included from arch/arm64/include/asm/pgtable.h:14:
arch/arm64/include/asm/pgtable-prot.h: At top level:
arch/arm64/include/asm/pgtable-prot.h:85: warning: "PAGE_KERNEL_RO" redefined
85 | #define PAGE_KERNEL_RO __pgprot(_PAGE_KERNEL_RO)
|
include/linux/pgtable.h:1539: note: this is the location of the previous definition
1539 | # define PAGE_KERNEL_RO PAGE_KERNEL
|
arch/arm64/include/asm/pgtable-prot.h:87: warning: "PAGE_KERNEL_EXEC" redefined
87 | #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
|
include/linux/pgtable.h:1543: note: this is the location of the previous definition
1543 | # define PAGE_KERNEL_EXEC PAGE_KERNEL
|
>> arch/arm64/include/asm/pgtable.h:42: warning: "flush_pmd_tlb_range" redefined
42 | #define flush_pmd_tlb_range(vma, addr, end) \
|
include/linux/pgtable.h:1498: note: this is the location of the previous definition
1498 | #define flush_pmd_tlb_range(vma, addr, end) flush_tlb_range(vma, addr, end)
|
>> arch/arm64/include/asm/pgtable.h:44: warning: "flush_pud_tlb_range" redefined
44 | #define flush_pud_tlb_range(vma, addr, end) \
|
include/linux/pgtable.h:1499: note: this is the location of the previous definition
1499 | #define flush_pud_tlb_range(vma, addr, end) flush_tlb_range(vma, addr, end)
|
arch/arm64/include/asm/pgtable.h:60: warning: "flush_tlb_fix_spurious_fault" redefined
60 | #define flush_tlb_fix_spurious_fault(vma, address, ptep) do { } while (0)
|
include/linux/pgtable.h:935: note: this is the location of the previous definition
935 | #define flush_tlb_fix_spurious_fault(vma, address, ptep) flush_tlb_page(vma, address)
|
arch/arm64/include/asm/pgtable.h:143: warning: "pte_accessible" redefined
143 | #define pte_accessible(mm, pte) \
|
include/linux/pgtable.h:931: note: this is the location of the previous definition
931 | # define pte_accessible(mm, pte) ((void)(pte), 1)
|
arch/arm64/include/asm/pgtable.h:153: warning: "pte_access_permitted" redefined
153 | #define pte_access_permitted(pte, write) \
|
include/linux/pgtable.h:767: note: this is the location of the previous definition
767 | #define pte_access_permitted(pte, write) \
|
arch/arm64/include/asm/pgtable.h:155: warning: "pmd_access_permitted" redefined
155 | #define pmd_access_permitted(pmd, write) \
|
include/linux/pgtable.h:772: note: this is the location of the previous definition
772 | #define pmd_access_permitted(pmd, write) \
|
arch/arm64/include/asm/pgtable.h:157: warning: "pud_access_permitted" redefined
157 | #define pud_access_permitted(pud, write) \
|
include/linux/pgtable.h:777: note: this is the location of the previous definition
777 | #define pud_access_permitted(pud, write) \
|
arch/arm64/include/asm/pgtable.h:184:21: error: conflicting types for 'pte_mkwrite_novma'; have 'pte_t(pte_t)'
184 | static inline pte_t pte_mkwrite_novma(pte_t pte)
| ^~~~~~~~~~~~~~~~~
include/linux/pgtable.h:605:16: note: previous implicit declaration of 'pte_mkwrite_novma' with type 'int()'
605 | return pte_mkwrite_novma(pte);
| ^~~~~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:209:21: error: conflicting types for 'pte_wrprotect'; have 'pte_t(pte_t)'
209 | static inline pte_t pte_wrprotect(pte_t pte)
| ^~~~~~~~~~~~~
include/linux/pgtable.h:621:39: note: previous implicit declaration of 'pte_wrprotect' with type 'int()'
621 | set_pte_at(mm, address, ptep, pte_wrprotect(old_pte));
| ^~~~~~~~~~~~~
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
arch/arm64/include/asm/pgtable.h:223:21: error: conflicting types for 'pte_mkold'; have 'pte_t(pte_t)'
223 | static inline pte_t pte_mkold(pte_t pte)
| ^~~~~~~~~
include/linux/pgtable.h:305:55: note: previous implicit declaration of 'pte_mkold' with type 'int()'
305 | set_pte_at(vma->vm_mm, address, ptep, pte_mkold(pte));
| ^~~~~~~~~
include/linux/pgtable.h:247:66: note: in definition of macro 'set_pte_at'
247 | #define set_pte_at(mm, addr, ptep, pte) set_ptes(mm, addr, ptep, pte, 1)
| ^~~
arch/arm64/include/asm/pgtable.h:264:20: warning: conflicting types for 'set_pte'; have 'void(pte_t *, pte_t)'
264 | static inline void set_pte(pte_t *ptep, pte_t pte)
| ^~~~~~~
arch/arm64/include/asm/pgtable.h:264:20: error: static declaration of 'set_pte' follows non-static declaration
include/linux/pgtable.h:238:17: note: previous implicit declaration of 'set_pte' with type 'void(pte_t *, pte_t)'
238 | set_pte(ptep, pte);
| ^~~~~~~
arch/arm64/include/asm/pgtable.h:349:20: error: redefinition of 'set_ptes'
349 | static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
| ^~~~~~~~
include/linux/pgtable.h:231:20: note: previous definition of 'set_ptes' with type 'void(struct mm_struct *, long unsigned int, pte_t *, pte_t, unsigned int)'
231 | static inline void set_ptes(struct mm_struct *mm, unsigned long addr,
| ^~~~~~~~
>> arch/arm64/include/asm/pgtable.h:534:20: warning: conflicting types for 'set_pmd_at'; have 'void(struct mm_struct *, long unsigned int, pmd_t *, pmd_t)'
534 | static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr,
| ^~~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:534:20: error: static declaration of 'set_pmd_at' follows non-static declaration
include/linux/pgtable.h:321:17: note: previous implicit declaration of 'set_pmd_at' with type 'void(struct mm_struct *, long unsigned int, pmd_t *, pmd_t)'
321 | set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
| ^~~~~~~~~~
arch/arm64/include/asm/pgtable.h:557: warning: "pgprot_nx" redefined
557 | #define pgprot_nx(prot) \
|
include/linux/pgtable.h:1099: note: this is the location of the previous definition
1099 | #define pgprot_nx(prot) (prot)
|
arch/arm64/include/asm/pgtable.h:563: warning: "pgprot_noncached" redefined
563 | #define pgprot_noncached(prot) \
|
include/linux/pgtable.h:1103: note: this is the location of the previous definition
1103 | #define pgprot_noncached(prot) (prot)
|
arch/arm64/include/asm/pgtable.h:565: warning: "pgprot_writecombine" redefined
565 | #define pgprot_writecombine(prot) \
|
include/linux/pgtable.h:1107: note: this is the location of the previous definition
1107 | #define pgprot_writecombine pgprot_noncached
|
arch/arm64/include/asm/pgtable.h:567: warning: "pgprot_device" redefined
567 | #define pgprot_device(prot) \
|
include/linux/pgtable.h:1115: note: this is the location of the previous definition
1115 | #define pgprot_device pgprot_noncached
|
arch/arm64/include/asm/pgtable.h:571: warning: "pgprot_mhp" redefined
571 | #define pgprot_mhp pgprot_tagged
|
include/linux/pgtable.h:1119: note: this is the location of the previous definition
1119 | #define pgprot_mhp(prot) (prot)
|
arch/arm64/include/asm/pgtable.h:595: warning: "pmd_leaf" redefined
595 | #define pmd_leaf(pmd) (pmd_present(pmd) && !pmd_table(pmd))
|
include/linux/pgtable.h:1634: note: this is the location of the previous definition
1634 | #define pmd_leaf(x) 0
|
arch/arm64/include/asm/pgtable.h:598: warning: "pmd_leaf_size" redefined
598 | #define pmd_leaf_size(pmd) (pmd_cont(pmd) ? CONT_PMD_SIZE : PMD_SIZE)
|
include/linux/pgtable.h:1647: note: this is the location of the previous definition
1647 | #define pmd_leaf_size(x) PMD_SIZE
|
arch/arm64/include/asm/pgtable.h:599: warning: "pte_leaf_size" redefined
599 | #define pte_leaf_size(pte) (pte_cont(pte) ? CONT_PTE_SIZE : PAGE_SIZE)
|
include/linux/pgtable.h:1650: note: this is the location of the previous definition
1650 | #define pte_leaf_size(x) PAGE_SIZE
|
>> arch/arm64/include/asm/pgtable.h:643:20: warning: conflicting types for 'pmd_clear'; have 'void(pmd_t *)'
643 | static inline void pmd_clear(pmd_t *pmdp)
| ^~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:643:20: error: static declaration of 'pmd_clear' follows non-static declaration
include/linux/pgtable.h:505:9: note: previous implicit declaration of 'pmd_clear' with type 'void(pmd_t *)'
505 | pmd_clear(pmdp);
| ^~~~~~~~~
arch/arm64/include/asm/pgtable.h:653:29: error: conflicting types for 'pmd_page_vaddr'; have 'long unsigned int(pmd_t)'
653 | static inline unsigned long pmd_page_vaddr(pmd_t pmd)
| ^~~~~~~~~~~~~~
include/linux/pgtable.h:94:25: note: previous implicit declaration of 'pmd_page_vaddr' with type 'int()'
94 | return (pte_t *)pmd_page_vaddr(*pmd) + pte_index(address);
| ^~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:684: warning: "pud_leaf" redefined
684 | #define pud_leaf(pud) (pud_present(pud) && !pud_table(pud))
|
include/linux/pgtable.h:1631: note: this is the location of the previous definition
1631 | #define pud_leaf(x) 0
|
>> arch/arm64/include/asm/pgtable.h:706:20: warning: conflicting types for 'pud_clear'; have 'void(pud_t *)'
706 | static inline void pud_clear(pud_t *pudp)
| ^~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:706:20: error: static declaration of 'pud_clear' follows non-static declaration
include/linux/pgtable.h:518:9: note: previous implicit declaration of 'pud_clear' with type 'void(pud_t *)'
518 | pud_clear(pudp);
| ^~~~~~~~~
arch/arm64/include/asm/pgtable.h:716:22: error: conflicting types for 'pud_pgtable'; have 'pmd_t *(pud_t)'
716 | static inline pmd_t *pud_pgtable(pud_t pud)
| ^~~~~~~~~~~
include/linux/pgtable.h:123:16: note: previous implicit declaration of 'pud_pgtable' with type 'int()'
123 | return pud_pgtable(*pud) + pmd_index(address);
| ^~~~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:844:19: error: static declaration of 'pmdp_set_access_flags' follows non-static declaration
844 | static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:257:12: note: previous declaration of 'pmdp_set_access_flags' with type 'int(struct vm_area_struct *, long unsigned int, pmd_t *, pmd_t, int)'
257 | extern int pmdp_set_access_flags(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:898:19: error: redefinition of 'ptep_test_and_clear_young'
898 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:296:19: note: previous definition of 'ptep_test_and_clear_young' with type 'int(struct vm_area_struct *, long unsigned int, pte_t *)'
296 | static inline int ptep_test_and_clear_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:906:19: error: static declaration of 'ptep_clear_flush_young' follows non-static declaration
906 | static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:336:5: note: previous declaration of 'ptep_clear_flush_young' with type 'int(struct vm_area_struct *, long unsigned int, pte_t *)'
336 | int ptep_clear_flush_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:928:19: error: redefinition of 'pmdp_test_and_clear_young'
928 | static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:312:19: note: previous definition of 'pmdp_test_and_clear_young' with type 'int(struct vm_area_struct *, long unsigned int, pmd_t *)'
312 | static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:937:21: error: redefinition of 'ptep_get_and_clear'
937 | static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:397:21: note: previous definition of 'ptep_get_and_clear' with type 'pte_t(struct mm_struct *, long unsigned int, pte_t *)'
397 | static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:949:21: error: redefinition of 'pmdp_huge_get_and_clear'
949 | static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:499:21: note: previous definition of 'pmdp_huge_get_and_clear' with type 'pmd_t(struct mm_struct *, long unsigned int, pmd_t *)'
499 | static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/include/asm/pgtable.h:965:20: error: redefinition of 'ptep_set_wrprotect'
965 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep)
| ^~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:618:20: note: previous definition of 'ptep_set_wrprotect' with type 'void(struct mm_struct *, long unsigned int, pte_t *)'
618 | static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep)
| ^~~~~~~~~~~~~~~~~~
>> arch/arm64/include/asm/pgtable.h:980:20: error: redefinition of 'pmdp_set_wrprotect'
980 | static inline void pmdp_set_wrprotect(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~
include/linux/pgtable.h:643:20: note: previous definition of 'pmdp_set_wrprotect' with type 'void(struct mm_struct *, long unsigned int, pmd_t *)'
643 | static inline void pmdp_set_wrprotect(struct mm_struct *mm,
| ^~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
..


vim +321 include/linux/pgtable.h

e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 309
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 310 #ifndef __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG
eed9a328aa1ae6 include/linux/pgtable.h Yu Zhao 2022-09-18 311 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) || defined(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG)
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 312 static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 313 unsigned long address,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 314 pmd_t *pmdp)
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 315 {
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 316 pmd_t pmd = *pmdp;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 317 int r = 1;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 318 if (!pmd_young(pmd))
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 319 r = 0;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 320 else
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 @321 set_pmd_at(vma->vm_mm, address, pmdp, pmd_mkold(pmd));
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 322 return r;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 323 }
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 324 #else
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 325 static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 326 unsigned long address,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 327 pmd_t *pmdp)
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 328 {
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 329 BUILD_BUG();
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 330 return 0;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 331 }
eed9a328aa1ae6 include/linux/pgtable.h Yu Zhao 2022-09-18 332 #endif /* CONFIG_TRANSPARENT_HUGEPAGE || CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG */
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 333 #endif
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 334
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 335 #ifndef __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 336 int ptep_clear_flush_young(struct vm_area_struct *vma,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 337 unsigned long address, pte_t *ptep);
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 338 #endif
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 339
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 340 #ifndef __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 341 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 342 extern int pmdp_clear_flush_young(struct vm_area_struct *vma,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 343 unsigned long address, pmd_t *pmdp);
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 344 #else
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 345 /*
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 346 * Despite relevant to THP only, this API is called from generic rmap code
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 347 * under PageTransHuge(), hence needs a dummy implementation for !THP
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 348 */
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 349 static inline int pmdp_clear_flush_young(struct vm_area_struct *vma,
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 350 unsigned long address, pmd_t *pmdp)
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 351 {
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 352 BUILD_BUG();
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 353 return 0;
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 354 }
bd5e88ad72b26e include/asm-generic/pgtable.h Vineet Gupta 2015-07-09 355 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 356 #endif
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 357
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 358 #ifndef arch_has_hw_nonleaf_pmd_young
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 359 /*
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 360 * Return whether the accessed bit in non-leaf PMD entries is supported on the
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 361 * local CPU.
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 362 */
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 363 static inline bool arch_has_hw_nonleaf_pmd_young(void)
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 364 {
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 365 return IS_ENABLED(CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG);
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 366 }
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 367 #endif
4aaf269c768dba include/linux/pgtable.h Juergen Gross 2022-11-23 368
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 369 #ifndef arch_has_hw_pte_young
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 370 /*
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 371 * Return whether the accessed bit is supported on the local CPU.
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 372 *
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 373 * This stub assumes accessing through an old PTE triggers a page fault.
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 374 * Architectures that automatically set the access bit should overwrite it.
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 375 */
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 376 static inline bool arch_has_hw_pte_young(void)
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 377 {
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 378 return false;
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 379 }
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 380 #endif
e1fd09e3d1dd4a include/linux/pgtable.h Yu Zhao 2022-09-18 381
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 382 #ifndef arch_check_zapped_pte
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 383 static inline void arch_check_zapped_pte(struct vm_area_struct *vma,
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 384 pte_t pte)
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 385 {
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 386 }
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 387 #endif
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 388
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 389 #ifndef arch_check_zapped_pmd
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 390 static inline void arch_check_zapped_pmd(struct vm_area_struct *vma,
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 391 pmd_t pmd)
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 392 {
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 393 }
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 394 #endif
e5136e876581ba include/linux/pgtable.h Rick Edgecombe 2023-06-12 395
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 396 #ifndef __HAVE_ARCH_PTEP_GET_AND_CLEAR
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 397 static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 398 unsigned long address,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 399 pte_t *ptep)
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 400 {
c33c794828f212 include/linux/pgtable.h Ryan Roberts 2023-06-12 401 pte_t pte = ptep_get(ptep);
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 402 pte_clear(mm, address, ptep);
aa232204c46894 include/linux/pgtable.h Kemeng Shi 2023-07-14 403 page_table_check_pte_clear(mm, pte);
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 404 return pte;
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 405 }
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 406 #endif
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 407
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 408 static inline void ptep_clear(struct mm_struct *mm, unsigned long addr,
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 409 pte_t *ptep)
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 410 {
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 411 ptep_get_and_clear(mm, addr, ptep);
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 412 }
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 413
6ca297d4784625 include/linux/pgtable.h Peter Zijlstra 2022-10-21 414 #ifdef CONFIG_GUP_GET_PXX_LOW_HIGH
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 415 /*
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 416 * For walking the pagetables without holding any locks. Some architectures
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 417 * (eg x86-32 PAE) cannot load the entries atomically without using expensive
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 418 * instructions. We are guaranteed that a PTE will only either go from not
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 419 * present to present, or present to not present -- it will not switch to a
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 420 * completely different present page without a TLB flush inbetween; which we
93b3037a148275 include/linux/pgtable.h Peter Zijlstra 2020-11-26 421 * are blocking by holding interrupts off.
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 422 *
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 423 * Setting ptes from not present to present goes:
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 424 *
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 425 * ptep->pte_high = h;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 426 * smp_wmb();
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 427 * ptep->pte_low = l;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 428 *
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 429 * And present to not present goes:
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 430 *
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 431 * ptep->pte_low = 0;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 432 * smp_wmb();
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 433 * ptep->pte_high = 0;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 434 *
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 435 * We must ensure here that the load of pte_low sees 'l' IFF pte_high sees 'h'.
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 436 * We load pte_high *after* loading pte_low, which ensures we don't see an older
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 437 * value of pte_high. *Then* we recheck pte_low, which ensures that we haven't
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 438 * picked up a changed pte high. We might have gotten rubbish values from
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 439 * pte_low and pte_high, but we are guaranteed that pte_low will not have the
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 440 * present bit set *unless* it is 'l'. Because get_user_pages_fast() only
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 441 * operates on present ptes we're safe.
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 442 */
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 443 static inline pte_t ptep_get_lockless(pte_t *ptep)
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 444 {
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 445 pte_t pte;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 446
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 447 do {
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 448 pte.pte_low = ptep->pte_low;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 449 smp_rmb();
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 450 pte.pte_high = ptep->pte_high;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 451 smp_rmb();
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 452 } while (unlikely(pte.pte_low != ptep->pte_low));
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 453
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 454 return pte;
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 455 }
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 456 #define ptep_get_lockless ptep_get_lockless
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 457
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 458 #if CONFIG_PGTABLE_LEVELS > 2
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 459 static inline pmd_t pmdp_get_lockless(pmd_t *pmdp)
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 460 {
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 461 pmd_t pmd;
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 462
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 463 do {
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 464 pmd.pmd_low = pmdp->pmd_low;
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 465 smp_rmb();
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 466 pmd.pmd_high = pmdp->pmd_high;
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 467 smp_rmb();
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 468 } while (unlikely(pmd.pmd_low != pmdp->pmd_low));
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 469
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 470 return pmd;
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 471 }
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 472 #define pmdp_get_lockless pmdp_get_lockless
146b42e07494e4 include/linux/pgtable.h Hugh Dickins 2023-07-11 473 #define pmdp_get_lockless_sync() tlb_remove_table_sync_one()
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 474 #endif /* CONFIG_PGTABLE_LEVELS > 2 */
6ca297d4784625 include/linux/pgtable.h Peter Zijlstra 2022-10-21 475 #endif /* CONFIG_GUP_GET_PXX_LOW_HIGH */
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 476
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 477 /*
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 478 * We require that the PTE can be read atomically.
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 479 */
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 480 #ifndef ptep_get_lockless
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 481 static inline pte_t ptep_get_lockless(pte_t *ptep)
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 482 {
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 483 return ptep_get(ptep);
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 484 }
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 485 #endif
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 486
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 487 #ifndef pmdp_get_lockless
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 488 static inline pmd_t pmdp_get_lockless(pmd_t *pmdp)
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 489 {
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 490 return pmdp_get(pmdp);
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 491 }
146b42e07494e4 include/linux/pgtable.h Hugh Dickins 2023-07-11 492 static inline void pmdp_get_lockless_sync(void)
146b42e07494e4 include/linux/pgtable.h Hugh Dickins 2023-07-11 493 {
146b42e07494e4 include/linux/pgtable.h Hugh Dickins 2023-07-11 494 }
024d232ae4fcd7 include/linux/pgtable.h Peter Zijlstra 2020-11-26 495 #endif
2a4a06da8a4b93 include/linux/pgtable.h Peter Zijlstra 2020-11-13 496
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 497 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 498 #ifndef __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR
8809aa2d28d741 include/asm-generic/pgtable.h Aneesh Kumar K.V 2015-06-24 499 static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 500 unsigned long address,
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 501 pmd_t *pmdp)
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 502 {
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 503 pmd_t pmd = *pmdp;
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 504
2d28a2275c21d0 include/asm-generic/pgtable.h Catalin Marinas 2012-10-08 @505 pmd_clear(pmdp);
1831414cd729a3 include/linux/pgtable.h Kemeng Shi 2023-07-14 506 page_table_check_pmd_clear(mm, pmd);
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 507
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 508 return pmd;
49b24d6b41c576 include/asm-generic/pgtable.h Nicolas Kaiser 2011-06-15 509 }
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 510 #endif /* __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR */
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 511 #ifndef __HAVE_ARCH_PUDP_HUGE_GET_AND_CLEAR
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 512 static inline pud_t pudp_huge_get_and_clear(struct mm_struct *mm,
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 513 unsigned long address,
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 514 pud_t *pudp)
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 515 {
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 516 pud_t pud = *pudp;
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 517
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 @518 pud_clear(pudp);
931c38e16499a0 include/linux/pgtable.h Kemeng Shi 2023-07-14 519 page_table_check_pud_clear(mm, pud);
de8c8e52836d00 include/linux/pgtable.h Tong Tiangen 2022-05-12 520
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 521 return pud;
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 522 }
a00cc7d9dd93d6 include/asm-generic/pgtable.h Matthew Wilcox 2017-02-24 523 #endif /* __HAVE_ARCH_PUDP_HUGE_GET_AND_CLEAR */
e2cda322648122 include/asm-generic/pgtable.h Andrea Arcangeli 2011-01-13 524 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
^1da177e4c3f41 include/asm-generic/pgtable.h Linus Torvalds 2005-04-16 525

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-10-08 16:20:38

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

Hi brookxu.cn,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on linus/master v6.6-rc4 next-20231006]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/brookxu-cn/delayacct-introduce-delayacct_enabled-to-simplify-implement/20231008-185144
base: tip/sched/core
patch link: https://lore.kernel.org/r/531ddc82793a39f4c09316d701a4b1170bcad4ab.1696761522.git.chunguang.xu%40shopee.com
patch subject: [PATCH 2/3] delayacct: convert task->delays to a object
config: x86_64-randconfig-002-20231008 (https://download.01.org/0day-ci/archive/20231009/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231009/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

In file included from arch/x86/include/asm/paravirt_types.h:19,
from arch/x86/include/asm/ptrace.h:97,
from arch/x86/include/asm/math_emu.h:5,
from arch/x86/include/asm/processor.h:13,
from arch/x86/include/asm/timex.h:5,
from include/linux/timex.h:67,
from include/linux/time32.h:13,
from include/linux/time.h:60,
from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:11,
from arch/x86/entry/vdso/vdso32/vclock_gettime.c:4:
arch/x86/include/asm/pgtable.h: In function 'pte_flags_pkey':
>> arch/x86/include/asm/pgtable_types.h:66:43: warning: left shift count >= width of type [-Wshift-count-overflow]
66 | #define _PAGE_PKEY_BIT0 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT0)
| ^~
arch/x86/include/asm/pgtable_types.h:77:26: note: in expansion of macro '_PAGE_PKEY_BIT0'
77 | #define _PAGE_PKEY_MASK (_PAGE_PKEY_BIT0 | \
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable.h:1615:29: note: in expansion of macro '_PAGE_PKEY_MASK'
1615 | return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable_types.h:67:43: warning: left shift count >= width of type [-Wshift-count-overflow]
67 | #define _PAGE_PKEY_BIT1 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT1)
| ^~
arch/x86/include/asm/pgtable_types.h:78:26: note: in expansion of macro '_PAGE_PKEY_BIT1'
78 | _PAGE_PKEY_BIT1 | \
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable.h:1615:29: note: in expansion of macro '_PAGE_PKEY_MASK'
1615 | return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable_types.h:68:43: warning: left shift count >= width of type [-Wshift-count-overflow]
68 | #define _PAGE_PKEY_BIT2 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT2)
| ^~
arch/x86/include/asm/pgtable_types.h:79:26: note: in expansion of macro '_PAGE_PKEY_BIT2'
79 | _PAGE_PKEY_BIT2 | \
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable.h:1615:29: note: in expansion of macro '_PAGE_PKEY_MASK'
1615 | return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable_types.h:69:43: warning: left shift count >= width of type [-Wshift-count-overflow]
69 | #define _PAGE_PKEY_BIT3 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT3)
| ^~
arch/x86/include/asm/pgtable_types.h:80:26: note: in expansion of macro '_PAGE_PKEY_BIT3'
80 | _PAGE_PKEY_BIT3)
| ^~~~~~~~~~~~~~~
arch/x86/include/asm/pgtable.h:1615:29: note: in expansion of macro '_PAGE_PKEY_MASK'
1615 | return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
| ^~~~~~~~~~~~~~~
In file included from include/linux/pgtable.h:6,
from include/linux/kasan.h:33,
from include/linux/slab.h:180,
from include/linux/delayacct.h:62,
from include/linux/sched.h:40,
from include/linux/sched/mm.h:7,
from include/linux/xarray.h:19,
from include/linux/radix-tree.h:21,
from include/linux/idr.h:15,
from include/linux/kernfs.h:12,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/clocksource.h:19,
from include/clocksource/hyperv_timer.h:16,
from arch/x86/include/asm/vdso/gettimeofday.h:21,
from include/vdso/datapage.h:137,
from arch/x86/entry/vdso/vdso32/../../../../../lib/vdso/gettimeofday.c:5,
from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:15,
from arch/x86/entry/vdso/vdso32/vclock_gettime.c:4:
>> arch/x86/include/asm/pgtable.h:1615:46: warning: right shift count >= width of type [-Wshift-count-overflow]
1615 | return (pte_flags & _PAGE_PKEY_MASK) >> _PAGE_BIT_PKEY_BIT0;
| ^~
In file included from include/linux/kasan.h:33,
from include/linux/slab.h:180,
from include/linux/delayacct.h:62,
from include/linux/sched.h:40,
from include/linux/sched/mm.h:7,
from include/linux/xarray.h:19,
from include/linux/radix-tree.h:21,
from include/linux/idr.h:15,
from include/linux/kernfs.h:12,
from include/linux/sysfs.h:16,
from include/linux/kobject.h:20,
from include/linux/of.h:17,
from include/linux/clocksource.h:19,
from include/clocksource/hyperv_timer.h:16,
from arch/x86/include/asm/vdso/gettimeofday.h:21,
from include/vdso/datapage.h:137,
from arch/x86/entry/vdso/vdso32/../../../../../lib/vdso/gettimeofday.c:5,
from arch/x86/entry/vdso/vdso32/../vclock_gettime.c:15,
from arch/x86/entry/vdso/vdso32/vclock_gettime.c:4:
include/linux/pgtable.h: At top level:
include/linux/pgtable.h:1578:2: error: #error Missing MAX_POSSIBLE_PHYSMEM_BITS definition
1578 | #error Missing MAX_POSSIBLE_PHYSMEM_BITS definition
| ^~~~~


vim +66 arch/x86/include/asm/pgtable_types.h

8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 48
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 49 #define _PAGE_PRESENT (_AT(pteval_t, 1) << _PAGE_BIT_PRESENT)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 50 #define _PAGE_RW (_AT(pteval_t, 1) << _PAGE_BIT_RW)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 51 #define _PAGE_USER (_AT(pteval_t, 1) << _PAGE_BIT_USER)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 52 #define _PAGE_PWT (_AT(pteval_t, 1) << _PAGE_BIT_PWT)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 53 #define _PAGE_PCD (_AT(pteval_t, 1) << _PAGE_BIT_PCD)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 54 #define _PAGE_ACCESSED (_AT(pteval_t, 1) << _PAGE_BIT_ACCESSED)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 55 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 56 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 57 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
c46a7c817e662a Mel Gorman 2014-06-04 58 #define _PAGE_SOFTW1 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW1)
f955371ca9d398 David Vrabel 2014-01-07 59 #define _PAGE_SOFTW2 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW2)
6c0df8689494e1 Joerg Roedel 2018-07-18 60 #define _PAGE_SOFTW3 (_AT(pteval_t, 1) << _PAGE_BIT_SOFTW3)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 61 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 62 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 63 #define _PAGE_SPECIAL (_AT(pteval_t, 1) << _PAGE_BIT_SPECIAL)
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 64 #define _PAGE_CPA_TEST (_AT(pteval_t, 1) << _PAGE_BIT_CPA_TEST)
5c1d90f51027e1 Dave Hansen 2016-02-12 65 #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
5c1d90f51027e1 Dave Hansen 2016-02-12 @66 #define _PAGE_PKEY_BIT0 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT0)
5c1d90f51027e1 Dave Hansen 2016-02-12 67 #define _PAGE_PKEY_BIT1 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT1)
5c1d90f51027e1 Dave Hansen 2016-02-12 68 #define _PAGE_PKEY_BIT2 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT2)
5c1d90f51027e1 Dave Hansen 2016-02-12 69 #define _PAGE_PKEY_BIT3 (_AT(pteval_t, 1) << _PAGE_BIT_PKEY_BIT3)
5c1d90f51027e1 Dave Hansen 2016-02-12 70 #else
5c1d90f51027e1 Dave Hansen 2016-02-12 71 #define _PAGE_PKEY_BIT0 (_AT(pteval_t, 0))
5c1d90f51027e1 Dave Hansen 2016-02-12 72 #define _PAGE_PKEY_BIT1 (_AT(pteval_t, 0))
5c1d90f51027e1 Dave Hansen 2016-02-12 73 #define _PAGE_PKEY_BIT2 (_AT(pteval_t, 0))
5c1d90f51027e1 Dave Hansen 2016-02-12 74 #define _PAGE_PKEY_BIT3 (_AT(pteval_t, 0))
5c1d90f51027e1 Dave Hansen 2016-02-12 75 #endif
8d19c99faf6165 Jeremy Fitzhardinge 2009-02-08 76

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2023-10-09 08:44:14

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

On Sun, Oct 08, 2023 at 07:10:01PM +0800, brookxu wrote:

> > > @@ -1331,7 +1332,7 @@ struct task_struct {
> > > struct page_frag task_frag;
> > > #ifdef CONFIG_TASK_DELAY_ACCT
> > > - struct task_delay_info *delays;
> > > + struct task_delay_info delays;
> > > #endif
> > Yeah, no.

> Yes, this way will increase about 80 bytes for task_struct, about 0.85% of
> size of task_struct, I think this just like sched_statistics, so that can
> better support dynamically enable through sysctl.

But it's 80 bytes 'nobody' will use. And arguably we should do the same
with schedstats, that's default disabled and again, that's per-task
storage nobody ever uses.

Per this argument we can grow task_struct indefinitely until it
collapses in on itself by the sheer weight of it's information density.
Every additional field will be a smaller fraction of the total.

Yes, it makes it all a little more cumbersome, but we should really not
burden everybody with the load of some.

Surely there is another solution... ?

2023-10-09 10:29:40

by 许春光

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object


在 2023/10/9 16:43, Peter Zijlstra 写道:
> On Sun, Oct 08, 2023 at 07:10:01PM +0800, brookxu wrote:
>
>>>> @@ -1331,7 +1332,7 @@ struct task_struct {
>>>> struct page_frag task_frag;
>>>> #ifdef CONFIG_TASK_DELAY_ACCT
>>>> - struct task_delay_info *delays;
>>>> + struct task_delay_info delays;
>>>> #endif
>>> Yeah, no.
>> Yes, this way will increase about 80 bytes for task_struct, about 0.85% of
>> size of task_struct, I think this just like sched_statistics, so that can
>> better support dynamically enable through sysctl.
> But it's 80 bytes 'nobody' will use. And arguably we should do the same
> with schedstats, that's default disabled and again, that's per-task
> storage nobody ever uses.
>
> Per this argument we can grow task_struct indefinitely until it
> collapses in on itself by the sheer weight of it's information density.
> Every additional field will be a smaller fraction of the total.
>
> Yes, it makes it all a little more cumbersome, but we should really not
> burden everybody with the load of some.
>
> Surely there is another solution... ?
Thanks, agree with you, I try do it in other ways :)

2023-10-09 11:39:16

by 许春光

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object


在 2023/10/9 16:43, Peter Zijlstra 写道:
> On Sun, Oct 08, 2023 at 07:10:01PM +0800, brookxu wrote:
>
>>>> @@ -1331,7 +1332,7 @@ struct task_struct {
>>>> struct page_frag task_frag;
>>>> #ifdef CONFIG_TASK_DELAY_ACCT
>>>> - struct task_delay_info *delays;
>>>> + struct task_delay_info delays;
>>>> #endif
>>> Yeah, no.
>> Yes, this way will increase about 80 bytes for task_struct, about 0.85% of
>> size of task_struct, I think this just like sched_statistics, so that can
>> better support dynamically enable through sysctl.
> But it's 80 bytes 'nobody' will use. And arguably we should do the same
> with schedstats, that's default disabled and again, that's per-task
> storage nobody ever uses.
>
> Per this argument we can grow task_struct indefinitely until it
> collapses in on itself by the sheer weight of it's information density.
> Every additional field will be a smaller fraction of the total.
>
> Yes, it makes it all a little more cumbersome, but we should really not
> burden everybody with the load of some.
>
> Surely there is another solution... ?

Hi, peter:

I found another question when I tried to allocate task_delay_info on
demand, it is hard for us to

determine whether tsk->delays is NULL due to memory failure or delayacct
disabled, if due to

memory failure I think we should not try to allocate it again, otherwise
we may have performance

issues, such as following code. If we limit only try once, the code is
very trick..


bool delayacct_enter(struct task_struct *tsk)

{
        if (!static_branch_unlikely(&delayacct_key))
                return false;

        if (tsk->delays && !IS_ERR(tsk->delays))
                return true;

        if (!cmpxchg(&tsk->delays, NULL, -1))
                __delayacct_tsk_init(tsk);

        return !IS_ERR_OR_NULL(tsk->delays);

}

static inline void delayacct_blkio_start(void)
{
        if (delayacct_enable(current))
                __delayacct_blkio_start();
}

static inline void delayacct_blkio_end(struct task_struct *p)
{
        if (delayacct_enable(p))
                __delayacct_blkio_end(p);
}


do you have any suggestion?

2023-10-09 14:17:16

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

On Mon, Oct 09, 2023 at 06:29:15PM +0800, brookxu wrote:
>
> 在 2023/10/9 16:43, Peter Zijlstra 写道:
> > On Sun, Oct 08, 2023 at 07:10:01PM +0800, brookxu wrote:
> >
> > > > > @@ -1331,7 +1332,7 @@ struct task_struct {
> > > > > struct page_frag task_frag;
> > > > > #ifdef CONFIG_TASK_DELAY_ACCT
> > > > > - struct task_delay_info *delays;
> > > > > + struct task_delay_info delays;
> > > > > #endif
> > > > Yeah, no.
> > > Yes, this way will increase about 80 bytes for task_struct, about 0.85% of
> > > size of task_struct, I think this just like sched_statistics, so that can
> > > better support dynamically enable through sysctl.
> > But it's 80 bytes 'nobody' will use. And arguably we should do the same
> > with schedstats, that's default disabled and again, that's per-task
> > storage nobody ever uses.
> >
> > Per this argument we can grow task_struct indefinitely until it
> > collapses in on itself by the sheer weight of it's information density.
> > Every additional field will be a smaller fraction of the total.
> >
> > Yes, it makes it all a little more cumbersome, but we should really not
> > burden everybody with the load of some.
> >
> > Surely there is another solution... ?
> Thanks, agree with you, I try do it in other ways :)

One option is to first flip the static key and then iterate all existing
tasks, allocating the memory structure. New tasks will get it allocated
per the static key, existing tasks will get it allocated per the
iteration and dying tasks we don't care about.

That would be sufficient, no?

2023-10-09 14:18:59

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 2/3] delayacct: convert task->delays to a object

On Mon, Oct 09, 2023 at 07:38:58PM +0800, brookxu wrote:

> I found another question when I tried to allocate task_delay_info on demand,
> it is hard for us to
>
> determine whether tsk->delays is NULL due to memory failure or delayacct
> disabled, if due to
>
> memory failure I think we should not try to allocate it again, otherwise we
> may have performance
>
> issues, such as following code. If we limit only try once, the code is very
> trick..

Yeah, I wouldn't worry about that. Not until it's shown to be a real
issue. First do the simple thing, only make it more complicated if
there's a real need.