linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: cgel.zte@gmail.com
Cc: bsingharora@gmail.com, iamjoonsoo.kim@lge.com, mingo@redhat.com,
	bristot@redhat.com, vschneid@redhat.com, willy@infradead.org,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-mm@kvack.org, Yang Yang <yang.yang29@zte.com.cn>,
	Ran Xiaokai <ran.xiaokai@zte.com.cn>,
	wangyong <wang.yong12@zte.com.cn>
Subject: Re: [PATCH 1/2] delayacct: support re-entrance detection of thrashing accounting
Date: Sat, 13 Aug 2022 16:23:25 -0700	[thread overview]
Message-ID: <20220813162325.57bb5d703d0063d717dc47e9@linux-foundation.org> (raw)
In-Reply-To: <20220813074108.58196-1-yang.yang29@zte.com.cn>

On Sat, 13 Aug 2022 07:41:09 +0000 cgel.zte@gmail.com wrote:

> From: Yang Yang <yang.yang29@zte.com.cn>
> 
> Once upon a time, we only support accounting thrashing of page cache.
> Then Joonsoo introduced workingset detection for anonymous pages and
> we gained the ability to account thrashing of them[1].
> 
> For page cache thrashing accounting, there is no suitable place to do
> it in fs level likes swap_readpage(). So we have to do it in
> folio_wait_bit_common().
> 
> Then for anonymous pages thrashing accounting, we have to do it in
> both swap_readpage() and folio_wait_bit_common(). This likes PSI,
> so we should let thrashing accounting supports re-entrance detection.
> 
> This patch is to prepare complete thrashing accounting, and is based
> on patch "filemap: make the accounting of thrashing more consistent".
> 
> -static inline void delayacct_thrashing_start(void)
> +static inline void delayacct_thrashing_start(unsigned long *flags)

I don't think that `flags' is a very descriptive name.  It might be
anything.  

> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -943,6 +943,10 @@ struct task_struct {
>  #ifdef	CONFIG_CPU_SUP_INTEL
>  	unsigned			reported_split_lock:1;
>  #endif
> +#ifdef CONFIG_TASK_DELAY_ACCT
> +	/* delay due to memory thrashing */
> +	unsigned                        in_thrashing:1;
> +#endif

OK, saving space in the task_struct is good.

>  	unsigned long			atomic_flags; /* Flags requiring atomic access. */
>  
> diff --git a/kernel/delayacct.c b/kernel/delayacct.c
> index 164ed9ef77a3..a5916196022f 100644
> --- a/kernel/delayacct.c
> +++ b/kernel/delayacct.c
> @@ -214,13 +214,22 @@ void __delayacct_freepages_end(void)
>  		      &current->delays->freepages_count);
>  }
>  
> -void __delayacct_thrashing_start(void)
> +void __delayacct_thrashing_start(unsigned long *flags)
>  {
> +	*flags = current->in_thrashing;
> +	if (*flags)
> +		return;

Can't we rename `flags' to `in_thrashing' throughout?

And may as well give it type `bool'.  And convert that bool to/from the
bitfield when moving it in and out of the task_struct with

	*in_thrashing = !!current->in_thrashing;

	current->in_thrashing = (in_thrashing != 0);




      reply	other threads:[~2022-08-13 23:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-13  7:41 cgel.zte
2022-08-13 23:23 ` Andrew Morton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220813162325.57bb5d703d0063d717dc47e9@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=bristot@redhat.com \
    --cc=bsingharora@gmail.com \
    --cc=cgel.zte@gmail.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=ran.xiaokai@zte.com.cn \
    --cc=vschneid@redhat.com \
    --cc=wang.yong12@zte.com.cn \
    --cc=willy@infradead.org \
    --cc=yang.yang29@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox