All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux MM <linux-mm@kvack.org>
Subject: Re: [PATCH] Revert "mm/page-writeback.c: print a warning if the vm dirtiness settings are illogical" (was: Re: [PATCH] mm: print a warning once the vm dirtiness settings is illogical)
Date: Tue, 28 Nov 2017 18:16:38 +0800	[thread overview]
Message-ID: <CALOAHbDy6aoiW4x+YAj3nqfo7PRxxdrGbvF6MBnKP=24M0uigQ@mail.gmail.com> (raw)
In-Reply-To: <20171128100946.GI5977@quack2.suse.cz>

2017-11-28 18:09 GMT+08:00 Jan Kara <jack@suse.cz>:
> On Tue 28-11-17 15:52:50, Yafang Shao wrote:
>> 2017-11-28 15:45 GMT+08:00 Michal Hocko <mhocko@suse.com>:
>> > On Tue 28-11-17 14:12:15, Yafang Shao wrote:
>> >> 2017-11-28 11:11 GMT+08:00 Yafang Shao <laoar.shao@gmail.com>:
>> >> > Hi Michal,
>> >> >
>> >> > What about bellow change ?
>> >> > It makes the function  domain_dirty_limits() more clear.
>> >> > And the result will have a higher precision.
>> >> >
>> >> >
>> >> > diff --git a/mm/page-writeback.c b/mm/page-writeback.c
>> >> > index 8a15511..2b5e507 100644
>> >> > --- a/mm/page-writeback.c
>> >> > +++ b/mm/page-writeback.c
>> >> > @@ -397,8 +397,8 @@ static void domain_dirty_limits(struct
>> >> > dirty_throttle_control *dtc)
>> >> >     unsigned long bytes = vm_dirty_bytes;
>> >> >     unsigned long bg_bytes = dirty_background_bytes;
>> >> >     /* convert ratios to per-PAGE_SIZE for higher precision */
>> >> > -   unsigned long ratio = (vm_dirty_ratio * PAGE_SIZE) / 100;
>> >> > -   unsigned long bg_ratio = (dirty_background_ratio * PAGE_SIZE) / 100;
>> >> > +   unsigned long ratio = vm_dirty_ratio;
>> >> > +   unsigned long bg_ratio = dirty_background_ratio;
>> >> >     unsigned long thresh;
>> >> >     unsigned long bg_thresh;
>> >> >     struct task_struct *tsk;
>> >> > @@ -416,28 +416,33 @@ static void domain_dirty_limits(struct
>> >> > dirty_throttle_control *dtc)
>> >> >          */
>> >> >         if (bytes)
>> >> >             ratio = min(DIV_ROUND_UP(bytes, global_avail),
>> >> > -                   PAGE_SIZE);
>> >> > +                   100);
>> >> >         if (bg_bytes)
>> >> >             bg_ratio = min(DIV_ROUND_UP(bg_bytes, global_avail),
>> >> > -                      PAGE_SIZE);
>> >> > +                      99);   /* bg_ratio should less than ratio */
>> >> >         bytes = bg_bytes = 0;
>> >> >     }
>> >>
>> >>
>> >> Errata:
>> >>
>> >>         if (bytes)
>> >> -           ratio = min(DIV_ROUND_UP(bytes, global_avail),
>> >> -                   PAGE_SIZE);
>> >> +           ratio = min(DIV_ROUND_UP(bytes / PAGE_SIZE, global_avail),
>> >> +                   100);
>> >>         if (bg_bytes)
>> >> -           bg_ratio = min(DIV_ROUND_UP(bg_bytes, global_avail),
>> >> -                      PAGE_SIZE);
>> >> +           bg_ratio = min(DIV_ROUND_UP(bg_bytes / PAGE_SIZE, global_avail),
>> >> +                      100 - 1); /* bg_ratio should be less than ratio */
>> >>         bytes = bg_bytes = 0;
>> >
>> > And you really think this makes code easier to follow? I am somehow not
>> > conviced...
>> >
>>
>> There's hidden bug in the original code, because it is too complex to
>> clearly understand.
>> See bellow,
>>
>> ratio = min(DIV_ROUND_UP(bytes, global_avail),
>>                     PAGE_SIZE)
>>
>> Suppose the vm_dirty_bytes is set to 512M (this is a reasonable
>> value), and the global_avail is only 10000 pages (this is not low),
>> then DIV_ROUND_UP(bytes, global_avail) is 53688, which is bigger than
>> 4096, so the ratio will be 4096.
>> That's unreasonable.
>
> But that's not a bug in domain_dirty_limits(). It is more a design issue of
> the dirty_bytes interface - i.e., if you tell the system that 512M of dirty
> pages is fine, then it is fine even if you have only 400M of page cache -
> i.e., 100% of page cache can be dirty and that's what the function
> computes.  Bad luck if you don't like that but that's how the interface was
> (mis)designed. We can talk about changes to what dirty_bytes mean under a
> situation when there is low amount of page cache but that will be a
> userspace visible change and we will have to be *very* careful not to break
> current users.
>

Thanks for your suggestion.
I will submit a patch for that.

Thanks
Yafang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-11-28 10:16 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-28  9:54 [PATCH] mm: print a warning once the vm dirtiness settings is illogical Yafang Shao
2017-11-25 16:05 ` Tetsuo Handa
2017-11-26  2:24   ` Yafang Shao
2017-11-26  2:42     ` Tetsuo Handa
2017-11-26  4:32       ` Yafang Shao
2017-11-26  8:03         ` Tetsuo Handa
2017-11-26  8:27           ` Yafang Shao
2017-11-26  8:46           ` Yafang Shao
2017-11-26 10:38             ` Tetsuo Handa
2017-11-27  8:06               ` Yafang Shao
2017-11-27  8:21                 ` Michal Hocko
2017-11-27  8:29                   ` Yafang Shao
2017-11-27  8:32                     ` Yafang Shao
2017-11-27  8:37                       ` Michal Hocko
2017-11-27  8:49                         ` Yafang Shao
2017-11-27  8:52                           ` Michal Hocko
2017-11-27  8:54                             ` Yafang Shao
2017-11-27  9:04                               ` Michal Hocko
2017-11-27  9:08                                 ` Yafang Shao
2017-11-27  8:34                     ` Michal Hocko
2017-11-27  9:19   ` [PATCH] Revert "mm/page-writeback.c: print a warning if the vm dirtiness settings are illogical" (was: Re: [PATCH] mm: print a warning once the vm dirtiness settings is illogical) Michal Hocko
2017-11-28  3:11     ` Yafang Shao
2017-11-28  6:12       ` Yafang Shao
2017-11-28  7:45         ` Michal Hocko
2017-11-28  7:52           ` Yafang Shao
2017-11-28  9:43             ` Yafang Shao
2017-11-28  9:45             ` Michal Hocko
2017-11-28 10:09             ` Jan Kara
2017-11-28 10:16               ` Yafang Shao [this message]
2017-11-28 10:25       ` Jan Kara
2017-11-28 10:33         ` Yafang Shao
2017-11-28 10:41           ` Jan Kara
2017-11-28 10:44             ` Yafang Shao
2017-11-28 10:37     ` Jan Kara
2017-11-28 10:48       ` Michal Hocko
2017-11-28 11:05         ` Yafang Shao
2017-11-28 11:54           ` Michal Hocko

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='CALOAHbDy6aoiW4x+YAj3nqfo7PRxxdrGbvF6MBnKP=24M0uigQ@mail.gmail.com' \
    --to=laoar.shao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jack@suse.cz \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.