linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: chi wu <wuchi.zero@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, tan.hu@zte.com.cn
Subject: Re: [PATCH] lib/flex_proportions.c: Use abs() when percpu_counter is negative.
Date: Tue, 18 May 2021 12:39:28 +0200	[thread overview]
Message-ID: <20210518103928.GC28667@quack2.suse.cz> (raw)
In-Reply-To: <CA+tQmHBEvZTe9-7tReRHBw1tkTW7uGS5FhPZ41eZFOqtoyqkHQ@mail.gmail.com>

On Tue 18-05-21 18:22:05, chi wu wrote:
> Jan Kara <jack@suse.cz> 于2021年5月18日周二 下午4:59写道:
> >
> > On Tue 18-05-21 11:42:53, chi wu wrote:
> > > Chi Wu <wuchi.zero@gmail.com> 于2021年5月17日周一 下午11:53写道:
> > > >
> > > > The value of percpu_counter_read() may become negative after
> > > > running percpu_counter_sum() in fprop_reflect_period_percpu().
> > > > The value of variable 'num' will be zero in fprop_fraction_percpu()
> > > > when using percpu_counter_read_positive(), but if using the abs of
> > > > percpu_counter_read() will be close to the correct value.
> > > >
> > >
> > > I realized that I was wrong as follow:
> > > (a) the decay rule is broken, the negative means the difference in
> > > decay here.
> > > (b) as the target event increasing, proportion of the event will
> > > decrease to 0 firstly and then it will increase. The logic is bad.
> > > 1. abs(-50) / abs(100) = 50%       //+50 to 2
> > > 2. abs(0) / abs(150) = 0 %           //+50 to 3
> > > 3. abs(50)/abs(200) = 25%
> > >
> > > Anyway, the percpu_counter_sum() had cost a lost performance,
> > > may be we could get a little benefits from that. So could we add a
> > > variable to stroe the decay value, we will get the value when
> > > percpu_counter_read() is negative?
> >
> > The result of percpu_counter_read() is inherently inexact (but fast! ;). It
> > can be upto number_of_cpus * counter_batch away from the real counter
> > value. But do you observe any practical problems with this inaccuracy on
> > your system? Sure, cache memory won't be split among devices exactly
> > according to writeout proportion but that usually does not matter.
> >
> >                                                                 Honza
> >
> 
> Thanks, Got it.
> Just try to optimize the fuse (with strictlimit feature)performance
> issue: The writing thread will be paused and runs slowly, when the
> proportion of fuse-bdi is 0.
> The issue is normal,and one of reasons is the characteristics of
> percpu_counter batch. Even the pages are writeout, we may be could not
> get the real proportion value due to side effects of counter
> performance. It's just a slight disappointment.

Well, you can tune 'min_ratio' of the fuse-bdi to avoid problems with these
near-zero states... To always give the bdi some breathing room for ramping
up.

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2021-05-18 10:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 15:53 [PATCH] lib/flex_proportions.c: Use abs() when percpu_counter is negative Chi Wu
2021-05-18  3:42 ` chi wu
2021-05-18  8:59   ` Jan Kara
2021-05-18 10:22     ` chi wu
2021-05-18 10:39       ` Jan Kara [this message]
2021-05-18 11:55         ` chi wu

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=20210518103928.GC28667@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tan.hu@zte.com.cn \
    --cc=wuchi.zero@gmail.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).