From: Jan Kara <jack@suse.cz>
To: Matthew Wilcox <willy@infradead.org>
Cc: Jan Kara <jack@suse.cz>,
linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH 2/3] flex_proportions: Allow N events instead of 1
Date: Wed, 31 Mar 2021 11:26:29 +0200 [thread overview]
Message-ID: <20210331092629.GD30749@quack2.suse.cz> (raw)
In-Reply-To: <20210322223527.GX1719932@casper.infradead.org>
On Mon 22-03-21 22:35:27, Matthew Wilcox wrote:
> On Mon, Mar 22, 2021 at 08:11:15PM +0000, Matthew Wilcox (Oracle) wrote:
> > -void __fprop_inc_percpu_max(struct fprop_global *p,
> > - struct fprop_local_percpu *pl, int max_frac)
> > +void __fprop_add_percpu_max(struct fprop_global *p,
> > + struct fprop_local_percpu *pl, int max_frac, long nr)
> > {
> > if (unlikely(max_frac < FPROP_FRAC_BASE)) {
>
> Oh, I meant to ask ... should this change? Should it be:
>
> if (unlikely(max_frac < FPROP_FRAC_BASE / nr))
> (or something similar that copes with overflow properly)
> I must confess to not understanding exactly how flex_proportions works.
No, __fprop_inc_percpu_max() implements "saturation" arithmetics on
fractions. So if the fraction tracked by 'pl' exceeds
max_frac/FPROP_FRAC_BASE, we don't want to increment 'pl' further. If 'nr'
is going to be small, we probably don't care that we somewhat exceed the
max_frac/FPROP_FRAC_BASE. But I suppose 'nr' can be say 512 at which point
(given FPROP_FRAC_BASE is 1024) one addition can make a very significant
difference. So we probably need to be more clever like:
if (unlikely(max_frac < FPROP_FRAC_BASE)) {
unsigned long numerator, denominator;
s64 tmp;
fprop_fraction_percpu(p, pl, &numerator, &denominator);
/* Adding 'nr' to fraction exceeds max_frac/FPROP_FRAC_BASE? */
tmp = (u64)denominator * max_frac -
((u64)numerator << FPROP_FRAC_SHIFT);
if (tmp < 0) {
/* Maximum fraction already exceeded? */
return;
} else if (tmp < nr * (FPROP_FRAC_BASE - max_frac)) {
/* Add just enough for the fraction to saturate */
nr = div_u64(tmp + FPROP_FRAC_BASE - max_frac - 1,
FPROP_FRAC_BASE - max_frac);
}
}
Honza
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2021-03-31 9:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 20:11 [PATCH 0/3] Allow for multiple pages in a single writeback event Matthew Wilcox (Oracle)
2021-03-22 20:11 ` [PATCH 1/3] mm/writeback: Rename __add_wb_stat to wb_stat_mod Matthew Wilcox (Oracle)
2021-03-22 20:11 ` [PATCH 2/3] flex_proportions: Allow N events instead of 1 Matthew Wilcox (Oracle)
2021-03-22 22:35 ` Matthew Wilcox
2021-03-31 9:26 ` Jan Kara [this message]
2021-03-22 20:11 ` [PATCH 3/3] mm/writeback: Change __wb_writeout_inc to __wb_writeout_add Matthew Wilcox (Oracle)
2021-03-31 9:28 ` [PATCH 0/3] Allow for multiple pages in a single writeback event Jan Kara
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=20210331092629.GD30749@quack2.suse.cz \
--to=jack@suse.cz \
--cc=hannes@cmpxchg.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/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