linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Feng Tang <feng.tang@intel.com>
To: Hillf Danton <hdanton@sina.com>
Cc: Shakeel Butt <shakeelb@google.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Xing Zhengjun <zhengjun.xing@linux.intel.com>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [memcg] 45208c9105: aim7.jobs-per-min -14.0% regression
Date: Sun, 12 Sep 2021 21:29:14 +0800	[thread overview]
Message-ID: <20210912132914.GA56674@shbuild999.sh.intel.com> (raw)
In-Reply-To: <20210912111756.4158-1-hdanton@sina.com>

On Sun, Sep 12, 2021 at 07:17:56PM +0800, Hillf Danton wrote:
[...]
> > +//	if (!(__this_cpu_inc_return(stats_flush_threshold) % MEMCG_CHARGE_BATCH))
> > +	if (!(__this_cpu_inc_return(stats_flush_threshold) % 128))
> >  		queue_work(system_unbound_wq, &stats_flush_work);
> >  }
> 
> Hi Feng,
> 
> Would you please check if it helps fix the regression to avoid queuing a
> queued work by adding and checking an atomic counter.
 
Hi Hillf,

I just tested your patch, and it didn't recover the regression, but
just reduced it from -14% to around -13%, similar to the patch
increasing the batch charge number.

Thanks,
Feng


> Hillf
> 
> --- x/mm/memcontrol.c
> +++ y/mm/memcontrol.c
> @@ -108,6 +108,7 @@ static void flush_memcg_stats_dwork(stru
>  static DECLARE_DEFERRABLE_WORK(stats_flush_dwork, flush_memcg_stats_dwork);
>  static void flush_memcg_stats_work(struct work_struct *w);
>  static DECLARE_WORK(stats_flush_work, flush_memcg_stats_work);
> +static atomic_t sfwork_queued;
>  static DEFINE_PER_CPU(unsigned int, stats_flush_threshold);
>  static DEFINE_SPINLOCK(stats_flush_lock);
>  
> @@ -660,8 +661,13 @@ void __mod_memcg_lruvec_state(struct lru
>  
>  	/* Update lruvec */
>  	__this_cpu_add(pn->lruvec_stats_percpu->state[idx], val);
> -	if (!(__this_cpu_inc_return(stats_flush_threshold) % MEMCG_CHARGE_BATCH))
> -		queue_work(system_unbound_wq, &stats_flush_work);
> +	if (!(__this_cpu_inc_return(stats_flush_threshold) %
> +	      MEMCG_CHARGE_BATCH)) {
> +		int queued = atomic_read(&sfwork_queued);
> +
> +		if (!queued && atomic_try_cmpxchg(&sfwork_queued, &queued, 1))
> +			queue_work(system_unbound_wq, &stats_flush_work);
> +	}
>  }
>  
>  /**
> @@ -5376,6 +5382,7 @@ static void flush_memcg_stats_dwork(stru
>  static void flush_memcg_stats_work(struct work_struct *w)
>  {
>  	mem_cgroup_flush_stats();
> +	atomic_dec(&sfwork_queued);
>  }
>  
>  static void mem_cgroup_css_rstat_flush(struct cgroup_subsys_state *css, int cpu)

  parent reply	other threads:[~2021-09-12 13:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210902215504.dSSfDKJZu%akpm@linux-foundation.org>
2021-09-05 12:44 ` [memcg] 45208c9105: aim7.jobs-per-min -14.0% regression kernel test robot
2021-09-05 22:15   ` Shakeel Butt
2021-09-07  3:30     ` Feng Tang
2021-09-10  0:43       ` Shakeel Butt
2021-09-10  1:08         ` Feng Tang
2021-09-10  1:19           ` Shakeel Butt
2021-09-10  2:34             ` Feng Tang
2021-09-10  4:17               ` Shakeel Butt
     [not found]         ` <20210912111756.4158-1-hdanton@sina.com>
2021-09-12 13:29           ` Feng Tang [this message]
2021-09-13 16:41             ` Shakeel Butt
2021-09-13 19:40               ` Shakeel Butt
2021-09-13 19:42                 ` Tejun Heo
2021-09-13 20:09                   ` Shakeel Butt
2021-09-13 20:10                     ` Tejun Heo
2021-09-13 20:13                       ` Shakeel Butt
2021-09-14  2:13                         ` Feng Tang
2021-09-14  4:20                           ` Shakeel Butt

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=20210912132914.GA56674@shbuild999.sh.intel.com \
    --to=feng.tang@intel.com \
    --cc=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shakeelb@google.com \
    --cc=zhengjun.xing@linux.intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).