* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-21 16:19 ` [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister Manjong Lee
@ 2021-10-21 11:16 ` Christoph Hellwig
2021-10-21 12:01 ` Matthew Wilcox
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2021-10-21 11:16 UTC (permalink / raw)
To: Manjong Lee
Cc: akpm, linux-mm, linux-kernel, seunghwan.hyun, sookwan7.kim,
nanich.lee, yt0928.kim, junho89.kim, jisoo2146.oh
On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> Because when sdcard is removed, bdi_min_ratio value will remain.
> Currently, the only way to reset bdi_ min_ratio is to reboot.
But bdis that are unregistered are never re-registered. What is
the problem you're trying to solve?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-21 11:16 ` Christoph Hellwig
@ 2021-10-21 12:01 ` Matthew Wilcox
2021-10-22 2:45 ` Andrew Morton
0 siblings, 1 reply; 8+ messages in thread
From: Matthew Wilcox @ 2021-10-21 12:01 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Manjong Lee, akpm, linux-mm, linux-kernel, seunghwan.hyun,
sookwan7.kim, nanich.lee, yt0928.kim, junho89.kim, jisoo2146.oh
On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > Because when sdcard is removed, bdi_min_ratio value will remain.
> > Currently, the only way to reset bdi_ min_ratio is to reboot.
>
> But bdis that are unregistered are never re-registered. What is
> the problem you're trying to solve?
The global bdi_min_ratio needs to be adjusted. See
bdi_set_min_ratio() in mm/page-writeback.c.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
[not found] <CGME20211021072307epcas1p4aa4388c13e71a66e3e1d5f7ee68b5a7f@epcas1p4.samsung.com>
@ 2021-10-21 16:19 ` Manjong Lee
2021-10-21 11:16 ` Christoph Hellwig
0 siblings, 1 reply; 8+ messages in thread
From: Manjong Lee @ 2021-10-21 16:19 UTC (permalink / raw)
To: mj0123.lee, akpm, linux-mm, linux-kernel
Cc: seunghwan.hyun, sookwan7.kim, nanich.lee, yt0928.kim,
junho89.kim, jisoo2146.oh
Initialize min_ratio if it is set when bdi unregister.
It can prevent problems that may occur when bdi is removed
without resetting min_ratio.
For example.
1) insert external sdcard
2) set external sdcard's min_ratio 70
3) remove external sdcard without setting min_ratio 0
4) insert external sdcard
5) set external sdcard's min_ratio 70 << error occur(can't set)
Because when sdcard is removed, bdi_min_ratio value will remain.
Currently, the only way to reset bdi_ min_ratio is to reboot.
Signed-off-by: Manjong Lee <mj0123.lee@samsung.com>
---
mm/backing-dev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/mm/backing-dev.c b/mm/backing-dev.c
index 4a9d4e27d0d9..ca53807be188 100644
--- a/mm/backing-dev.c
+++ b/mm/backing-dev.c
@@ -947,6 +947,11 @@ void bdi_unregister(struct backing_dev_info *bdi)
wb_shutdown(&bdi->wb);
cgwb_bdi_unregister(bdi);
+ /* if min ratio doesn't 0, it has to set 0 before unregister */
+ if (bdi->min_ratio) {
+ bdi_set_min_ratio(bdi, 0);
+ }
+
if (bdi->dev) {
bdi_debug_unregister(bdi);
device_unregister(bdi->dev);
--
2.32.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-21 12:01 ` Matthew Wilcox
@ 2021-10-22 2:45 ` Andrew Morton
2021-10-22 2:58 ` Matthew Wilcox
2021-12-10 21:36 ` Peter Zijlstra
0 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2021-10-22 2:45 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Christoph Hellwig, Manjong Lee, linux-mm, linux-kernel,
seunghwan.hyun, sookwan7.kim, nanich.lee, yt0928.kim,
junho89.kim, jisoo2146.oh
On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
> On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > > Because when sdcard is removed, bdi_min_ratio value will remain.
> > > Currently, the only way to reset bdi_ min_ratio is to reboot.
> >
> > But bdis that are unregistered are never re-registered. What is
> > the problem you're trying to solve?
>
> The global bdi_min_ratio needs to be adjusted. See
> bdi_set_min_ratio() in mm/page-writeback.c.
I added cc:stable to this and tweaked the comment & coding style a bit:
--- a/mm/backing-dev.c~mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister-fix
+++ a/mm/backing-dev.c
@@ -947,10 +947,12 @@ void bdi_unregister(struct backing_dev_i
wb_shutdown(&bdi->wb);
cgwb_bdi_unregister(bdi);
- /* if min ratio doesn't 0, it has to set 0 before unregister */
- if (bdi->min_ratio) {
+ /*
+ * If this BDI's min ratio has been set, use bdi_set_min_ratio() to
+ * update the global bdi_min_ratio.
+ */
+ if (bdi->min_ratio)
bdi_set_min_ratio(bdi, 0);
- }
if (bdi->dev) {
bdi_debug_unregister(bdi);
_
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-22 2:45 ` Andrew Morton
@ 2021-10-22 2:58 ` Matthew Wilcox
[not found] ` <CGME20211022043310epcas1p22952e8fa3eb3675717badae9a3e1223e@epcas1p2.samsung.com>
2021-12-10 21:35 ` Peter Zijlstra
2021-12-10 21:36 ` Peter Zijlstra
1 sibling, 2 replies; 8+ messages in thread
From: Matthew Wilcox @ 2021-10-22 2:58 UTC (permalink / raw)
To: Andrew Morton
Cc: Christoph Hellwig, Manjong Lee, linux-mm, linux-kernel,
seunghwan.hyun, sookwan7.kim, nanich.lee, yt0928.kim,
junho89.kim, jisoo2146.oh
On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote:
> On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > > > Because when sdcard is removed, bdi_min_ratio value will remain.
> > > > Currently, the only way to reset bdi_ min_ratio is to reboot.
> > >
> > > But bdis that are unregistered are never re-registered. What is
> > > the problem you're trying to solve?
> >
> > The global bdi_min_ratio needs to be adjusted. See
> > bdi_set_min_ratio() in mm/page-writeback.c.
>
> I added cc:stable to this and tweaked the comment & coding style a bit:
Definitely improvements on that front.
I don't know the BDI code particularly well, and the implementation of
bdi_set_min_ratio() confuses me, so I can't say whether the original
patch is clearly correct or not.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re:Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
[not found] ` <CGME20211022043310epcas1p22952e8fa3eb3675717badae9a3e1223e@epcas1p2.samsung.com>
@ 2021-10-22 13:39 ` Manjong Lee
0 siblings, 0 replies; 8+ messages in thread
From: Manjong Lee @ 2021-10-22 13:39 UTC (permalink / raw)
To: willy
Cc: akpm, hch, jisoo2146.oh, junho89.kim, linux-kernel, linux-mm,
mj0123.lee, nanich.lee, seunghwan.hyun, sookwan7.kim, yt0928.kim
>On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote:
>> On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>>
>> > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
>> > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
>> > > > Because when sdcard is removed, bdi_min_ratio value will remain.
>> > > > Currently, the only way to reset bdi_ min_ratio is to reboot.
>> > >
>> > > But bdis that are unregistered are never re-registered. What is
>> > > the problem you're trying to solve?
>> >
>> > The global bdi_min_ratio needs to be adjusted. See
>> > bdi_set_min_ratio() in mm/page-writeback.c.
>>
>> I added cc:stable to this and tweaked the comment & coding style a bit:
>
>Definitely improvements on that front.
>
>I don't know the BDI code particularly well, and the implementation of
>bdi_set_min_ratio() confuses me, so I can't say whether the original
>patch is clearly correct or not.
Thank Andrew Morton for modifying the comment & style. :)
Dear Matthew Wilcox.
Please tell me about it more? I want to know more,
and I want to find a way to improve it. :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-22 2:58 ` Matthew Wilcox
[not found] ` <CGME20211022043310epcas1p22952e8fa3eb3675717badae9a3e1223e@epcas1p2.samsung.com>
@ 2021-12-10 21:35 ` Peter Zijlstra
1 sibling, 0 replies; 8+ messages in thread
From: Peter Zijlstra @ 2021-12-10 21:35 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Andrew Morton, Christoph Hellwig, Manjong Lee, linux-mm,
linux-kernel, seunghwan.hyun, sookwan7.kim, nanich.lee,
yt0928.kim, junho89.kim, jisoo2146.oh
On Fri, Oct 22, 2021 at 03:58:13AM +0100, Matthew Wilcox wrote:
> On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote:
> > On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
> >
> > > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> > > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > > > > Because when sdcard is removed, bdi_min_ratio value will remain.
> > > > > Currently, the only way to reset bdi_ min_ratio is to reboot.
> > > >
> > > > But bdis that are unregistered are never re-registered. What is
> > > > the problem you're trying to solve?
> > >
> > > The global bdi_min_ratio needs to be adjusted. See
> > > bdi_set_min_ratio() in mm/page-writeback.c.
> >
> > I added cc:stable to this and tweaked the comment & coding style a bit:
>
> Definitely improvements on that front.
>
> I don't know the BDI code particularly well, and the implementation of
> bdi_set_min_ratio() confuses me, so I can't say whether the original
> patch is clearly correct or not.
Looks like something I might've written :-)
I'm thinking the part:
min_ratio -= bdi->min_ratio;
if (bdi_min_ratio + min_ratio < 100) {
bdi_min_ratio += min_ratio;
bdi->min_ratio += min_ratio;
}
is what confuses? particularly when min_ratio < bdi->min_ratio?
Anyway, two cases: bdi->min_ratio < min_ratio and bdi->min_ratio >
min_ratio, let's do both with 0 and 10.
bdi->min_ratio = 0, min_ratio = 10 gives us:
min_ratio -= bdi->min_ratio; // 10 -= 0 == 10
if (bdi_min_ratio + min_ratio < 100) { // x + 10 < 100
bdi_min_ratio += min_ratio; // x += 10
bdi->min_ratio += min_ratio // 0 += 10 == 10
}
The other way around, bdi->min_raito = 10, min_ratio = 0:
min_ratio -= bdi->min_ratio; // 0 -= 10 == -10
if (bdi_min_ratio + min_ratio < 100) { // x + -10 < 100
bdi_min_ratio += min_ratio; // x += -10
bdi->min_ratio += min_ratio; // 10 += -10 == 0
}
Makes sense?
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister
2021-10-22 2:45 ` Andrew Morton
2021-10-22 2:58 ` Matthew Wilcox
@ 2021-12-10 21:36 ` Peter Zijlstra
1 sibling, 0 replies; 8+ messages in thread
From: Peter Zijlstra @ 2021-12-10 21:36 UTC (permalink / raw)
To: Andrew Morton
Cc: Matthew Wilcox, Christoph Hellwig, Manjong Lee, linux-mm,
linux-kernel, seunghwan.hyun, sookwan7.kim, nanich.lee,
yt0928.kim, junho89.kim, jisoo2146.oh
On Thu, Oct 21, 2021 at 07:45:30PM -0700, Andrew Morton wrote:
> On Thu, 21 Oct 2021 13:01:30 +0100 Matthew Wilcox <willy@infradead.org> wrote:
>
> > On Thu, Oct 21, 2021 at 04:16:52AM -0700, Christoph Hellwig wrote:
> > > On Fri, Oct 22, 2021 at 01:19:43AM +0900, Manjong Lee wrote:
> > > > Because when sdcard is removed, bdi_min_ratio value will remain.
> > > > Currently, the only way to reset bdi_ min_ratio is to reboot.
> > >
> > > But bdis that are unregistered are never re-registered. What is
> > > the problem you're trying to solve?
> >
> > The global bdi_min_ratio needs to be adjusted. See
> > bdi_set_min_ratio() in mm/page-writeback.c.
>
> I added cc:stable to this and tweaked the comment & coding style a bit:
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> --- a/mm/backing-dev.c~mm-bdi-initialize-bdi_min_ratio-when-bdi-unregister-fix
> +++ a/mm/backing-dev.c
> @@ -947,10 +947,12 @@ void bdi_unregister(struct backing_dev_i
> wb_shutdown(&bdi->wb);
> cgwb_bdi_unregister(bdi);
>
> - /* if min ratio doesn't 0, it has to set 0 before unregister */
> - if (bdi->min_ratio) {
> + /*
> + * If this BDI's min ratio has been set, use bdi_set_min_ratio() to
> + * update the global bdi_min_ratio.
> + */
> + if (bdi->min_ratio)
> bdi_set_min_ratio(bdi, 0);
> - }
>
> if (bdi->dev) {
> bdi_debug_unregister(bdi);
> _
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2021-12-10 21:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CGME20211021072307epcas1p4aa4388c13e71a66e3e1d5f7ee68b5a7f@epcas1p4.samsung.com>
2021-10-21 16:19 ` [PATCH 1/1] mm: bdi: Initialize bdi_min_ratio when bdi unregister Manjong Lee
2021-10-21 11:16 ` Christoph Hellwig
2021-10-21 12:01 ` Matthew Wilcox
2021-10-22 2:45 ` Andrew Morton
2021-10-22 2:58 ` Matthew Wilcox
[not found] ` <CGME20211022043310epcas1p22952e8fa3eb3675717badae9a3e1223e@epcas1p2.samsung.com>
2021-10-22 13:39 ` Manjong Lee
2021-12-10 21:35 ` Peter Zijlstra
2021-12-10 21:36 ` Peter Zijlstra
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).